diff --git a/ChangeAppSettings.sh b/ChangeAppSettings.sh index a0e9a1f5d..515fd3d72 100755 --- a/ChangeAppSettings.sh +++ b/ChangeAppSettings.sh @@ -436,7 +436,7 @@ fi if [ -z "$ResetSdlConfigForThisVersion" -o -z "$AUTO" ]; then echo -echo "Reset SDL config when updating application to the new version (y) / (n) ($ResetSdlConfigForThisVersion): " +echo -n "Reset SDL config when updating application to the new version (y) / (n) ($ResetSdlConfigForThisVersion): " read var if [ -n "$var" ] ; then ResetSdlConfigForThisVersion="$var" diff --git a/build.sh b/build.sh index 3e58042f0..bac447419 100755 --- a/build.sh +++ b/build.sh @@ -34,5 +34,6 @@ cd project && env PATH=$NDKBUILDPATH nice -n19 ndk-build V=1 -j4 && \ `which ndk-build | sed 's@/ndk-build@@'`/toolchains/arm-linux-androideabi-4.4.3/prebuilt/$MYARCH/bin/arm-linux-androideabi-strip --strip-unneeded libs/armeabi/libapplication.so \ || true ; } && \ ant debug && \ - test -z "$1" && cd bin && adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && \ - adb install -r MainActivity-debug.apk + test -z "$1" && cd bin && \ + { adb install -r MainActivity-debug.apk || { \ + adb uninstall `grep AppFullName ../../AndroidAppSettings.cfg | sed 's/.*=//'` && adb install -r MainActivity-debug.apk ; } ; } diff --git a/project/jni/application/alienblaster/AndroidAppSettings.cfg b/project/jni/application/alienblaster/AndroidAppSettings.cfg index 3a509e0b5..afb6bc026 100644 --- a/project/jni/application/alienblaster/AndroidAppSettings.cfg +++ b/project/jni/application/alienblaster/AndroidAppSettings.cfg @@ -16,6 +16,7 @@ SdlVideoResizeKeepAspect=n CompatibilityHacks= AppUsesMouse=n AppNeedsTwoButtonMouse=n +ShowMouseCursor=n ForceRelativeMouseMode=n AppNeedsArrowKeys=y AppNeedsTextInput=y @@ -33,6 +34,7 @@ FirstStartMenuOptions='' MultiABI=n AppVersionCode=110014 AppVersionName="1.1.0.14" +ResetSdlConfigForThisVersion=n CompiledLibraries="sdl_mixer sdl_image" CustomBuildScript=n AppCflags='-O3' diff --git a/project/jni/application/alienblaster/SdlForwardCompat.h b/project/jni/application/alienblaster/SdlForwardCompat.h index dbe54440b..b0040c1d1 100644 --- a/project/jni/application/alienblaster/SdlForwardCompat.h +++ b/project/jni/application/alienblaster/SdlForwardCompat.h @@ -35,7 +35,7 @@ static inline SdlCompat_AcceleratedSurface * SdlCompat_CreateAcceleratedSurface( format = SDL_PIXELFORMAT_RGB565; if( surface->flags & SDL_SRCCOLORKEY ) - format = SDL_PIXELFORMAT_RGBA5551; + format = SDL_PIXELFORMAT_RGBA4444; ret->t = SDL_CreateTextureFromSurface(format, surface); diff --git a/project/jni/application/src b/project/jni/application/src index 92362c4db..0a7ca3edf 120000 --- a/project/jni/application/src +++ b/project/jni/application/src @@ -1 +1 @@ -ufoai \ No newline at end of file +gemrb-sdl-1.3 \ No newline at end of file diff --git a/project/jni/sdl-1.2/Android.mk b/project/jni/sdl-1.2/Android.mk deleted file mode 120000 index c06be4170..000000000 --- a/project/jni/sdl-1.2/Android.mk +++ /dev/null @@ -1 +0,0 @@ -../sdl-1.3/Android.mk \ No newline at end of file diff --git a/project/jni/sdl-1.2/Android.mk b/project/jni/sdl-1.2/Android.mk new file mode 100644 index 000000000..b32c0e2e5 --- /dev/null +++ b/project/jni/sdl-1.2/Android.mk @@ -0,0 +1,65 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +LOCAL_MODULE := $(lastword $(subst /, ,$(LOCAL_PATH))) + +ifndef SDL_JAVA_PACKAGE_PATH +$(error Please define SDL_JAVA_PACKAGE_PATH to the path of your Java package with dots replaced with underscores, for example "com_example_SanAngeles") +endif + +LOCAL_C_INCLUDES := $(LOCAL_PATH)/include +LOCAL_CFLAGS := -O3 \ + -DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH) \ + -DSDL_CURDIR_PATH=\"$(SDL_CURDIR_PATH)\" \ + -DSDL_TRACKBALL_KEYUP_DELAY=$(SDL_TRACKBALL_KEYUP_DELAY) \ + -DSDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT=$(SDL_VIDEO_RENDER_RESIZE_KEEP_ASPECT) \ + -DSDL_VIDEO_RENDER_RESIZE=$(SDL_VIDEO_RENDER_RESIZE) \ + $(SDL_ADDITIONAL_CFLAGS) + + +SDL_SRCS := \ + src/*.c \ + src/audio/*.c \ + src/cdrom/*.c \ + src/cpuinfo/*.c \ + src/events/*.c \ + src/file/*.c \ + src/haptic/*.c \ + src/joystick/*.c \ + src/stdlib/*.c \ + src/thread/*.c \ + src/timer/*.c \ + src/video/*.c \ + src/main/*.c \ + src/power/*.c \ + src/thread/pthread/*.c \ + src/timer/unix/*.c \ + src/audio/android/*.c \ + src/cdrom/dummy/*.c \ + src/video/android/*.c \ + src/video/android/*.cpp \ + src/haptic/dummy/*.c \ + src/loadso/dlopen/*.c \ + src/atomic/dummy/*.c \ + +# TODO: use libcutils for atomic operations, but it's not included in NDK + +# src/atomic/linux/*.c \ +# src/power/linux/*.c \ +# src/joystick/android/*.c \ +# src/haptic/android/*.c \ +# src/libm/*.c \ + +LOCAL_CPP_EXTENSION := .cpp + +# Note this "simple" makefile var substitution, you can find even more complex examples in different Android projects +LOCAL_SRC_FILES := $(foreach F, $(SDL_SRCS), $(addprefix $(dir $(F)),$(notdir $(wildcard $(LOCAL_PATH)/$(F))))) + +LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog + +ifneq ($(CRYSTAX_R5_TOOLCHAIN),) +LOCAL_LDLIBS += -L$(NDK_PATH)/sources/crystax/libs/armeabi -lcrystax_static +endif + +include $(BUILD_SHARED_LIBRARY) diff --git a/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h b/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h deleted file mode 120000 index 040f8b699..000000000 --- a/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h +++ /dev/null @@ -1 +0,0 @@ -../../../../sdl-1.3/src/video/SDL_glesfuncs.h \ No newline at end of file diff --git a/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h b/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h new file mode 100644 index 000000000..d8dc79dd5 --- /dev/null +++ b/project/jni/sdl-1.2/src/video/android/SDL_glesfuncs.h @@ -0,0 +1,229 @@ +/* list of OpenGL ES functions sorted alphabetically + If you need to use a GLES function from the SDL video subsystem, + change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild. +*/ +#define SDL_PROC_UNUSED(ret,func,params) + +SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum func, GLclampf ref)) +SDL_PROC(void, glClearColor, + (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) +SDL_PROC_UNUSED(void, glClearDepthf, (GLclampf depth)) +SDL_PROC_UNUSED(void, glClipPlanef, (GLenum plane, const GLfloat * equation)) +SDL_PROC(void, glColor4f, + (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) +SDL_PROC_UNUSED(void, glDepthRangef, (GLclampf zNear, GLclampf zFar)) +SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glFrustumf, + (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, + GLfloat zNear, GLfloat zFar)) +SDL_PROC_UNUSED(void, glGetClipPlanef, (GLenum pname, GLfloat eqn[4])) +SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetLightfv, + (GLenum light, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetMaterialfv, + (GLenum face, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexEnvfv, + (GLenum env, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glGetTexParameterfv, + (GLenum target, GLenum pname, GLfloat * params)) +SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glLightfv, + (GLenum light, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glLineWidth, (GLfloat width)) +SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m)) +SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glMaterialfv, + (GLenum face, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m)) +SDL_PROC_UNUSED(void, glMultiTexCoord4f, + (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)) +SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz)) +SDL_PROC(void, glOrthof, + (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, + GLfloat zNear, GLfloat zFar)) +SDL_PROC_UNUSED(void, glPointParameterf, (GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glPointParameterfv, + (GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glPointSize, (GLfloat size)) +SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units)) +SDL_PROC_UNUSED(void, glRotatef, + (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z)) +SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glTexEnvfv, + (GLenum target, GLenum pname, const GLfloat * params)) +SDL_PROC(void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param)) +SDL_PROC_UNUSED(void, glTexParameterfv, + (GLenum target, GLenum pname, const GLfloat * params)) +SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z)) + +/* Available in both Common and Common-Lite profiles */ +SDL_PROC_UNUSED(void, glActiveTexture, (GLenum texture)) +SDL_PROC_UNUSED(void, glAlphaFuncx, (GLenum func, GLclampx ref)) +SDL_PROC_UNUSED(void, glBindBuffer, (GLenum target, GLuint buffer)) +SDL_PROC(void, glBindTexture, (GLenum target, GLuint texture)) +SDL_PROC(void, glBlendFunc, (GLenum sfactor, GLenum dfactor)) +SDL_PROC_UNUSED(void, glBufferData, + (GLenum target, GLsizeiptr size, const GLvoid * data, + GLenum usage)) +SDL_PROC_UNUSED(void, glBufferSubData, + (GLenum target, GLintptr offset, GLsizeiptr size, + const GLvoid * data)) +SDL_PROC(void, glClear, (GLbitfield mask)) +SDL_PROC_UNUSED(void, glClearColorx, + (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)) +SDL_PROC_UNUSED(void, glClearDepthx, (GLclampx depth)) +SDL_PROC_UNUSED(void, glClearStencil, (GLint s)) +SDL_PROC_UNUSED(void, glClientActiveTexture, (GLenum texture)) +SDL_PROC_UNUSED(void, glClipPlanex, (GLenum plane, const GLfixed * equation)) +SDL_PROC_UNUSED(void, glColor4ub, + (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) +SDL_PROC_UNUSED(void, glColor4x, + (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)) +SDL_PROC_UNUSED(void, glColorMask, + (GLboolean red, GLboolean green, GLboolean blue, + GLboolean alpha)) +SDL_PROC(void, glColorPointer, + (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glCompressedTexImage2D, + (GLenum target, GLint level, GLenum internalformat, + GLsizei width, GLsizei height, GLint border, + GLsizei imageSize, const GLvoid * data)) +SDL_PROC_UNUSED(void, glCompressedTexSubImage2D, + (GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, + GLsizei imageSize, const GLvoid * data)) +SDL_PROC_UNUSED(void, glCopyTexImage2D, + (GLenum target, GLint level, GLenum internalformat, GLint x, + GLint y, GLsizei width, GLsizei height, GLint border)) +SDL_PROC_UNUSED(void, glCopyTexSubImage2D, + (GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height)) +SDL_PROC_UNUSED(void, glCullFace, (GLenum mode)) +SDL_PROC_UNUSED(void, glDeleteBuffers, (GLsizei n, const GLuint * buffers)) +SDL_PROC_UNUSED(void, glDeleteTextures, (GLsizei n, const GLuint * textures)) +SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func)) +SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag)) +SDL_PROC_UNUSED(void, glDepthRangex, (GLclampx zNear, GLclampx zFar)) +SDL_PROC(void, glDisable, (GLenum cap)) +SDL_PROC(void, glDisableClientState, (GLenum array)) +SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) +SDL_PROC_UNUSED(void, glDrawElements, + (GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices)) +SDL_PROC(void, glEnable, (GLenum cap)) +SDL_PROC(void, glEnableClientState, (GLenum array)) +SDL_PROC_UNUSED(void, glFinish, (void)) +SDL_PROC_UNUSED(void, glFlush, (void)) +SDL_PROC_UNUSED(void, glFogx, (GLenum pname, GLfixed param)) +SDL_PROC_UNUSED(void, glFogxv, (GLenum pname, const GLfixed * params)) +SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode)) +SDL_PROC_UNUSED(void, glFrustumx, + (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, + GLfixed zNear, GLfixed zFar)) +SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params)) +SDL_PROC_UNUSED(void, glGetBufferParameteriv, + (GLenum target, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetClipPlanex, (GLenum pname, GLfixed eqn[4])) +SDL_PROC_UNUSED(void, glGenBuffers, (GLsizei n, GLuint * buffers)) +SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures)) +SDL_PROC(GLenum, glGetError, (void)) +SDL_PROC_UNUSED(void, glGetFixedv, (GLenum pname, GLfixed * params)) +SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetLightxv, + (GLenum light, GLenum pname, GLfixed * params)) +SDL_PROC_UNUSED(void, glGetMaterialxv, + (GLenum face, GLenum pname, GLfixed * params)) +SDL_PROC_UNUSED(void, glGetPointerv, (GLenum pname, void **params)) +SDL_PROC_UNUSED(const GLubyte *, glGetString, (GLenum name)) +SDL_PROC_UNUSED(void, glGetTexEnviv, + (GLenum env, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetTexEnvxv, + (GLenum env, GLenum pname, GLfixed * params)) +SDL_PROC_UNUSED(void, glGetTexParameteriv, + (GLenum target, GLenum pname, GLint * params)) +SDL_PROC_UNUSED(void, glGetTexParameterxv, + (GLenum target, GLenum pname, GLfixed * params)) +SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode)) +SDL_PROC_UNUSED(GLboolean, glIsBuffer, (GLuint buffer)) +SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap)) +SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture)) +SDL_PROC_UNUSED(void, glLightModelx, (GLenum pname, GLfixed param)) +SDL_PROC_UNUSED(void, glLightModelxv, (GLenum pname, const GLfixed * params)) +SDL_PROC_UNUSED(void, glLightx, (GLenum light, GLenum pname, GLfixed param)) +SDL_PROC_UNUSED(void, glLightxv, + (GLenum light, GLenum pname, const GLfixed * params)) +SDL_PROC_UNUSED(void, glLineWidthx, (GLfixed width)) +SDL_PROC(void, glLoadIdentity, (void)) +SDL_PROC_UNUSED(void, glLoadMatrixx, (const GLfixed * m)) +SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode)) +SDL_PROC_UNUSED(void, glMaterialx, (GLenum face, GLenum pname, GLfixed param)) +SDL_PROC_UNUSED(void, glMaterialxv, + (GLenum face, GLenum pname, const GLfixed * params)) +SDL_PROC(void, glMatrixMode, (GLenum mode)) +SDL_PROC_UNUSED(void, glMultMatrixx, (const GLfixed * m)) +SDL_PROC_UNUSED(void, glMultiTexCoord4x, + (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)) +SDL_PROC_UNUSED(void, glNormal3x, (GLfixed nx, GLfixed ny, GLfixed nz)) +SDL_PROC_UNUSED(void, glNormalPointer, + (GLenum type, GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glOrthox, + (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, + GLfixed zNear, GLfixed zFar)) +SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glPointParameterx, (GLenum pname, GLfixed param)) +SDL_PROC_UNUSED(void, glPointParameterxv, + (GLenum pname, const GLfixed * params)) +SDL_PROC_UNUSED(void, glPointSizex, (GLfixed size)) +SDL_PROC_UNUSED(void, glPolygonOffsetx, (GLfixed factor, GLfixed units)) +SDL_PROC_UNUSED(void, glPopMatrix, (void)) +SDL_PROC_UNUSED(void, glPushMatrix, (void)) +SDL_PROC_UNUSED(void, glReadPixels, + (GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLvoid * pixels)) +SDL_PROC_UNUSED(void, glRotatex, + (GLfixed angle, GLfixed x, GLfixed y, GLfixed z)) +SDL_PROC_UNUSED(void, glSampleCoverage, (GLclampf value, GLboolean invert)) +SDL_PROC_UNUSED(void, glSampleCoveragex, (GLclampx value, GLboolean invert)) +SDL_PROC_UNUSED(void, glScalex, (GLfixed x, GLfixed y, GLfixed z)) +SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height)) +SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode)) +SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask)) +SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask)) +SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) +SDL_PROC(void, glTexCoordPointer, + (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) +SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glTexEnvx, (GLenum target, GLenum pname, GLfixed param)) +SDL_PROC_UNUSED(void, glTexEnviv, + (GLenum target, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glTexEnvxv, + (GLenum target, GLenum pname, const GLfixed * params)) +SDL_PROC(void, glTexImage2D, + (GLenum target, GLint level, GLint internalformat, GLsizei width, + GLsizei height, GLint border, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param)) +SDL_PROC_UNUSED(void, glTexParameterx, + (GLenum target, GLenum pname, GLfixed param)) +SDL_PROC(void, glTexParameteriv, + (GLenum target, GLenum pname, const GLint * params)) +SDL_PROC_UNUSED(void, glTexParameterxv, + (GLenum target, GLenum pname, const GLfixed * params)) +SDL_PROC(void, glTexSubImage2D, + (GLenum target, GLint level, GLint xoffset, GLint yoffset, + GLsizei width, GLsizei height, GLenum format, GLenum type, + const GLvoid * pixels)) +SDL_PROC_UNUSED(void, glTranslatex, (GLfixed x, GLfixed y, GLfixed z)) +SDL_PROC(void, glVertexPointer, + (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) +SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) + +/* extension functions used */ +SDL_PROC(void, glDrawTexiOES, + (GLint x, GLint y, GLint z, GLint width, GLint height)) + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c b/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c deleted file mode 120000 index 0b020c883..000000000 --- a/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c +++ /dev/null @@ -1 +0,0 @@ -../../../../sdl-1.3/src/video/SDL_renderer_gles.c \ No newline at end of file diff --git a/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c b/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c new file mode 100644 index 000000000..62d88ecf9 --- /dev/null +++ b/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.c @@ -0,0 +1,1056 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" +#include "SDL_version.h" + +#if SDL_VIDEO_RENDER_OGL_ES + +#if SDL_VERSION_ATLEAST(1,3,0) +#include "SDL_video.h" +#include "SDL_opengles.h" +#include "SDL_sysvideo.h" +#else +#include "SDL_video-1.3.h" +#include "SDL_sysvideo-1.3.h" +#endif +#include "SDL_opengles.h" +#include "SDL_pixels_c.h" +#include "SDL_rect_c.h" +#if SDL_VERSION_ATLEAST(1,3,0) +#include "SDL_yuv_sw_c.h" +#endif +#ifdef ANDROID +#include +#else +#define __android_log_print(...) +#endif + +#if defined(__QNXNTO__) +/* Include QNX system header to check QNX version later */ +#include +#endif /* __QNXNTO__ */ + +#if defined(SDL_VIDEO_DRIVER_QNXGF) || \ + defined(SDL_VIDEO_DRIVER_PHOTON) || \ + defined(SDL_VIDEO_DRIVER_PANDORA) + +/* Empty function stub to get OpenGL ES 1.x support without */ +/* OpenGL ES extension GL_OES_draw_texture supported */ +GL_API void GL_APIENTRY +glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + return; +} + +#endif /* QNXGF || PHOTON || PANDORA */ + +/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */ + +static const float inv255f = 1.0f / 255.0f; + +static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags); +static int GLES_ActivateRenderer(SDL_Renderer * renderer); +static int GLES_DisplayModeChanged(SDL_Renderer * renderer); +static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int GLES_QueryTexturePixels(SDL_Renderer * renderer, + SDL_Texture * texture, void **pixels, + int *pitch); +static int GLES_SetTexturePalette(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Color * colors, int firstcolor, + int ncolors); +static int GLES_GetTexturePalette(SDL_Renderer * renderer, + SDL_Texture * texture, SDL_Color * colors, + int firstcolor, int ncolors); +static int GLES_SetTextureColorMod(SDL_Renderer * renderer, + SDL_Texture * texture); +static int GLES_SetTextureAlphaMod(SDL_Renderer * renderer, + SDL_Texture * texture); +static int GLES_SetTextureBlendMode(SDL_Renderer * renderer, + SDL_Texture * texture); +static int GLES_SetTextureScaleMode(SDL_Renderer * renderer, + SDL_Texture * texture); +static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, int markDirty, + void **pixels, int *pitch); +static void GLES_UnlockTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, + int numrects, const SDL_Rect * rects); +static int GLES_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, int count); +static int GLES_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, int count); +static int GLES_RenderDrawRects(SDL_Renderer * renderer, + const SDL_Rect ** rects, int count); +static int GLES_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect ** rects, int count); +static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect); +static void GLES_RenderPresent(SDL_Renderer * renderer); +static void GLES_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static void GLES_DestroyRenderer(SDL_Renderer * renderer); + + +SDL_RenderDriver GL_ES_RenderDriver = { + GLES_CreateRenderer, + { + "opengl_es", + (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD | + SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), + (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | + SDL_TEXTUREMODULATE_ALPHA), + (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | + SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), + (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), 5, + { + /* OpenGL ES 1.x supported formats list */ + SDL_PIXELFORMAT_RGBA4444, + SDL_PIXELFORMAT_RGBA5551, + SDL_PIXELFORMAT_RGB565, + SDL_PIXELFORMAT_RGB24, + SDL_PIXELFORMAT_RGBA8888}, + 0, + 0} +}; + +typedef struct +{ + SDL_GLContext context; + SDL_bool updateSize; + int blendMode; + +#ifndef APIENTRY +#define APIENTRY +#endif + + SDL_bool useDrawTexture; + SDL_bool GL_OES_draw_texture_supported; + + /* OpenGL ES functions */ +#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#include "SDL_glesfuncs.h" +#undef SDL_PROC + +} GLES_RenderData; + +typedef struct +{ + GLuint texture; + GLenum type; + GLfloat texw; + GLfloat texh; + GLenum format; + GLenum formattype; + void *pixels; + int pitch; + SDL_DirtyRectList dirty; +} GLES_TextureData; + +static void +GLES_SetError(const char *prefix, GLenum result) +{ + const char *error; + + switch (result) { + case GL_NO_ERROR: + error = "GL_NO_ERROR"; + break; + case GL_INVALID_ENUM: + error = "GL_INVALID_ENUM"; + break; + case GL_INVALID_VALUE: + error = "GL_INVALID_VALUE"; + break; + case GL_INVALID_OPERATION: + error = "GL_INVALID_OPERATION"; + break; + case GL_STACK_OVERFLOW: + error = "GL_STACK_OVERFLOW"; + break; + case GL_STACK_UNDERFLOW: + error = "GL_STACK_UNDERFLOW"; + break; + case GL_OUT_OF_MEMORY: + error = "GL_OUT_OF_MEMORY"; + break; + default: + error = "UNKNOWN"; + break; + } + SDL_SetError("%s: %s", prefix, error); +} + +static int +GLES_LoadFunctions(GLES_RenderData * data) +{ + +#define SDL_PROC(ret,func,params) \ + data->func = func; +#include "SDL_glesfuncs.h" +#undef SDL_PROC + + return 0; +} + +SDL_Renderer * +GLES_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + + SDL_Renderer *renderer; + GLES_RenderData *data; + GLint value; + int doublebuffer; + +#if SDL_VERSION_ATLEAST(1,3,0) + if (!(window->flags & SDL_WINDOW_OPENGL)) { + if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) { + return NULL; + } + } +#endif + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + GLES_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + + renderer->ActivateRenderer = GLES_ActivateRenderer; + renderer->DisplayModeChanged = GLES_DisplayModeChanged; + renderer->CreateTexture = GLES_CreateTexture; + renderer->QueryTexturePixels = GLES_QueryTexturePixels; + renderer->SetTexturePalette = GLES_SetTexturePalette; + renderer->GetTexturePalette = GLES_GetTexturePalette; + renderer->SetTextureColorMod = GLES_SetTextureColorMod; + renderer->SetTextureAlphaMod = GLES_SetTextureAlphaMod; + renderer->SetTextureBlendMode = GLES_SetTextureBlendMode; + renderer->SetTextureScaleMode = GLES_SetTextureScaleMode; + renderer->UpdateTexture = GLES_UpdateTexture; + renderer->LockTexture = GLES_LockTexture; + renderer->UnlockTexture = GLES_UnlockTexture; + renderer->DirtyTexture = GLES_DirtyTexture; + renderer->RenderDrawPoints = GLES_RenderDrawPoints; + renderer->RenderDrawLines = GLES_RenderDrawLines; + renderer->RenderDrawRects = GLES_RenderDrawRects; + renderer->RenderFillRects = GLES_RenderFillRects; + renderer->RenderCopy = GLES_RenderCopy; + renderer->RenderPresent = GLES_RenderPresent; + renderer->DestroyTexture = GLES_DestroyTexture; + renderer->DestroyRenderer = GLES_DestroyRenderer; + renderer->info = GL_ES_RenderDriver.info; + renderer->window = window; + renderer->driverdata = data; + + renderer->info.flags = + (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED); + +#if defined(__QNXNTO__) +#if _NTO_VERSION<=641 + /* QNX's OpenGL ES implementation is broken regarding */ + /* packed textures support, affected versions 6.3.2, 6.4.0, 6.4.1 */ + renderer->info.num_texture_formats = 2; + renderer->info.texture_formats[0] = SDL_PIXELFORMAT_ABGR8888; + renderer->info.texture_formats[1] = SDL_PIXELFORMAT_BGR24; +#endif /* _NTO_VERSION */ +#endif /* __QNXNTO__ */ + + if (GLES_LoadFunctions(data) < 0) { + GLES_DestroyRenderer(renderer); + return NULL; + } + + data->context = SDL_GL_CreateContext(window); + if (!data->context) { + GLES_DestroyRenderer(renderer); + return NULL; + } + if (SDL_GL_MakeCurrent(window, data->context) < 0) { + GLES_DestroyRenderer(renderer); + return NULL; + } + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + if (SDL_GL_GetSwapInterval() > 0) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + +#if SDL_VERSION_ATLEAST(1,3,0) + // Always double-buffered +#else + if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) { + if (!doublebuffer) { + renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER; + } + } +#endif +#if SDL_VIDEO_DRIVER_PANDORA + data->GL_OES_draw_texture_supported = SDL_FALSE; + data->useDrawTexture = SDL_FALSE; +#else + if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) { + data->GL_OES_draw_texture_supported = SDL_TRUE; + data->useDrawTexture = SDL_TRUE; + } else { + data->GL_OES_draw_texture_supported = SDL_FALSE; + data->useDrawTexture = SDL_FALSE; + } +#ifdef ANDROID + data->GL_OES_draw_texture_supported = SDL_TRUE; + data->useDrawTexture = SDL_TRUE; +#endif +#endif + + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_height = value; + + /* Set up parameters for rendering */ + data->blendMode = -1; + data->glDisable(GL_DEPTH_TEST); + data->glDisable(GL_CULL_FACE); + data->updateSize = SDL_TRUE; + + return renderer; +} + +static int +GLES_ActivateRenderer(SDL_Renderer * renderer) +{ + + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + SDL_Window *window = renderer->window; + + if (SDL_GL_MakeCurrent(window, data->context) < 0) { + return -1; + } + + /* Set up parameters for rendering */ + data->blendMode = -1; + data->glDisable(GL_DEPTH_TEST); + data->glDisable(GL_CULL_FACE); + data->updateSize = SDL_TRUE; + + if (data->updateSize) { + data->glMatrixMode(GL_PROJECTION); + data->glLoadIdentity(); + data->glMatrixMode(GL_MODELVIEW); + data->glLoadIdentity(); +#if SDL_VIDEO_RENDER_RESIZE + data->glViewport(0, 0, window->display->desktop_mode.w, window->display->desktop_mode.h); + data->glOrthof(0.0, (GLfloat) window->display->desktop_mode.w, (GLfloat) window->display->desktop_mode.h, + 0.0, 0.0, 1.0); +#else + data->glViewport(0, 0, window->w, window->h); + data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, + 0.0, 0.0, 1.0); +#endif + data->updateSize = SDL_FALSE; + } + return 0; +} + +static int +GLES_DisplayModeChanged(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + data->updateSize = SDL_TRUE; + return 0; +} + +static __inline__ int +power_of_2(int input) +{ + int value = 1; + + while (value < input) { + value <<= 1; + } + return value; +} + +static int +GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *data; + GLint internalFormat; + GLenum format, type; + int texture_w, texture_h; + GLenum result; + + switch (texture->format) { + case SDL_PIXELFORMAT_RGB24: + internalFormat = GL_RGB; + format = GL_RGB; + type = GL_UNSIGNED_BYTE; + break; + case SDL_PIXELFORMAT_BGR888: + case SDL_PIXELFORMAT_ABGR8888: + case SDL_PIXELFORMAT_RGBA8888: + internalFormat = GL_RGBA; + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + break; + case SDL_PIXELFORMAT_RGB565: + internalFormat = GL_RGB; + format = GL_RGB; + type = GL_UNSIGNED_SHORT_5_6_5; + break; + case SDL_PIXELFORMAT_RGBA5551: + internalFormat = GL_RGBA; + format = GL_RGBA; + type = GL_UNSIGNED_SHORT_5_5_5_1; + break; + case SDL_PIXELFORMAT_RGBA4444: + internalFormat = GL_RGBA; + format = GL_RGBA; + type = GL_UNSIGNED_SHORT_4_4_4_4; + break; + default: + SDL_SetError("Texture format %s not supported by OpenGL ES", + SDL_GetPixelFormatName(texture->format)); + return -1; + } + + data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_OutOfMemory(); + return -1; + } + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) + { + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + data->pixels = SDL_malloc(texture->h * data->pitch); + if (!data->pixels) { + SDL_OutOfMemory(); + SDL_free(data); + return -1; + } + } + + texture->driverdata = data; + + renderdata->glGetError(); + renderdata->glEnable(GL_TEXTURE_2D); + renderdata->glGenTextures(1, &data->texture); + + data->type = GL_TEXTURE_2D; + /* no NPOV textures allowed in OpenGL ES (yet) */ + texture_w = power_of_2(texture->w); + texture_h = power_of_2(texture->h); + data->texw = (GLfloat) texture->w / texture_w; + data->texh = (GLfloat) texture->h / texture_h; + if( renderer->info.max_texture_width < texture_w || renderer->info.max_texture_height < texture_h ) + __android_log_print(ANDROID_LOG_WARN, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than largest possible device texture %dx%d", + texture_w, texture_h, renderer->info.max_texture_width, renderer->info.max_texture_height ); + else if( texture_w > 1024 || texture_h > 1024 ) + __android_log_print(ANDROID_LOG_WARN, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than 1024x1024 - this code will not work on HTC G1", texture_w, texture_h ); + + data->format = format; + data->formattype = type; + renderdata->glBindTexture(data->type, data->texture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, + GL_NEAREST); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, + GL_NEAREST); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + + renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, + texture_h, 0, format, type, NULL); + renderdata->glDisable(GL_TEXTURE_2D); + + result = renderdata->glGetError(); + if (result != GL_NO_ERROR) { + GLES_SetError("glTexImage2D()", result); + return -1; + } + return 0; +} + +static int +GLES_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, + void **pixels, int *pitch) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + + *pixels = data->pixels; + *pitch = data->pitch; + return 0; +} + +static int +GLES_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Color * colors, int firstcolor, int ncolors) +{ + SDL_SetError("OpenGL ES does not support paletted textures"); + return -1; +} + +static int +GLES_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, + SDL_Color * colors, int firstcolor, int ncolors) +{ + SDL_SetError("OpenGL ES does not support paletted textures"); + return -1; +} + +static void +SetupTextureUpdate(GLES_RenderData * renderdata, SDL_Texture * texture, + int pitch) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + renderdata->glBindTexture(data->type, data->texture); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); +} + +static int +GLES_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) +{ + return 0; +} + +static int +GLES_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) +{ + return 0; +} + +static int +GLES_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) +{ + switch (texture->blendMode) { + case SDL_BLENDMODE_NONE: + case SDL_BLENDMODE_MASK: + case SDL_BLENDMODE_BLEND: + case SDL_BLENDMODE_ADD: + case SDL_BLENDMODE_MOD: + return 0; + default: + SDL_Unsupported(); + texture->blendMode = SDL_BLENDMODE_NONE; + return -1; + } +} + +static int +GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) +{ + switch (texture->scaleMode) { + case SDL_SCALEMODE_NONE: + case SDL_SCALEMODE_FAST: + case SDL_SCALEMODE_SLOW: + return 0; + case SDL_SCALEMODE_BEST: + SDL_Unsupported(); + texture->scaleMode = SDL_SCALEMODE_SLOW; + return -1; + default: + SDL_Unsupported(); + texture->scaleMode = SDL_SCALEMODE_NONE; + return -1; + } +} + +static int +GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + GLenum result; + int bpp = SDL_BYTESPERPIXEL(texture->format); + void * temp_buffer; + void * temp_ptr; + int i; + + renderdata->glGetError(); + renderdata->glEnable(data->type); + SetupTextureUpdate(renderdata, texture, pitch); + + if( rect->w * bpp == pitch ) { + temp_buffer = (void *)pixels; /* No need to reformat */ + } else { + /* Reformatting of mem area required */ + temp_buffer = SDL_malloc(rect->w * rect->h * bpp); + temp_ptr = temp_buffer; + for (i = 0; i < rect->h; i++) { + SDL_memcpy(temp_ptr, pixels, rect->w * bpp); + temp_ptr += rect->w * bpp; + pixels += pitch; + } + } + + renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, + rect->h, data->format, data->formattype, + temp_buffer); + + if( temp_buffer != pixels ) { + SDL_free(temp_buffer); + } + + renderdata->glDisable(data->type); + result = renderdata->glGetError(); + if (result != GL_NO_ERROR) { + GLES_SetError("glTexSubImage2D()", result); + return -1; + } + return 0; +} + +static int +GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, int markDirty, void **pixels, + int *pitch) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + + if (markDirty) { + SDL_AddDirtyRect(&data->dirty, rect); + } + + *pixels = + (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = data->pitch; + return 0; +} + +static void +GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ +} + +static void +GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, + int numrects, const SDL_Rect * rects) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + int i; + + for (i = 0; i < numrects; ++i) { + SDL_AddDirtyRect(&data->dirty, &rects[i]); + } +} + +static void +GLES_SetBlendMode(GLES_RenderData * data, int blendMode, int isprimitive) +{ + if (blendMode != data->blendMode) { + switch (blendMode) { + case SDL_BLENDMODE_NONE: + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + data->glDisable(GL_BLEND); + break; + case SDL_BLENDMODE_MASK: + if (isprimitive) { + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + data->glDisable(GL_BLEND); + /* The same as SDL_BLENDMODE_NONE */ + blendMode = SDL_BLENDMODE_NONE; + break; + } + /* fall through */ + case SDL_BLENDMODE_BLEND: + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + data->glEnable(GL_BLEND); + data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + case SDL_BLENDMODE_ADD: + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + data->glEnable(GL_BLEND); + data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); + break; + case SDL_BLENDMODE_MOD: + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + data->glEnable(GL_BLEND); + data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); + break; + } + data->blendMode = blendMode; + } +} + +static int +GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, + int count) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + int i; + GLshort *vertices; + + GLES_SetBlendMode(data, renderer->blendMode, 1); + + data->glColor4f((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + vertices = SDL_stack_alloc(GLshort, count*2); + for (i = 0; i < count; ++i) { + vertices[2*i+0] = (GLshort)points[i].x; + vertices[2*i+1] = (GLshort)points[i].y; + } + data->glVertexPointer(2, GL_SHORT, 0, vertices); + data->glEnableClientState(GL_VERTEX_ARRAY); + data->glDrawArrays(GL_POINTS, 0, count); + data->glDisableClientState(GL_VERTEX_ARRAY); + SDL_stack_free(vertices); + + return 0; +} + +static int +GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, + int count) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + int i; + GLshort *vertices; + + GLES_SetBlendMode(data, renderer->blendMode, 1); + + data->glColor4f((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + vertices = SDL_stack_alloc(GLshort, count*2); + for (i = 0; i < count; ++i) { + vertices[2*i+0] = (GLshort)points[i].x; + vertices[2*i+1] = (GLshort)points[i].y; + } + data->glVertexPointer(2, GL_SHORT, 0, vertices); + data->glEnableClientState(GL_VERTEX_ARRAY); + if (count > 2 && + points[0].x == points[count-1].x && points[0].y == points[count-1].y) { + /* GL_LINE_LOOP takes care of the final segment */ + --count; + data->glDrawArrays(GL_LINE_LOOP, 0, count); + } else { + data->glDrawArrays(GL_LINE_STRIP, 0, count); + } + data->glDisableClientState(GL_VERTEX_ARRAY); + SDL_stack_free(vertices); + + return 0; +} + +static int +GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, + int count) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + int i; + + GLES_SetBlendMode(data, renderer->blendMode, 1); + + data->glColor4f((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + data->glEnableClientState(GL_VERTEX_ARRAY); + for (i = 0; i < count; ++i) { + const SDL_Rect *rect = rects[i]; + GLshort minx = rect->x; + GLshort maxx = rect->x + rect->w; + GLshort miny = rect->y; + GLshort maxy = rect->y + rect->h; + GLshort vertices[8]; + vertices[0] = minx; + vertices[1] = miny; + vertices[2] = maxx; + vertices[3] = miny; + vertices[4] = minx; + vertices[5] = maxy; + vertices[6] = maxx; + vertices[7] = maxy; + + data->glVertexPointer(2, GL_SHORT, 0, vertices); + data->glDrawArrays(GL_LINE_LOOP, 0, 4); + } + data->glDisableClientState(GL_VERTEX_ARRAY); + + return 0; +} + +static int +GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, + int count) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + int i; + + GLES_SetBlendMode(data, renderer->blendMode, 1); + + data->glColor4f((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + data->glEnableClientState(GL_VERTEX_ARRAY); + for (i = 0; i < count; ++i) { + const SDL_Rect *rect = rects[i]; + GLshort minx = rect->x; + GLshort maxx = rect->x + rect->w; + GLshort miny = rect->y; + GLshort maxy = rect->y + rect->h; + GLshort vertices[8]; + vertices[0] = minx; + vertices[1] = miny; + vertices[2] = maxx; + vertices[3] = miny; + vertices[4] = minx; + vertices[5] = maxy; + vertices[6] = maxx; + vertices[7] = maxy; + + data->glVertexPointer(2, GL_SHORT, 0, vertices); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + data->glDisableClientState(GL_VERTEX_ARRAY); + + return 0; +} + +static int +GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect) +{ + + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + int minx, miny, maxx, maxy; + GLfloat minu, maxu, minv, maxv; + int i; + void *temp_buffer; /* used for reformatting dirty rect pixels */ + void *temp_ptr; + + data->glEnable(GL_TEXTURE_2D); + + if (texturedata->dirty.list) { + SDL_DirtyRect *dirty; + void *pixels; + int bpp = SDL_BYTESPERPIXEL(texture->format); + int pitch = texturedata->pitch; + + SetupTextureUpdate(data, texture, pitch); + + data->glBindTexture(texturedata->type, texturedata->texture); + for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) { + SDL_Rect *rect = &dirty->rect; + pixels = + (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch + + rect->x * bpp); + /* There is no GL_UNPACK_ROW_LENGTH in OpenGLES + we must do this reformatting ourselves(!) + + maybe it'd be a good idea to keep a temp buffer around + for this purpose rather than allocating it each time + */ + if( rect->x == 0 && rect->w * bpp == pitch ) { + temp_buffer = pixels; /* Updating whole texture, no need to reformat */ + } else { + temp_buffer = SDL_malloc(rect->w * rect->h * bpp); + temp_ptr = temp_buffer; + for (i = 0; i < rect->h; i++) { + SDL_memcpy(temp_ptr, pixels, rect->w * bpp); + temp_ptr += rect->w * bpp; + pixels += pitch; + } + } + + data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, + rect->w, rect->h, texturedata->format, + texturedata->formattype, temp_buffer); + + if( temp_buffer != pixels ) { + SDL_free(temp_buffer); + } + } + SDL_ClearDirtyRects(&texturedata->dirty); + } + + data->glBindTexture(texturedata->type, texturedata->texture); + + if (texture->modMode) { + data->glColor4f((GLfloat) texture->r * inv255f, + (GLfloat) texture->g * inv255f, + (GLfloat) texture->b * inv255f, + (GLfloat) texture->a * inv255f); + } else { + data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + } + + GLES_SetBlendMode(data, texture->blendMode, 0); + + switch (texture->scaleMode) { + case SDL_SCALEMODE_NONE: + case SDL_SCALEMODE_FAST: + data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, + GL_NEAREST); + data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, + GL_NEAREST); + break; + case SDL_SCALEMODE_SLOW: + case SDL_SCALEMODE_BEST: + data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, + GL_LINEAR); + data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, + GL_LINEAR); + break; + } + + if (data->GL_OES_draw_texture_supported && data->useDrawTexture) { + /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */ + SDL_Window *window = renderer->window; + GLint cropRect[4]; + cropRect[0] = srcrect->x; + cropRect[1] = srcrect->y + srcrect->h; + cropRect[2] = srcrect->w; + cropRect[3] = -srcrect->h; + data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, + cropRect); + //__android_log_print(ANDROID_LOG_INFO, "libSDL", "GLES_RenderCopy glDrawTexiOES(%d, %d, %d, %d) cropRect %d:%d:%d:%d", dstrect->x, window->display->desktop_mode.h - dstrect->y - dstrect->h, dstrect->w, dstrect->h, cropRect[0], cropRect[1], cropRect[2], cropRect[3]); + data->glDrawTexiOES(dstrect->x, +#if SDL_VIDEO_RENDER_RESIZE + window->display->desktop_mode.h - dstrect->y - dstrect->h, +#else + window->h - dstrect->y - dstrect->h, +#endif + 0, dstrect->w, dstrect->h); + } else { + + minx = dstrect->x; + miny = dstrect->y; + maxx = dstrect->x + dstrect->w; + maxy = dstrect->y + dstrect->h; + + minu = (GLfloat) srcrect->x / texture->w; + minu *= texturedata->texw; + maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; + maxu *= texturedata->texw; + minv = (GLfloat) srcrect->y / texture->h; + minv *= texturedata->texh; + maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; + maxv *= texturedata->texh; + + GLshort vertices[8]; + GLfloat texCoords[8]; + + vertices[0] = minx; + vertices[1] = miny; + vertices[2] = maxx; + vertices[3] = miny; + vertices[4] = minx; + vertices[5] = maxy; + vertices[6] = maxx; + vertices[7] = maxy; + + texCoords[0] = minu; + texCoords[1] = minv; + texCoords[2] = maxu; + texCoords[3] = minv; + texCoords[4] = minu; + texCoords[5] = maxv; + texCoords[6] = maxu; + texCoords[7] = maxv; + + data->glVertexPointer(2, GL_SHORT, 0, vertices); + data->glEnableClientState(GL_VERTEX_ARRAY); + data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords); + data->glEnableClientState(GL_TEXTURE_COORD_ARRAY); + data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + data->glDisableClientState(GL_TEXTURE_COORD_ARRAY); + data->glDisableClientState(GL_VERTEX_ARRAY); + } + + data->glDisable(GL_TEXTURE_2D); + + return 0; +} + +static void +GLES_RenderPresent(SDL_Renderer * renderer) +{ + SDL_GL_SwapWindow(renderer->window); +} + +static void +GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + + if (!data) { + return; + } + if (data->texture) { + glDeleteTextures(1, &data->texture); + } + if (data->pixels) { + SDL_free(data->pixels); + } + SDL_FreeDirtyRects(&data->dirty); + SDL_free(data); + texture->driverdata = NULL; +} + +static void +GLES_DestroyRenderer(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (data) { + if (data->context) { + SDL_GL_DeleteContext(data->context); + } + SDL_free(data); + } + SDL_free(renderer); +} + +#endif /* SDL_VIDEO_RENDER_OGL_ES */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.h b/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.h deleted file mode 120000 index cdce4bd68..000000000 --- a/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.h +++ /dev/null @@ -1 +0,0 @@ -../../../../sdl-1.3/src/video/SDL_renderer_gles.h \ No newline at end of file diff --git a/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.h b/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.h new file mode 100644 index 000000000..f86328d4e --- /dev/null +++ b/project/jni/sdl-1.2/src/video/android/SDL_renderer_gles.h @@ -0,0 +1,28 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2010 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +/* OpenGL renderer implementation */ + +extern SDL_RenderDriver GL_ES_RenderDriver; + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.2/src/video/android/SDL_sysvideo-1.3.h b/project/jni/sdl-1.2/src/video/android/SDL_sysvideo-1.3.h index ba89f3e84..8182cb487 100644 --- a/project/jni/sdl-1.2/src/video/android/SDL_sysvideo-1.3.h +++ b/project/jni/sdl-1.2/src/video/android/SDL_sysvideo-1.3.h @@ -25,8 +25,12 @@ #define _SDL_sysvideo_1_3_h #include "SDL_mouse.h" -#include "SDL_keysym.h" #include "SDL_rect.h" +#if SDL_VERSION_ATLEAST(1,3,0) +#include "SDL_keycode.h" +#else +#include "SDL_keysym.h" +#endif /* The SDL video driver */ diff --git a/project/jni/sdl-1.3/Android.mk b/project/jni/sdl-1.3/Android.mk index b32c0e2e5..4db07c53f 100644 --- a/project/jni/sdl-1.3/Android.mk +++ b/project/jni/sdl-1.3/Android.mk @@ -9,7 +9,7 @@ $(error Please define SDL_JAVA_PACKAGE_PATH to the path of your Java package wit endif LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_CFLAGS := -O3 \ +LOCAL_CFLAGS := -O3 -D__ANDROID__ -DANDROID \ -DSDL_JAVA_PACKAGE_PATH=$(SDL_JAVA_PACKAGE_PATH) \ -DSDL_CURDIR_PATH=\"$(SDL_CURDIR_PATH)\" \ -DSDL_TRACKBALL_KEYUP_DELAY=$(SDL_TRACKBALL_KEYUP_DELAY) \ @@ -38,10 +38,13 @@ SDL_SRCS := \ src/audio/android/*.c \ src/cdrom/dummy/*.c \ src/video/android/*.c \ - src/video/android/*.cpp \ src/haptic/dummy/*.c \ src/loadso/dlopen/*.c \ - src/atomic/dummy/*.c \ + src/atomic/*.c \ + src/render/*.c \ + src/render/opengles/*.c \ + src/render/software/*.c + # TODO: use libcutils for atomic operations, but it's not included in NDK diff --git a/project/jni/sdl-1.3/README.BeOS b/project/jni/sdl-1.3/README.BeOS new file mode 100644 index 000000000..ccdccf598 --- /dev/null +++ b/project/jni/sdl-1.3/README.BeOS @@ -0,0 +1,13 @@ + +SDL on BeOS R5 +============== + +You can build SDL on BeOS like any other GNU style package. +e.g. ./configure && make && make install +By default it is installed in /boot/develop/tools/gnupro/{bin,lib,etc.} + +Once you install SDL, you need to copy libSDL.so to /boot/home/config/lib, +so it can be found by the dynamic linker. + +Enjoy! + Sam Lantinga (slouken@libsdl.org) diff --git a/project/jni/sdl-1.3/README.DirectFB b/project/jni/sdl-1.3/README.DirectFB new file mode 100644 index 000000000..68988136b --- /dev/null +++ b/project/jni/sdl-1.3/README.DirectFB @@ -0,0 +1,106 @@ +SDL on DirectFB + +Supports: + +- Hardware YUV overlays +- OpenGL - software only +- 2D/3D accelerations (depends on directfb driver) +- multiple displays +- windows + +What you need: + +DirectFB 1.0.1, 1.2.x, 1.3.0 +Kernel-Framebuffer support: required: vesafb, radeonfb .... +Mesa 7.0.x - optional for OpenGL + +/etc/directfbrc + +This file should contain the following lines to make +your joystick work and avoid crashes: +------------------------ +disable-module=joystick +disable-module=cle266 +disable-module=cyber5k +no-linux-input-grab +------------------------ + +To disable to use x11 backend when DISPLAY variable is found use + +export SDL_DIRECTFB_X11_CHECK=0 + +To disable the use of linux input devices, i.e. multimice/multikeyboard support, +use + +export SDL_DIRECTFB_LINUX_INPUT=0 + +To use hardware accelerated YUV-overlays for YUV-textures, use: + +export SDL_DIRECTFB_YUV_DIRECT=1 + +This is disabled by default. It will only support one +YUV texture, namely the first. Every other YUV texture will be +rendered in software. + +In addition, you may use (directfb-1.2.x) + +export SDL_DIRECTFB_YUV_UNDERLAY=1 + +to make the YUV texture an underlay. This will make the cursor to +be shown. + +Simple Window Manager +===================== + +The driver has support for a very, very basic window manager you may +want to use when runnning with "wm=default". Use + +export SDL_DIRECTFB_WM=1 + +to enable basic window borders. In order to have the window title rendered, +you need to have the following font installed: + +/usr/share/fonts/truetype/freefont/FreeSans.ttf + +OPENGL Support +============== + +The following instructions will give you *software* opengl. However this +works at least on all directfb supported platforms. + +As of this writing 20100802 you need to pull Mesa from git and do the following: + +------------------------ +git clone git://anongit.freedesktop.org/git/mesa/mesa +cd mesa +git checkout 2c9fdaf7292423c157fc79b5ce43f0f199dd753a +------------------------ + +Edit configs/linux-directfb so that the Directories-section looks like +------------------------ +# Directories +SRC_DIRS = mesa glu +GLU_DIRS = sgi +DRIVER_DIRS = directfb +PROGRAM_DIRS = +------------------------ + +make linux-directfb +make + +echo Installing - please enter sudo pw. + +sudo make install INSTALL_DIR=/usr/local/dfb_GL +cd src/mesa/drivers/directfb +make +sudo make install INSTALL_DIR=/usr/local/dfb_GL +------------------------ + +To run the SDL - testprograms: + +export SDL_VIDEODRIVER=directfb +export LD_LIBRARY_PATH=/usr/local/dfb_GL/lib +export LD_PRELOAD=/usr/local/dfb_GL/libGL.so.7 + +./testgl + diff --git a/project/jni/sdl-1.3/README.HG b/project/jni/sdl-1.3/README.HG index a69f5e39e..616307c6c 100644 --- a/project/jni/sdl-1.3/README.HG +++ b/project/jni/sdl-1.3/README.HG @@ -1,4 +1,3 @@ - The latest development version of SDL is available via Mercurial. Mercurial allows you to get up-to-the-minute fixes and enhancements; as a developer works on a source tree, you can use "hg" to mirror that @@ -16,6 +15,7 @@ If you are building SDL via configure, you will need to run autogen.sh before running configure. There is a web interface to the subversion repository at: + http://hg.libsdl.org/SDL/ There is an RSS feed available at that URL, for those that want to diff --git a/project/jni/sdl-1.3/README.MacOSX b/project/jni/sdl-1.3/README.MacOSX new file mode 100644 index 000000000..3bc421371 --- /dev/null +++ b/project/jni/sdl-1.3/README.MacOSX @@ -0,0 +1,186 @@ +============================================================================== +Using the Simple DirectMedia Layer with Mac OS X +============================================================================== + +These instructions are for people using Apple's Mac OS X (pronounced +"ten"). + +From the developer's point of view, OS X is a sort of hybrid Mac and +Unix system, and you have the option of using either traditional +command line tools or Apple's IDE Xcode. + +To build SDL using the command line, use the standard configure and make +process: + + ./configure + make + sudo make install + +You can also build SDL as a Universal library (a single binary for both +PowerPC and Intel architectures), on Mac OS X 10.4 and newer, by using +the fatbuild.sh script in build-scripts: + sh build-scripts/fatbuild.sh + sudo build-scripts/fatbuild.sh install +This script builds SDL with 10.2 ABI compatibility on PowerPC and 10.4 +ABI compatibility on Intel architectures. For best compatibility you +should compile your application the same way. A script which wraps +gcc to make this easy is provided in test/gcc-fat.sh + +To use the library once it's built, you essential have two possibilities: +use the traditional autoconf/automake/make method, or use Xcode. + +============================================================================== +Using the Simple DirectMedia Layer with a traditional Makefile +============================================================================== + +An existing autoconf/automake build system for your SDL app has good chances +to work almost unchanged on OS X. However, to produce a "real" Mac OS X binary +that you can distribute to users, you need to put the generated binary into a +so called "bundle", which basically is a fancy folder with a name like +"MyCoolGame.app". + +To get this build automatically, add something like the following rule to +your Makefile.am: + +bundle_contents = APP_NAME.app/Contents +APP_NAME_bundle: EXE_NAME + mkdir -p $(bundle_contents)/MacOS + mkdir -p $(bundle_contents)/Resources + echo "APPL????" > $(bundle_contents)/PkgInfo + $(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/ + +You should replace EXE_NAME with the name of the executable. APP_NAME is what +will be visible to the user in the Finder. Usually it will be the same +as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME +usually is "TestGame". You might also want to use @PACKAGE@ to use the package +name as specified in your configure.in file. + +If your project builds more than one application, you will have to do a bit +more. For each of your target applications, you need a seperate rule. + +If you want the created bundles to be installed, you may want to add this +rule to your Makefile.am: + +install-exec-hook: APP_NAME_bundle + rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app + mkdir -p $(DESTDIR)$(prefix)/Applications/ + cp -r $< /$(DESTDIR)$(prefix)Applications/ + +This rule takes the Bundle created by the rule from step 3 and installs them +into $(DESTDIR)$(prefix)/Applications/. + +Again, if you want to install multiple applications, you will have to augment +the make rule accordingly. + + +But beware! That is only part of the story! With the above, you end up with +a bare bone .app bundle, which is double clickable from the Finder. But +there are some more things you should do before shipping yor product... + +1) The bundle right now probably is dynamically linked against SDL. That + means that when you copy it to another computer, *it will not run*, + unless you also install SDL on that other computer. A good solution + for this dilemma is to static link against SDL. On OS X, you can + achieve that by linkinag against the libraries listed by + sdl-config --static-libs + instead of those listed by + sdl-config --libs + Depending on how exactly SDL is integrated into your build systems, the + way to achieve that varies, so I won't describe it here in detail +2) Add an 'Info.plist' to your application. That is a special XML file which + contains some meta-information about your application (like some copyright + information, the version of your app, the name of an optional icon file, + and other things). Part of that information is displayed by the Finder + when you click on the .app, or if you look at the "Get Info" window. + More information about Info.plist files can be found on Apple's homepage. + + +As a final remark, let me add that I use some of the techniques (and some +variations of them) in Exult and ScummVM; both are available in source on +the net, so feel free to take a peek at them for inspiration! + + +============================================================================== +Using the Simple DirectMedia Layer with Xcode +============================================================================== + +These instructions are for using Apple's Xcode IDE to build SDL applications. + +- First steps + +The first thing to do is to unpack the Xcode.tar.gz archive in the +top level SDL directory (where the Xcode.tar.gz archive resides). +Because Stuffit Expander will unpack the archive into a subdirectory, +you should unpack the archive manually from the command line: + cd [path_to_SDL_source] + tar zxf Xcode.tar.gz +This will create a new folder called Xcode, which you can browse +normally from the Finder. + +- Building the Framework + +The SDL Library is packaged as a framework bundle, an organized +relocatable folder heirarchy of executible code, interface headers, +and additional resources. For practical purposes, you can think of a +framework as a more user and system-friendly shared library, whose library +file behaves more or less like a standard UNIX shared library. + +To build the framework, simply open the framework project and build it. +By default, the framework bundle "SDL.framework" is installed in +/Library/Frameworks. Therefore, the testers and project stationary expect +it to be located there. However, it will function the same in any of the +following locations: + + ~/Library/Frameworks + /Local/Library/Frameworks + /System/Library/Frameworks + +- Build Options + There are two "Build Styles" (See the "Targets" tab) for SDL. + "Deployment" should be used if you aren't tweaking the SDL library. + "Development" should be used to debug SDL apps or the library itself. + +- Building the Testers + Open the SDLTest project and build away! + +- Using the Project Stationary + Copy the stationary to the indicated folders to access it from + the "New Project" and "Add target" menus. What could be easier? + +- Setting up a new project by hand + Some of you won't want to use the Stationary so I'll give some tips: + * Create a new "Cocoa Application" + * Add src/main/macosx/SDLMain.m , .h and .nib to your project + * Remove "main.c" from your project + * Remove "MainMenu.nib" from your project + * Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path + * Add "$(HOME)/Library/Frameworks" to the frameworks search path + * Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS" + * Set the "Main Nib File" under "Application Settings" to "SDLMain.nib" + * Add your files + * Clean and build + +- Building from command line + Use pbxbuild in the same directory as your .pbproj file + +- Running your app + You can send command line args to your app by either invoking it from + the command line (in *.app/Contents/MacOS) or by entering them in the + "Executibles" panel of the target settings. + +- Implementation Notes + Some things that may be of interest about how it all works... + * Working directory + As defined in the SDL_main.m file, the working directory of your SDL app + is by default set to its parent. You may wish to change this to better + suit your needs. + * You have a Cocoa App! + Your SDL app is essentially a Cocoa application. When your app + starts up and the libraries finish loading, a Cocoa procedure is called, + which sets up the working directory and calls your main() method. + You are free to modify your Cocoa app with generally no consequence + to SDL. You cannot, however, easily change the SDL window itself. + Functionality may be added in the future to help this. + + +Known bugs are listed in the file "BUGS" diff --git a/project/jni/sdl-1.3/README.Platforms b/project/jni/sdl-1.3/README.Platforms new file mode 100644 index 000000000..a766e0e30 --- /dev/null +++ b/project/jni/sdl-1.3/README.Platforms @@ -0,0 +1,33 @@ + +This is a list of the platforms SDL supports, and who maintains them. + +Officially supported platforms +============================== +(code compiles, and thoroughly tested for release) +============================== +Windows XP +Windows Vista +Windows 7 +Mac OS X 10.4+ +Linux 2.6+ +iOS 3.1.3+ +Android 1.6+ + +Unofficially supported platforms +================================ +(code compiles, but not thoroughly tested) +================================ +Windows CE +FreeBSD +NetBSD +OpenBSD +Solaris + +Platforms supported by volunteers +================================= +Pandora - maintained by Scott Smith + +Platforms that need maintainers +=============================== +Nintendo DS +Haiku diff --git a/project/jni/sdl-1.3/README.Watcom b/project/jni/sdl-1.3/README.Watcom new file mode 100644 index 000000000..b0ae8b898 --- /dev/null +++ b/project/jni/sdl-1.3/README.Watcom @@ -0,0 +1,139 @@ + +Using SDL 1.3 under Windows with the OpenWatcom compiler + +==================================================== + +Prerequisites +------------- + +I have done the port under Windows XP Professional with SP2 installed. +Windows 2000 should also be working. I'm not so sure about ancient Windows NT, +since only DirectX 3 is available there. Building should be possible, +but running the compiled applications will probalbly fail with +SDL_VIDEODRIVER=directx. The windib driver should work, though. + +To compile and use the SDL with Open Watcom you will need the following: +- Open Watcom compiler. I used version 1.8. The environment variables + PATH, WATCOM and INCLUDE need to be set appropriately - please consult + the OpenWatcom documentation and instructions given during the + installation of the compiler. + My setup looks like this in owvars.bat: + set WATCOM=C:\dev\ow18 + set INCLUDE=%WATCOM%\h;%WATCOM%\h\nt + set PATH=%PATH%;%WATCOM%\binnt;%WATCOM%\binw +- A recent DirectX SDK. The library needs D3d9.h so at leat the + directx 9 sdk is to be used. I used DirectX 10 SDK from August 2009 + taken directly from the microsoft site. +- The SDL 1.3 sources from Subversion +- The file Watcom-Win32.zip (now available in Subversion) + + +Building the Library +-------------------- + +1) In the SDL base directory extract the archive Watcom-Win32.zip. This + creates a subdirectory named 'watcom'. +2) The makefile expects the environment variable DXDIR to be set to the + base directory of a DirectX SDK. I have tried the August 2009 + DirectX SDK from Microsoft + You can also edit the makefile directly and hard code your path to + the SDK on your system. + I have this in my setup: + set DXDIR=..\dx10 +3) Enter the watcom directory and run + wmake sdl +4) All tests from the test directory are working and can be built by + running + wmake tests + +Notes: + + The makefile offers some options to tweak the way the library is built. + You have at your disposal the option to build a static (default) + library, or a DLL (with tgt=dll). You can also choose whether to build + a Release (default) or a Debug version (with build=debug) of the tests + and library. Please consult the usage comment at the top of the + makefile for usage instructions. + + If you specify a test target (i.e. 'wmake tests' for all tests, or + selected targets like 'wmake testgl testvidinfo testoverlay2'), the + tests are always freshly compiled and linked. This is done to + minimise hassle when switching between library versions (static vs. + DLL), because they require subtly different options. + Also, the test executables are put directly into the test directory, + so they can find their data files. The clean target of the makefile + removes the test executables and the SDL.dll file from the test + directory. + + To use the library in your own projects with Open Watcom, you can use + the way the tests are built as base of your own build environment. + + The library can also be built with the stack calling convention of the + compiler (-6s instead of -6r). + +Test applications +----------------- +$FixME: which test works ? which one compiles ? + +I've tried to make all tests work. The following table gives an overview +of the current status. + + Testname Status +~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +checkkeys + +graywin + +loopwave + +testalpha + +testbitmap + +testdyngl + +testerror + +testfile + +testgamma + +testgl + +testhread + +testiconv - (all failed) +testkeys + +testlock + +testoverlay + (needs 'set SDL_VIDEODRIVER=directx') +testoverlay2 + (needs 'set SDL_VIDEODRIVER=directx') +testpalette + +testplatform + +testsem + +testsprite + +testtimer + +testver + +testvidinfo + +testwin ? (fading doesn't seem right) +testwm + +torturethread + +testcdrom + +testjoystick not tested +threadwin + +testcursor + + + +TODO +---- + +There is room for further improvement: +- Test joystick functionality. +- Investigate fading issue in 'testwin' test. +- Fix the UTF-8 support. +- Adapt the makefile/object file list to support more target systems +- Use "#pragma aux" syntax for the CPU info functions. + + +Questions and Comments +---------------------- + +Please direct any questions or comments to me: + + ow_sdl [at] digitalfantasy [dot] it + +The original porting to the open watcom compiler was made by +Marc Peter + + Happy Coding! + + Daniele Forghieri + diff --git a/project/jni/sdl-1.3/README.WinCE b/project/jni/sdl-1.3/README.WinCE new file mode 100644 index 000000000..6f8799ef8 --- /dev/null +++ b/project/jni/sdl-1.3/README.WinCE @@ -0,0 +1,55 @@ + +Project files for embedded Visual C++ 3.0, 4.0 and +Visual Studio 2005 can be found in VisualCE.zip + +SDL supports GAPI and WinDib output for Windows CE. + +GAPI driver supports: + +- all possible WinCE devices (Pocket PC, Smartphones, HPC) + with different orientations of video memory and resolutions. +- 4, 8 and 16 bpp devices +- special handling of 8bpp on 8bpp devices +- VGA mode, you can even switch between VGA and GAPI in runtime + (between 240x320 and 480x640 for example). On VGA devices you can + use either GAPI or VGA. +- Landscape mode and automatic rotation of buttons and stylus coordinates. + To enable landscape mode make width of video screen bigger than height. + For example: + SDL_SetVideoMode(320,240,16,SDL_FULLSCREEN) +- WM2005 +- SDL_ListModes + +NOTE: +There are several SDL features not available in the WinCE port of SDL. + +- DirectX is not yet available +- Semaphores are not available +- Joystick support is not available +- CD-ROM control is not available + +In addition, there are several features that run in "degraded" mode: + +Preprocessor Symbol Effect +=================== ================================= + +SDL_systimer.c: +USE_GETTICKCOUNT Less accurate values for SDL time functions +USE_SETTIMER Use only a single marginally accurate timer + +SDL_syswm.c: +DISABLE_ICON_SUPPORT Can't set the runtime window icon + +SDL_sysmouse.c: +USE_STATIC_CURSOR Only the arrow cursor is available + +SDL_sysevents.c: +NO_GETKEYBOARDSTATE Can't get modifier state on keyboard focus + +SDL_dibevents.c: +NO_GETKEYBOARDSTATE Very limited keycode translation + +SDL_dibvideo.c: +NO_GETDIBITS Can't distinguish between 15 bpp and 16 bpp +NO_CHANGEDISPLAYSETTINGS No fullscreen support +NO_GAMMA_SUPPORT Gamma correction not available diff --git a/project/jni/sdl-1.3/README.android b/project/jni/sdl-1.3/README.android new file mode 100644 index 000000000..e556db074 --- /dev/null +++ b/project/jni/sdl-1.3/README.android @@ -0,0 +1,174 @@ +================================================================================ +Simple DirectMedia Layer for Android +================================================================================ + +Requirements: + +Android SDK +http://developer.android.com/sdk/index.html + +Android NDK r4 or later +http://developer.android.com/sdk/ndk/index.html + + +================================================================================ + How the port works +================================================================================ + +- Android applications are Java-based, optionally with parts written in C +- As SDL apps are C-based, we use a small Java shim that uses JNI to talk to +the SDL library +- This means that your application C code must be placed inside an android +Java project, along with some C support code that communicates with Java +- This eventually produces a standard Android .apk package + +The Android Java code implements an "activity" and can be found in: +android-project/src/org/libsdl/app/SDLActivity.java + +The Java code loads your game code, the SDL shared library, and +dispatches to native functions implemented in the SDL library: +src/SDL_android.cpp + +Your project must include some glue code that starts your main() routine: +src/main/android/SDL_android_main.cpp + + +================================================================================ + Building an app +================================================================================ + +Instructions: +1. Copy the android-project directory wherever you want to keep your projects and rename it to the name of your project. +2. Move this SDL directory into the /jni directory +3. Place your application source files in the /jni/src directory +4. Edit /jni/src/Android.mk to include your source files +5. Run 'ndk-build' (a script provided by the NDK). This compiles the C source + +If you want to use the Eclipse IDE, skip to the Eclipse section below. + +6. Edit /local.properties to point to the Android SDK directory +7. Run 'ant debug' in android/project. This compiles the .java and eventually +creates a .apk with the native code embedded +8. 'ant install' will push the apk to the device or emulator (if connected) + +Here's an explanation of the files in the Android project, so you can customize them: + +android-project/ + AndroidManifest.xml - package manifest, do not modify + build.properties - empty + build.xml - build description file, used by ant + default.properties - holds the ABI for the application, currently android-4 which corresponds to the Android 1.6 system image + local.properties - holds the SDK path, you should change this to the path to your SDK + jni/ - directory holding native code + jni/Android.mk - Android makefile that includes all subdirectories + jni/SDL/ - directory holding the SDL library files + jni/SDL/Android.mk - Android makefile for creating the SDL shared library + jni/src/ - directory holding your C/C++ source + jni/src/Android.mk - Android makefile that you should customize to include your source code and any library references + res/ - directory holding resources for your application + res/drawable-* - directories holding icons for different phone hardware + res/layout/main.xml - place holder for the main screen layout, overridden by the SDL video output + res/values/strings.xml - strings used in your application, including the application name shown on the phone. + src/org/libsdl/app/SDLActivity.java - the Java class handling the initialization and binding to SDL. Be very careful changing this, as the SDL library relies on this implementation. + + +================================================================================ + Additional documentation +================================================================================ + +The documentation in the NDK docs directory is very helpful in understanding the build process and how to work with native code on the Android platform. + +The best place to start is with docs/OVERVIEW.TXT + + +================================================================================ + Using Eclipse +================================================================================ + +First make sure that you've installed Eclipse and the Android extensions as described here: + http://developer.android.com/sdk/eclipse-adt.html + +Once you've copied the SDL android project and customized it, you can create an Eclipse project from it: + * File -> New -> Other + * Select the Android -> Android Project wizard and click Next + * Enter the name you'd like your project to have + * Select "Create project from existing source" and browse for your project directory + * Make sure the Build Target is set to Android 1.6 + * Click Finish + + +================================================================================ + Loading files and resources +================================================================================ + +NEED CONTENT + + +================================================================================ + Troubleshooting +================================================================================ + +You can create and run an emulator from the Eclipse IDE: + * Window -> Android SDK and AVD Manager + +You can see if adb can see any devices with the following command: + adb devices + +You can see the output of log messages on the default device with: + adb logcat + +You can push files to the device with: + adb push local_file remote_path_and_file + +You can push files to the SD Card at /sdcard, for example: + adb push moose.dat /sdcard/moose.dat + +You can see the files on the SD card with a shell command: + adb shell ls /sdcard/ + +You can start a command shell on the default device with: + adb shell + +You can do a clean build with the following commands: + ndk-build clean + ndk-build + +You can see the complete command line that ndk-build is using by passing V=1 on the command line: + ndk-build V=1 + +If your application crashes in native code, you can use addr2line to convert the addresses in the stack trace to lines in your code. + +For example, if your crash looks like this: +I/DEBUG ( 31): signal 11 (SIGSEGV), code 2 (SEGV_ACCERR), fault addr 400085d0 +I/DEBUG ( 31): r0 00000000 r1 00001000 r2 00000003 r3 400085d4 +I/DEBUG ( 31): r4 400085d0 r5 40008000 r6 afd41504 r7 436c6a7c +I/DEBUG ( 31): r8 436c6b30 r9 435c6fb0 10 435c6f9c fp 4168d82c +I/DEBUG ( 31): ip 8346aff0 sp 436c6a60 lr afd1c8ff pc afd1c902 cpsr 60000030 +I/DEBUG ( 31): #00 pc 0001c902 /system/lib/libc.so +I/DEBUG ( 31): #01 pc 0001ccf6 /system/lib/libc.so +I/DEBUG ( 31): #02 pc 000014bc /data/data/org.libsdl.app/lib/libmain.so +I/DEBUG ( 31): #03 pc 00001506 /data/data/org.libsdl.app/lib/libmain.so + +You can see that there's a crash in the C library being called from the main code. I run addr2line with the debug version of my code: + arm-eabi-addr2line -C -f -e obj/local/armeabi/libmain.so +and then paste in the number after "pc" in the call stack, from the line that I care about: +000014bc + +I get output from addr2line showing that it's in the quit function, in testspriteminimal.c, on line 23. + +You can add logging to your code to help show what's happening: + +#include + + __android_log_print(ANDROID_LOG_INFO, "foo", "Something happened! x = %d", x); + +If you need to build without optimization turned on, you can create a file called "Application.mk" in the jni directory, with the following line in it: +APP_OPTIM := debug + + +================================================================================ + Known issues +================================================================================ + +- SDL audio (although it's mostly written, just not working properly yet) +- TODO. I'm sure there's a bunch more stuff I haven't thought of diff --git a/project/jni/sdl-1.3/README.ds b/project/jni/sdl-1.3/README.ds new file mode 100644 index 000000000..3b97144b3 --- /dev/null +++ b/project/jni/sdl-1.3/README.ds @@ -0,0 +1,59 @@ +================================================================================ +Simple DirectMedia Layer for Nintendo DS +================================================================================ + +-Requirements- +* The devkitpro SDK available at http://devkitpro.org. + Read the information at http://devkitpro.org/wiki/Getting_Started/devkitARM + The necessary packages are devkitARM, libnds, libfat and default arm7. +* The hardware renderer is using the libgl2d abstraction library that can be found at: + http://rel.phatcode.net/junk.php?id=117 + Build it, and install the library and the header where SDL can find them (ie. in + the libnds/lib and libnds/include directories). + + +-Building SDL- + +After setting the devkitpro environment, cd into your SDL directory and type: + make -f Makefile.ds + +This will compile and install the library and headers into the +devkitpro's portlibs directory. Additionnaly it will compile several +tests that you can run either on the DS or with desmume. For instance: + desmume test/nds-test-progs/general/general.nds + +-Notes- +* The renderer code is based on the gl like engine. It's not using the sprite engine. +* The port is very basic and incomplete: + - SDL currently has to be compiled for either framebuffer mode or render mode. + See USE_HW_RENDERER in Makefile.ds. + - some optional renderer functions are not implemented. + +-Limitations- +* in hardware renderer mode, don't load too many textures. The internal format is + 2 bytes per pixel. And there is only 256KB reserved for the textures. For instance, + testscale won't display sample.bmp, unless it's resized to a smaller picture. +* the screen size is 256 x 384. Anything else won't work. +* there is no 8 bits/pixel mode because SDL 1.3 doesn't support palettes. + +-Joystick mapping- +The Joystick presented to SDL has 2 axes and 8 buttons + + KEY | Code + A | 0 + B | 1 + X | 2 + Y | 3 + L | 4 + R | 5 + select | 6 + start | 7 + + Left-right is axe 0. + Up-down is axe 1. + +-Mouse mapping- +todo + +-Examples- +Due to memory limitations, to be able to successfully run the testscale example, sample.bmp must be resized to 256x105. diff --git a/project/jni/sdl-1.3/README.iphoneos b/project/jni/sdl-1.3/README.iphoneos new file mode 100644 index 000000000..39ff14da9 --- /dev/null +++ b/project/jni/sdl-1.3/README.iphoneos @@ -0,0 +1,111 @@ +============================================================================== +Building the Simple DirectMedia Layer for iPhone OS 2.0 +============================================================================== + +Requirements: Mac OS X v10.5 or later and the iPhone SDK. + +Instructions: +1. Open SDLiPhoneOS.xcodeproj (located in Xcode-iPhoneOS/SDL) in XCode. +2. Set Project->Set Active SDK to "Use Project Settings" +3. Select your desired target, and hit build. + +There are three build targets: +- StaticLibiPhoneOS: + Build SDL as a statically linked (armv6) library for iPhone OS 2.0. +- StaticLibSimulator: + Build SDL as a statically linked (x86) library for the iPhone Simulator +- Template: + Package a project template together with the SDL for iPhone static libraries and copies of the SDL headers. The template includes proper references to the SDL library and headers, skeleton code for a basic SDL program, and placeholder graphics for the application icon and startup screen. + +============================================================================== +Using the Simple DirectMedia Layer for iPhone OS 2.0 +============================================================================== + +Here is the easiest method: +1. Build the SDL libraries (libSDLiPhoneOS.a and libSDLSimulator.a) and the iPhone SDL Application template. +1. Install the iPhone SDL Application template by copying it to one of XCode's template directories. I recommend creating a directory called "SDL" in "/Developer/Platforms/iPhoneOS.platform/Developer/Library/XCode/Project Templates/" and placing it there. +2. Start a new project using the template. The project should be immediately ready for use with SDL. + +Here is a more manual method: +1. Create a new iPhone view based application. +2. Build the SDL static libraries (libSDLiPhoneOS.a and libSDLSimulator.a) for iPhone and include them in your project. XCode will ignore the library that is not currently of the correct architecture, hence your app will work both on iPhone and in the iPhone Simulator. +3. Include the SDL header files in your project. +4. Remove the ApplicationDelegate.h and ApplicationDelegate.m files -- SDL for iPhone provides its own UIApplicationDelegate. Remove MainWindow.xib -- SDL for iPhone produces its user interface programmatically. +5. Delete the contents of main.m and program your app as a regular SDL program instead. You may replace main.m with your own main.c, but you must tell XCode not to use the project prefix file, as it includes Objective-C code. + +============================================================================== +Notes -- Accelerometer as Joystick +============================================================================== + +SDL for iPhone supports polling the built in accelerometer as a joystick device. For an example on how to do this, see the accelerometer.c in the demos directory. + +The main thing to note when using the accelerometer with SDL is that while the iPhone natively reports accelerometer as floating point values in units of g-force, SDL_JoystickGetAxis reports joystick values as signed integers. Hence, in order to convert between the two, some clamping and scaling is necessary on the part of the iPhone SDL joystick driver. To convert SDL_JoystickGetAxis reported values BACK to units of g-force, simply multiply the values by SDL_IPHONE_MAX_GFORCE / 0x7FFF. + +============================================================================== +Notes -- OpenGL ES +============================================================================== + +Your SDL application for iPhone uses OpenGL ES for video by default. + +OpenGL ES for iPhone supports several display pixel formats, such as RGBA8 and RGB565, which provide a 32 bit and 16 bit color buffer respectively. By default, the implementation uses RGB565, but you may use RGBA8 by setting each color component to 8 bits in SDL_GL_SetAttribute. + +If your application doesn't use OpenGL's depth buffer, you may find significant performance improvement by setting SDL_GL_DEPTH_SIZE to 0. + +Finally, if your application completely redraws the screen each frame, you may find significant performance improvement by setting the attribute SDL_GL_RETAINED_BACKING to 1. + +============================================================================== +Notes -- Keyboard +============================================================================== + +SDL for iPhone contains several additional functions related to keyboard visibility. These functions are not part of the SDL standard API, but are necessary for revealing and hiding the iPhone's virtual onscreen keyboard. You can use them in your own applications by including a copy of the SDL_uikitkeyboard.h header (located in src/video/uikit) in your project. + +int SDL_iPhoneKeyboardShow(SDL_Window * window) + -- reveals the onscreen keyboard. Returns 0 on success and -1 on error. +int SDL_iPhoneKeyboardHide(SDL_Window * window) + -- hides the onscreen keyboard. Returns 0 on success and -1 on error. +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) + -- returns whether or not the onscreen keyboard is currently visible. +int SDL_iPhoneKeyboardToggle(SDL_Window * window) + -- toggles the visibility of the onscreen keyboard. Returns 0 on success and -1 on error. + +============================================================================== +Notes -- Reading and Writing files +============================================================================== + +Each application installed on iPhone resides in a sandbox which includes its own Application Home directory. Your application may not access files outside this directory. + +Once your application is installed its directory tree looks like: + +MySDLApp Home/ + MySDLApp.app + Documents/ + Library/ + Preferences/ + tmp/ + +When your SDL based iPhone application starts up, it sets the working directory to the main bundle (MySDLApp Home/MySDLApp.app), where your application resources are stored. You cannot write to this directory. Instead, I advise you to write document files to "../Documents/" and preferences to "../Library/Preferences". + +More information on this subject is available here: +http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/ApplicationEnvironment/chapter_6_section_3.html#//apple_ref/doc/uid/TP40007072-CH7-SW21 + +============================================================================== +Notes -- iPhone SDL limitations +============================================================================== + +Windows: + Full-size, single window applications only. You cannot create multi-window SDL applications for iPhone OS. The application window will fill the display, though you have the option of turning on or off the menu-bar (pass SDL_CreateWindow the flag SDL_WINDOW_BORDERLESS). Presently, landscape mode is not supported. + +Video: + For real time frame-rates, you are advised to use strictly SDL 1.3 video calls. Using compatibility video calls uploads an OpenGL texture for each frame drawn, and this operation is excruciatingly slow. + +Textures: + SDL for iPhone Textures supports only SDL_PIXELFORMAT_ABGR8888 and SDL_PIXELFORMAT_RGB24 pixel formats. This is because texture support in SDL for iPhone is done through OpenGL ES, which supports fewer pixel formats than OpenGL, will not re-order pixel data for you, and has no support for color-paletted formats (without extensions). + +Audio: + SDL for iPhone does not yet support audio input. + +Loading Shared Objects: + This is disabled by default since it seems to break the terms of the iPhone SDK agreement. It can be re-enabled in SDL_config_iphoneos.h. + + + diff --git a/project/jni/sdl-1.3/README.pandora b/project/jni/sdl-1.3/README.pandora new file mode 100644 index 000000000..8f8f8a9c6 --- /dev/null +++ b/project/jni/sdl-1.3/README.pandora @@ -0,0 +1,16 @@ +SDL 1.3 with open pandora console support ( http://openpandora.org/ ) +===================================================================== + +- A pandora specific video driver was writed to allow SDL 1.3 with OpenGL ES +support to work on the pandora under the framebuffer. This driver do not have +input support for now, so if you use it you will have to add your own control code. +The video driver name is "pandora" so if you have problem running it from +the framebuffer, try to set the following variable before starting your application : +"export SDL_VIDEODRIVER=pandora" + +- OpenGL ES support was added to the x11 driver, so it's working like the normal +x11 driver one with OpenGLX support, with SDL input event's etc.. + + +David Carré (Cpasjuste) +cpasjuste@gmail.com diff --git a/project/jni/sdl-1.3/include/SDL.h b/project/jni/sdl-1.3/include/SDL.h index 0f4eb35b0..d6f130fca 100644 --- a/project/jni/sdl-1.3/include/SDL.h +++ b/project/jni/sdl-1.3/include/SDL.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -37,10 +36,6 @@ * level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, * and 2D framebuffer across multiple platforms. * - * The current version supports Windows, Windows CE, Mac OS X, Linux, - * FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, and QNX. The code contains - * support for other operating systems but those are not officially supported. - * * SDL is written in C, but works with C++ natively, and has bindings to * several other languages, including Ada, C#, Eiffel, Erlang, Euphoria, * Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP, @@ -76,6 +71,7 @@ #include "SDL_main.h" #include "SDL_stdinc.h" +#include "SDL_assert.h" #include "SDL_atomic.h" #include "SDL_audio.h" #include "SDL_clipboard.h" @@ -83,9 +79,12 @@ #include "SDL_endian.h" #include "SDL_error.h" #include "SDL_events.h" +#include "SDL_hints.h" #include "SDL_loadso.h" +#include "SDL_log.h" #include "SDL_mutex.h" #include "SDL_power.h" +#include "SDL_render.h" #include "SDL_rwops.h" #include "SDL_thread.h" #include "SDL_timer.h" @@ -116,7 +115,6 @@ extern "C" { #define SDL_INIT_JOYSTICK 0x00000200 #define SDL_INIT_HAPTIC 0x00001000 #define SDL_INIT_NOPARACHUTE 0x00100000 /**< Don't catch fatal signals */ -#define SDL_INIT_EVENTTHREAD 0x01000000 /**< Not supported on all OS's */ #define SDL_INIT_EVERYTHING 0x0000FFFF /*@}*/ diff --git a/project/jni/sdl-1.3/include/SDL_assert.h b/project/jni/sdl-1.3/include/SDL_assert.h index 6c72fa18e..19331232b 100644 --- a/project/jni/sdl-1.3/include/SDL_assert.h +++ b/project/jni/sdl-1.3/include/SDL_assert.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_assert_h @@ -50,9 +49,11 @@ on the assertion line and not in some random guts of SDL, and so each assert can have unique static variables associated with it. */ -#if (defined(_MSC_VER) && ((_M_IX86) || (_M_X64))) - #define SDL_TriggerBreakpoint() __asm { int 3 } -#elif (defined(__GNUC__) && ((__i386__) || (__x86_64__))) +#if defined(_MSC_VER) && !defined(_WIN32_WCE) +/* Don't include intrin.h here because it contains C++ code */ +extern void __cdecl __debugbreak(void); + #define SDL_TriggerBreakpoint() __debugbreak() +#elif (defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))) #define SDL_TriggerBreakpoint() __asm__ __volatile__ ( "int $3\n\t" ) #elif defined(HAVE_SIGNAL_H) #include @@ -62,7 +63,7 @@ assert can have unique static variables associated with it. #define SDL_TriggerBreakpoint() #endif -#if (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ +#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L) /* C99 supports __func__ as a standard. */ # define SDL_FUNCTION __func__ #elif ((__GNUC__ >= 2) || defined(_MSC_VER)) # define SDL_FUNCTION __FUNCTION__ @@ -98,7 +99,7 @@ typedef enum SDL_ASSERTION_BREAK, /**< Make the debugger trigger a breakpoint. */ SDL_ASSERTION_ABORT, /**< Terminate the program. */ SDL_ASSERTION_IGNORE, /**< Ignore the assert. */ - SDL_ASSERTION_ALWAYS_IGNORE, /**< Ignore the assert from now on. */ + SDL_ASSERTION_ALWAYS_IGNORE /**< Ignore the assert from now on. */ } SDL_assert_state; typedef struct SDL_assert_data @@ -168,7 +169,7 @@ extern DECLSPEC SDL_assert_state SDLCALL SDL_ReportAssertion(SDL_assert_data *, typedef SDL_assert_state (SDLCALL *SDL_AssertionHandler)( - const SDL_assert_data *, void *userdata); + const SDL_assert_data* data, void* userdata); /** * \brief Set an application-defined assertion handler. @@ -204,7 +205,7 @@ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( * * * const SDL_assert_data *item = SDL_GetAssertionReport(); - * while (item->condition) { + * while (item) { * printf("'%s', %s (%s:%d), triggered %u times, always ignore: %s.\n", * item->condition, item->function, item->filename, * item->linenum, item->trigger_count, @@ -213,8 +214,7 @@ extern DECLSPEC void SDLCALL SDL_SetAssertionHandler( * } * * - * \return List of all assertions. This never returns NULL, - * even if there are no items. + * \return List of all assertions. * \sa SDL_ResetAssertionReport */ extern DECLSPEC const SDL_assert_data * SDLCALL SDL_GetAssertionReport(void); diff --git a/project/jni/sdl-1.3/include/SDL_atomic.h b/project/jni/sdl-1.3/include/SDL_atomic.h index e3711433f..6a6a73f5b 100644 --- a/project/jni/sdl-1.3/include/SDL_atomic.h +++ b/project/jni/sdl-1.3/include/SDL_atomic.h @@ -1,41 +1,58 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Contributed by Bob Pendleton, bob@pendleton.com - */ + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ /** - * \file SDL_atomic.h - * - * Atomic operations. - * - * These operations may, or may not, actually be implemented using - * processor specific atomic operations. When possible they are - * implemented as true processor specific atomic operations. When that - * is not possible the are implemented using locks that *do* use the - * available atomic operations. - * - * At the very minimum spin locks must be implemented. Without spin - * locks it is not possible (AFAICT) to emulate the rest of the atomic - * operations. + * \file SDL_atomic.h + * + * Atomic operations. + * + * IMPORTANT: + * If you are not an expert in concurrent lockless programming, you should + * only be using the atomic lock and reference counting functions in this + * file. In all other cases you should be protecting your data structures + * with full mutexes. + * + * The list of "safe" functions to use are: + * SDL_AtomicLock() + * SDL_AtomicUnlock() + * SDL_AtomicIncRef() + * SDL_AtomicDecRef() + * + * Seriously, here be dragons! + * ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + * + * You can find out a little more about lockless programming and the + * subtle issues that can arise here: + * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx + * + * There's also lots of good information here: + * http://www.1024cores.net/home/lock-free-algorithms + * + * These operations may or may not actually be implemented using + * processor specific atomic operations. When possible they are + * implemented as true processor specific atomic operations. When that + * is not possible the are implemented using locks that *do* use the + * available atomic operations. + * + * All of the atomic operations that modify memory are full memory barriers. */ #ifndef _SDL_atomic_h_ @@ -46,6 +63,13 @@ #include "begin_code.h" +/* Need to do this here because intrin.h has C++ code in it */ +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE) +#include +#define HAVE_MSC_ATOMICS 1 +#endif + /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ @@ -53,154 +77,232 @@ extern "C" { /* *INDENT-ON* */ #endif -/* Function prototypes */ - /** - * \name SDL AtomicLock - * - * The spin lock functions and type are required and can not be - * emulated because they are used in the emulation code. + * \name SDL AtomicLock + * + * The atomic locks are efficient spinlocks using CPU instructions, + * but are vulnerable to starvation and can spin forever if a thread + * holding a lock has been terminated. For this reason you should + * minimize the code executed inside an atomic lock and never do + * expensive things like API or system calls while holding them. + * + * The atomic locks are not safe to lock recursively. + * + * Porting Note: + * The spin lock functions and type are required and can not be + * emulated because they are used in the atomic emulation code. */ /*@{*/ -typedef volatile Uint32 SDL_SpinLock; +typedef int SDL_SpinLock; /** - * \brief Lock a spin lock by setting it to a none zero value. - * - * \param lock Points to the lock. + * \brief Try to lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. + * + * \return SDL_TRUE if the lock succeeded, SDL_FALSE if the lock is already held. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTryLock(SDL_SpinLock *lock); + +/** + * \brief Lock a spin lock by setting it to a non-zero value. + * + * \param lock Points to the lock. */ extern DECLSPEC void SDLCALL SDL_AtomicLock(SDL_SpinLock *lock); /** - * \brief Unlock a spin lock by setting it to 0. Always returns immediately + * \brief Unlock a spin lock by setting it to 0. Always returns immediately * - * \param lock Points to the lock. + * \param lock Points to the lock. */ extern DECLSPEC void SDLCALL SDL_AtomicUnlock(SDL_SpinLock *lock); /*@}*//*SDL AtomicLock*/ -/** - * \name 32 bit atomic operations - */ -/*@{*/ /** - * \brief Check to see if \c *ptr == 0 and set it to 1. - * - * \return SDL_True if the value pointed to by \c ptr was zero and - * SDL_False if it was not zero - * - * \param ptr Points to the value to be tested and set. + * The compiler barrier prevents the compiler from reordering + * reads and writes to globally visible variables across the call. */ -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet32(volatile Uint32 * ptr); +#ifdef _MSC_VER +void _ReadWriteBarrier(void); +#pragma intrinsic(_ReadWriteBarrier) +#define SDL_CompilerBarrier() _ReadWriteBarrier() +#elif defined(__GNUC__) +#define SDL_CompilerBarrier() __asm__ __volatile__ ("" : : : "memory") +#else +#define SDL_CompilerBarrier() \ +({ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); }) +#endif + +/* Platform specific optimized versions of the atomic functions, + * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE + */ +#if defined(SDL_ATOMIC_DISABLED) && SDL_ATOMIC_DISABLED +#define SDL_DISABLE_ATOMIC_INLINE +#endif +#ifndef SDL_DISABLE_ATOMIC_INLINE + +#ifdef HAVE_MSC_ATOMICS + +#define SDL_AtomicSet(a, v) _InterlockedExchange((long*)&(a)->value, (v)) +#define SDL_AtomicAdd(a, v) _InterlockedExchangeAdd((long*)&(a)->value, (v)) +#define SDL_AtomicCAS(a, oldval, newval) (_InterlockedCompareExchange((long*)&(a)->value, (newval), (oldval)) == (oldval)) +#define SDL_AtomicSetPtr(a, v) _InterlockedExchangePointer((a), (v)) +#if _M_IX86 +#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchange((long*)(a), (long)(newval), (long)(oldval)) == (long)(oldval)) +#else +#define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchangePointer((a), (newval), (oldval)) == (oldval)) +#endif + +#elif defined(__MACOSX__) +#include + +#define SDL_AtomicCAS(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((oldval), (newval), &(a)->value) +#if SIZEOF_VOIDP == 4 +#define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((int32_t)(oldval), (int32_t)(newval), (int32_t*)(a)) +#elif SIZEOF_VOIDP == 8 +#define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap64Barrier((int64_t)(oldval), (int64_t)(newval), (int64_t*)(a)) +#endif + +#elif defined(HAVE_GCC_ATOMICS) + +#define SDL_AtomicSet(a, v) __sync_lock_test_and_set(&(a)->value, v) +#define SDL_AtomicAdd(a, v) __sync_fetch_and_add(&(a)->value, v) +#define SDL_AtomicSetPtr(a, v) __sync_lock_test_and_set(a, v) +#define SDL_AtomicCAS(a, oldval, newval) __sync_bool_compare_and_swap(&(a)->value, oldval, newval) +#define SDL_AtomicCASPtr(a, oldval, newval) __sync_bool_compare_and_swap(a, oldval, newval) + +#endif + +#endif /* !SDL_DISABLE_ATOMIC_INLINE */ + /** - * \brief Set the value pointed to by \c ptr to be zero. - * - * \param ptr Address of the value to be set to zero + * \brief A type representing an atomic integer value. It is a struct + * so people don't accidentally use numeric operations on it. */ -extern DECLSPEC void SDLCALL SDL_AtomicClear32(volatile Uint32 * ptr); +#ifndef SDL_atomic_t_defined +typedef struct { int value; } SDL_atomic_t; +#endif /** - * \brief Fetch the current value of \c *ptr and then increment that - * value in place. - * - * \return The value before it was incremented. - * - * \param ptr Address of the value to fetch and increment - */ -extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr); + * \brief Set an atomic variable to a new value if it is currently an old value. + * + * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +#ifndef SDL_AtomicCAS +#define SDL_AtomicCAS SDL_AtomicCAS_ +#endif +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS_(SDL_atomic_t *a, int oldval, int newval); /** - * \brief Fetch \c *ptr and then decrement the value in place. - * - * \return The value before it was decremented. - * - * \param ptr Address of the value to fetch and decrement + * \brief Set an atomic variable to a value. + * + * \return The previous value of the atomic variable. */ -extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr); +#ifndef SDL_AtomicSet +static __inline__ int SDL_AtomicSet(SDL_atomic_t *a, int v) +{ + int value; + do { + value = a->value; + } while (!SDL_AtomicCAS(a, value, v)); + return value; +} +#endif /** - * \brief Fetch the current value at \c ptr and then add \c value to \c *ptr. - * - * \return \c *ptr before the addition took place. - * - * \param ptr The address of data we are changing. - * \param value The value to add to \c *ptr. + * \brief Get the value of an atomic variable */ -extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value); +#ifndef SDL_AtomicGet +static __inline__ int SDL_AtomicGet(SDL_atomic_t *a) +{ + int value = a->value; + SDL_CompilerBarrier(); + return value; +} +#endif /** - * \brief Fetch \c *ptr and then subtract \c value from it. - * - * \return \c *ptr before the subtraction took place. - * - * \param ptr The address of the data being changed. - * \param value The value to subtract from \c *ptr. + * \brief Add to an atomic variable. + * + * \return The previous value of the atomic variable. + * + * \note This same style can be used for any number operation */ -extern DECLSPEC Uint32 SDLCALL SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value); +#ifndef SDL_AtomicAdd +static __inline__ int SDL_AtomicAdd(SDL_atomic_t *a, int v) +{ + int value; + do { + value = a->value; + } while (!SDL_AtomicCAS(a, value, (value + v))); + return value; +} +#endif /** - * \brief Add one to the data pointed to by \c ptr and return that value. - * - * \return The incremented value. - * - * \param ptr The address of the data to increment. + * \brief Increment an atomic variable used as a reference count. */ -extern DECLSPEC Uint32 SDLCALL SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr); +#ifndef SDL_AtomicIncRef +#define SDL_AtomicIncRef(a) SDL_AtomicAdd(a, 1) +#endif /** - * \brief Subtract one from data pointed to by \c ptr and return the new value. - * - * \return The decremented value. - * - * \param ptr The address of the data to decrement. + * \brief Decrement an atomic variable used as a reference count. + * + * \return SDL_TRUE if the variable reached zero after decrementing, + * SDL_FALSE otherwise */ -extern DECLSPEC Uint32 SDLCALL SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr); +#ifndef SDL_AtomicDecRef +#define SDL_AtomicDecRef(a) (SDL_AtomicAdd(a, -1) == 1) +#endif /** - * \brief Add \c value to the data pointed to by \c ptr and return result. - * - * \return The sum of \c *ptr and \c value. - * - * \param ptr The address of the data to be modified. - * \param value The value to be added. - */ -extern DECLSPEC Uint32 SDLCALL SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value); + * \brief Set a pointer to a new value if it is currently an old value. + * + * \return SDL_TRUE if the pointer was set, SDL_FALSE otherwise. + * + * \note If you don't know what this function is for, you shouldn't use it! +*/ +#ifndef SDL_AtomicCASPtr +#define SDL_AtomicCASPtr SDL_AtomicCASPtr_ +#endif +extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr_(void* *a, void *oldval, void *newval); /** - * \brief Subtract \c value from the data pointed to by \c ptr and return the result. - * - * \return The difference between \c *ptr and \c value. - * - * \param ptr The address of the data to be modified. - * \param value The value to be subtracted. + * \brief Set a pointer to a value atomically. + * + * \return The previous value of the pointer. */ -extern DECLSPEC Uint32 SDLCALL SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value); - -/*@}*//*32 bit atomic operations*/ +#ifndef SDL_AtomicSetPtr +static __inline__ void* SDL_AtomicSetPtr(void* *a, void* v) +{ + void* value; + do { + value = *a; + } while (!SDL_AtomicCASPtr(a, value, v)); + return value; +} +#endif /** - * \name 64 bit atomic operations + * \brief Get the value of a pointer atomically. */ -/*@{*/ -#ifdef SDL_HAS_64BIT_TYPE +#ifndef SDL_AtomicGetPtr +static __inline__ void* SDL_AtomicGetPtr(void* *a) +{ + void* value = *a; + SDL_CompilerBarrier(); + return value; +} +#endif -extern DECLSPEC SDL_bool SDLCALL SDL_AtomicTestThenSet64(volatile Uint64 * ptr); -extern DECLSPEC void SDLCALL SDL_AtomicClear64(volatile Uint64 * ptr); -extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr); -extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr); -extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value); -extern DECLSPEC Uint64 SDLCALL SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value); -extern DECLSPEC Uint64 SDLCALL SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr); -extern DECLSPEC Uint64 SDLCALL SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr); -extern DECLSPEC Uint64 SDLCALL SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value); -extern DECLSPEC Uint64 SDLCALL SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value); -#endif /* SDL_HAS_64BIT_TYPE */ - -/*@}*//*64 bit atomic operations*/ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/project/jni/sdl-1.3/include/SDL_audio.h b/project/jni/sdl-1.3/include/SDL_audio.h index fc55c5217..611084129 100644 --- a/project/jni/sdl-1.3/include/SDL_audio.h +++ b/project/jni/sdl-1.3/include/SDL_audio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/SDL_blendmode.h b/project/jni/sdl-1.3/include/SDL_blendmode.h index 33aa719fe..11d91bb1a 100644 --- a/project/jni/sdl-1.3/include/SDL_blendmode.h +++ b/project/jni/sdl-1.3/include/SDL_blendmode.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -43,12 +42,9 @@ extern "C" { typedef enum { SDL_BLENDMODE_NONE = 0x00000000, /**< No blending */ - SDL_BLENDMODE_MASK = 0x00000001, /**< dst = A ? src : dst - (alpha is mask) */ - - SDL_BLENDMODE_BLEND = 0x00000002, /**< dst = (src * A) + (dst * (1-A)) */ - SDL_BLENDMODE_ADD = 0x00000004, /**< dst = (src * A) + dst */ - SDL_BLENDMODE_MOD = 0x00000008 /**< dst = src * dst */ + SDL_BLENDMODE_BLEND = 0x00000001, /**< dst = (src * A) + (dst * (1-A)) */ + SDL_BLENDMODE_ADD = 0x00000002, /**< dst = (src * A) + dst */ + SDL_BLENDMODE_MOD = 0x00000004 /**< dst = src * dst */ } SDL_BlendMode; /* Ends C function definitions when using C++ */ diff --git a/project/jni/sdl-1.3/include/SDL_clipboard.h b/project/jni/sdl-1.3/include/SDL_clipboard.h index bc9e348db..7c60d6373 100644 --- a/project/jni/sdl-1.3/include/SDL_clipboard.h +++ b/project/jni/sdl-1.3/include/SDL_clipboard.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -56,7 +55,7 @@ extern DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text); extern DECLSPEC char * SDLCALL SDL_GetClipboardText(void); /** - * \brief Returns whether the clipboard has text + * \brief Returns a flag indicating whether the clipboard exists and contains a text string that it non-empty * * \sa SDL_GetClipboardText() */ diff --git a/project/jni/sdl-1.3/include/SDL_compat.h b/project/jni/sdl-1.3/include/SDL_compat.h index 5613e9eea..c71022d80 100644 --- a/project/jni/sdl-1.3/include/SDL_compat.h +++ b/project/jni/sdl-1.3/include/SDL_compat.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -64,6 +63,12 @@ extern "C" { */ /*@{*/ +/* Platform */ +#ifdef __WIN32__ +#undef __WIN32__ +#define __WIN32__ 1 +#endif + /** * \name Surface flags */ @@ -202,14 +207,6 @@ typedef enum SDL_GRAB_ON = 1 } SDL_GrabMode; -typedef enum -{ - SDL_TEXTURESCALEMODE_NONE = SDL_SCALEMODE_NONE, - SDL_TEXTURESCALEMODE_FAST = SDL_SCALEMODE_FAST, - SDL_TEXTURESCALEMODE_SLOW = SDL_SCALEMODE_SLOW, - SDL_TEXTURESCALEMODE_BEST = SDL_SCALEMODE_BEST -} SDL_TextureScaleMode; - struct SDL_SysWMinfo; /** @@ -217,6 +214,13 @@ struct SDL_SysWMinfo; */ /*@{*/ +#define SDL_keysym SDL_Keysym +#define SDL_KeySym SDL_Keysym +#define SDL_scancode SDL_Scancode +#define SDL_ScanCode SDL_Scancode +#define SDLKey SDL_Keycode +#define SDLMod SDL_Keymod + /** * \name Renamed keys * @@ -272,8 +276,8 @@ struct SDL_SysWMinfo; #define SDL_AllocSurface SDL_CreateRGBSurface extern DECLSPEC const SDL_version *SDLCALL SDL_Linked_Version(void); -extern DECLSPEC char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); -extern DECLSPEC char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); +extern DECLSPEC const char *SDLCALL SDL_AudioDriverName(char *namebuf, int maxlen); +extern DECLSPEC const char *SDLCALL SDL_VideoDriverName(char *namebuf, int maxlen); extern DECLSPEC const SDL_VideoInfo *SDLCALL SDL_GetVideoInfo(void); extern DECLSPEC int SDLCALL SDL_VideoModeOK(int width, int height, @@ -323,18 +327,27 @@ extern DECLSPEC int SDLCALL SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect); extern DECLSPEC void SDLCALL SDL_FreeYUVOverlay(SDL_Overlay * overlay); extern DECLSPEC void SDLCALL SDL_GL_SwapBuffers(void); +extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); +extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red, + const Uint16 * green, + const Uint16 * blue); +extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green, + Uint16 * blue); extern DECLSPEC int SDLCALL SDL_EnableKeyRepeat(int delay, int interval); extern DECLSPEC void SDLCALL SDL_GetKeyRepeat(int *delay, int *interval); extern DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable); -typedef SDL_Texture* SDL_TextureID; typedef SDL_Window* SDL_WindowID; -#define SDL_RenderPoint SDL_RenderDrawPoint -#define SDL_RenderLine SDL_RenderDrawLine -#define SDL_RenderFill(X) (X) ? SDL_RenderFillRect(X) : SDL_RenderClear() #define SDL_KillThread(X) +/* The timeslice and timer resolution are no longer relevant */ +#define SDL_TIMESLICE 10 +#define TIMER_RESOLUTION 10 + +typedef Uint32 (SDLCALL * SDL_OldTimerCallback) (Uint32 interval); +extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback); + extern DECLSPEC int SDLCALL SDL_putenv(const char *variable); /*@}*//*Compatibility*/ diff --git a/project/jni/sdl-1.3/include/SDL_config.h.in b/project/jni/sdl-1.3/include/SDL_config.h.in index f99ecb763..9eed823d7 100644 --- a/project/jni/sdl-1.3/include/SDL_config.h.in +++ b/project/jni/sdl-1.3/include/SDL_config.h.in @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_config_h @@ -34,7 +33,7 @@ /* Make sure that this isn't included by Visual C++ */ #ifdef _MSC_VER -#error You should copy include/SDL_config.h.default to include/SDL_config.h +#error You should run hg revert SDL_config.h #endif /* C language features */ @@ -43,21 +42,10 @@ #undef volatile /* C datatypes */ -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) -#undef size_t -#undef int8_t -#undef uint8_t -#undef int16_t -#undef uint16_t -#undef int32_t -#undef uint32_t -#undef int64_t -#undef uint64_t -#undef uintptr_t -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ - #undef SIZEOF_VOIDP -#undef SDL_HAS_64BIT_TYPE +#undef HAVE_GCC_ATOMICS +#undef HAVE_GCC_SYNC_LOCK_TEST_AND_SET +#undef HAVE_PTHREAD_SPINLOCK /* Comment this if you want to build without any C library requirements */ #undef HAVE_LIBC @@ -81,6 +69,7 @@ #undef HAVE_ICONV_H #undef HAVE_SIGNAL_H #undef HAVE_ALTIVEC_H +#undef HAVE_PTHREAD_NP_H /* C library functions */ #undef HAVE_MALLOC @@ -88,7 +77,7 @@ #undef HAVE_REALLOC #undef HAVE_FREE #undef HAVE_ALLOCA -#ifndef _WIN32 /* Don't use C runtime versions of these on Windows */ +#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */ #undef HAVE_GETENV #undef HAVE_SETENV #undef HAVE_PUTENV @@ -151,6 +140,7 @@ #undef HAVE_SINF #undef HAVE_SQRT #undef HAVE_SIGACTION +#undef HAVE_SA_SIGACTION #undef HAVE_SETJMP #undef HAVE_NANOSLEEP #undef HAVE_SYSCONF @@ -158,6 +148,9 @@ #undef HAVE_CLOCK_GETTIME #undef HAVE_GETPAGESIZE #undef HAVE_MPROTECT +#undef HAVE_ICONV +#undef HAVE_PTHREAD_SETNAME_NP +#undef HAVE_PTHREAD_SET_NAME_NP #else /* We may need some replacement for stdarg.h here */ @@ -168,6 +161,7 @@ #undef SDL_DEFAULT_ASSERT_LEVEL /* Allow disabling of core subsystems */ +#undef SDL_ATOMIC_DISABLED #undef SDL_AUDIO_DISABLED #undef SDL_CPUINFO_DISABLED #undef SDL_EVENTS_DISABLED @@ -175,6 +169,7 @@ #undef SDL_JOYSTICK_DISABLED #undef SDL_HAPTIC_DISABLED #undef SDL_LOADSO_DISABLED +#undef SDL_RENDER_DISABLED #undef SDL_THREADS_DISABLED #undef SDL_TIMERS_DISABLED #undef SDL_VIDEO_DISABLED @@ -192,11 +187,10 @@ #undef SDL_AUDIO_DRIVER_COREAUDIO #undef SDL_AUDIO_DRIVER_DISK #undef SDL_AUDIO_DRIVER_DUMMY -#undef SDL_AUDIO_DRIVER_DMEDIA +#undef SDL_AUDIO_DRIVER_XAUDIO2 #undef SDL_AUDIO_DRIVER_DSOUND #undef SDL_AUDIO_DRIVER_ESD #undef SDL_AUDIO_DRIVER_ESD_DYNAMIC -#undef SDL_AUDIO_DRIVER_MMEAUDIO #undef SDL_AUDIO_DRIVER_NAS #undef SDL_AUDIO_DRIVER_NAS_DYNAMIC #undef SDL_AUDIO_DRIVER_NDS @@ -205,7 +199,7 @@ #undef SDL_AUDIO_DRIVER_PAUDIO #undef SDL_AUDIO_DRIVER_QSA #undef SDL_AUDIO_DRIVER_SUNAUDIO -#undef SDL_AUDIO_DRIVER_WINWAVEOUT +#undef SDL_AUDIO_DRIVER_WINMM #undef SDL_AUDIO_DRIVER_FUSIONSOUND #undef SDL_AUDIO_DRIVER_FUSIONSOUND_DYNAMIC @@ -218,7 +212,6 @@ #undef SDL_JOYSTICK_IOKIT #undef SDL_JOYSTICK_LINUX #undef SDL_JOYSTICK_NDS -#undef SDL_JOYSTICK_RISCOS #undef SDL_JOYSTICK_WINMM #undef SDL_JOYSTICK_USBHID #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H @@ -229,11 +222,10 @@ /* Enable various shared object loading systems */ #undef SDL_LOADSO_BEOS -#undef SDL_LOADSO_DLCOMPAT #undef SDL_LOADSO_DLOPEN #undef SDL_LOADSO_DUMMY #undef SDL_LOADSO_LDG -#undef SDL_LOADSO_WIN32 +#undef SDL_LOADSO_WINDOWS /* Enable various threading systems */ #undef SDL_THREAD_BEOS @@ -241,16 +233,14 @@ #undef SDL_THREAD_PTHREAD #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX #undef SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP -#undef SDL_THREAD_SPROC -#undef SDL_THREAD_WIN32 +#undef SDL_THREAD_WINDOWS /* Enable various timer systems */ #undef SDL_TIMER_BEOS #undef SDL_TIMER_DUMMY #undef SDL_TIMER_NDS -#undef SDL_TIMER_RISCOS #undef SDL_TIMER_UNIX -#undef SDL_TIMER_WIN32 +#undef SDL_TIMER_WINDOWS #undef SDL_TIMER_WINCE /* Enable various video drivers */ @@ -259,41 +249,29 @@ #undef SDL_VIDEO_DRIVER_DIRECTFB #undef SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC #undef SDL_VIDEO_DRIVER_DUMMY -#undef SDL_VIDEO_DRIVER_FBCON #undef SDL_VIDEO_DRIVER_NDS -#undef SDL_VIDEO_DRIVER_PHOTON -#undef SDL_VIDEO_DRIVER_QNXGF -#undef SDL_VIDEO_DRIVER_PS3 -#undef SDL_VIDEO_DRIVER_RISCOS -#undef SDL_VIDEO_DRIVER_SVGALIB -#undef SDL_VIDEO_DRIVER_WIN32 +#undef SDL_VIDEO_DRIVER_WINDOWS #undef SDL_VIDEO_DRIVER_X11 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR #undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XDAMAGE -#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XFIXES -#undef SDL_VIDEO_DRIVER_X11_VIDMODE +#undef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE +#undef SDL_VIDEO_DRIVER_X11_XCURSOR #undef SDL_VIDEO_DRIVER_X11_XINERAMA -#undef SDL_VIDEO_DRIVER_X11_XRANDR #undef SDL_VIDEO_DRIVER_X11_XINPUT -#undef SDL_VIDEO_DRIVER_X11_SCRNSAVER -#undef SDL_VIDEO_DRIVER_X11_XV -#undef SDL_VIDEO_DRIVER_X11_XRENDER -#undef SDL_VIDEO_DRIVER_X11_XDAMAGE -#undef SDL_VIDEO_DRIVER_X11_XFIXES +#undef SDL_VIDEO_DRIVER_X11_XRANDR +#undef SDL_VIDEO_DRIVER_X11_XSCRNSAVER #undef SDL_VIDEO_DRIVER_X11_XSHAPE +#undef SDL_VIDEO_DRIVER_X11_XVIDMODE #undef SDL_VIDEO_RENDER_D3D -#undef SDL_VIDEO_RENDER_GDI #undef SDL_VIDEO_RENDER_OGL #undef SDL_VIDEO_RENDER_OGL_ES -#undef SDL_VIDEO_RENDER_X11 -#undef SDL_VIDEO_RENDER_GAPI -#undef SDL_VIDEO_RENDER_DDRAW +#undef SDL_VIDEO_RENDER_DIRECTFB /* Enable OpenGL support */ #undef SDL_VIDEO_OPENGL diff --git a/project/jni/sdl-1.3/include/SDL_config_android.h b/project/jni/sdl-1.3/include/SDL_config_android.h index 10f4d522e..7e7c34462 100644 --- a/project/jni/sdl-1.3/include/SDL_config_android.h +++ b/project/jni/sdl-1.3/include/SDL_config_android.h @@ -163,6 +163,7 @@ #undef HAVE_SYSCTLBYNAME #undef SDL_ALTIVEC_BLITTERS #define SDL_ASSEMBLY_ROUTINES 1 // There is no assembly code for Arm CPU yet +#define HAVE_GCC_ATOMICS 1 /* Prototypes for Android-specific functions */ diff --git a/project/jni/sdl-1.3/include/SDL_config_iphoneos.h b/project/jni/sdl-1.3/include/SDL_config_iphoneos.h index 6e031114b..f953efef7 100644 --- a/project/jni/sdl-1.3/include/SDL_config_iphoneos.h +++ b/project/jni/sdl-1.3/include/SDL_config_iphoneos.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_config_iphoneos_h @@ -25,23 +24,13 @@ #include "SDL_platform.h" -#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) -typedef signed char int8_t; -typedef unsigned char uint8_t; -typedef signed short int16_t; -typedef unsigned short uint16_t; -typedef signed int int32_t; -typedef unsigned int uint32_t; -typedef unsigned long uintptr_t; -#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ - #ifdef __LP64__ #define SIZEOF_VOIDP 8 #else #define SIZEOF_VOIDP 4 #endif -#define SDL_HAS_64BIT_TYPE 1 +#define HAVE_GCC_ATOMICS 1 #define HAVE_ALLOCA_H 1 #define HAVE_SYS_TYPES_H 1 @@ -93,6 +82,9 @@ typedef unsigned long uintptr_t; #define HAVE_SSCANF 1 #define HAVE_SNPRINTF 1 #define HAVE_VSNPRINTF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 #define HAVE_CEIL 1 #define HAVE_COPYSIGN 1 #define HAVE_COS 1 @@ -112,7 +104,7 @@ typedef unsigned long uintptr_t; #define HAVE_SYSCTLBYNAME 1 /* enable iPhone version of Core Audio driver */ -#define SDL_AUDIO_DRIVER_COREAUDIOIPHONE 1 +#define SDL_AUDIO_DRIVER_COREAUDIO 1 /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ #define SDL_AUDIO_DRIVER_DUMMY 1 @@ -140,6 +132,7 @@ typedef unsigned long uintptr_t; /* enable OpenGL ES */ #define SDL_VIDEO_OPENGL_ES 1 #define SDL_VIDEO_RENDER_OGL_ES 1 +#define SDL_VIDEO_RENDER_OGL_ES2 1 /* Enable system power support */ #define SDL_POWER_UIKIT 1 @@ -147,6 +140,9 @@ typedef unsigned long uintptr_t; /* enable iPhone keyboard support */ #define SDL_IPHONE_KEYBOARD 1 +/* enable joystick subsystem */ +#define SDL_JOYSTICK_DISABLED 0 + /* Set max recognized G-force from accelerometer See src/joystick/uikit/SDLUIAccelerationDelegate.m for notes on why this is needed */ diff --git a/project/jni/sdl-1.3/include/SDL_config_macosx.h b/project/jni/sdl-1.3/include/SDL_config_macosx.h index 4a9f1862a..57e2f7458 100644 --- a/project/jni/sdl-1.3/include/SDL_config_macosx.h +++ b/project/jni/sdl-1.3/include/SDL_config_macosx.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_config_macosx_h @@ -36,8 +35,6 @@ #define SIZEOF_VOIDP 4 #endif -#define SDL_HAS_64BIT_TYPE 1 - /* Useful headers */ /* If we specified an SDK or have a post-PowerPC chip, then alloca.h exists. */ #if ( (MAC_OS_X_VERSION_MIN_REQUIRED >= 1030) || (!defined(__POWERPC__)) ) @@ -136,25 +133,32 @@ #define SDL_VIDEO_DRIVER_X11 1 #define SDL_VIDEO_DRIVER_X11_DYNAMIC "/usr/X11R6/lib/libX11.6.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT "/usr/X11R6/lib/libXext.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER "/usr/X11R6/lib/libXrender.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA "/usr/X11R6/lib/libXinerama.1.dylib" #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT "/usr/X11R6/lib/libXi.6.dylib" -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.6.dylib" -#define SDL_VIDEO_DRIVER_X11_VIDMODE 1 +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR "/usr/X11R6/lib/libXrandr.2.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS "/usr/X11R6/lib/libXss.1.dylib" +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE "/usr/X11R6/lib/libXxf86vm.1.dylib" #define SDL_VIDEO_DRIVER_X11_XINERAMA 1 -#define SDL_VIDEO_DRIVER_X11_XRANDR 1 #define SDL_VIDEO_DRIVER_X11_XINPUT 1 -#define SDL_VIDEO_DRIVER_X11_SCRNSAVER 1 -#define SDL_VIDEO_DRIVER_X11_XV 1 +#define SDL_VIDEO_DRIVER_X11_XRANDR 1 +#define SDL_VIDEO_DRIVER_X11_XSCRNSAVER 1 #define SDL_VIDEO_DRIVER_X11_XSHAPE 1 +#define SDL_VIDEO_DRIVER_X11_XVIDMODE 1 +#ifndef SDL_VIDEO_RENDER_OGL #define SDL_VIDEO_RENDER_OGL 1 -#define SDL_VIDEO_RENDER_X11 1 +#endif /* Enable OpenGL support */ +#ifndef SDL_VIDEO_OPENGL #define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_CGL #define SDL_VIDEO_OPENGL_CGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_GLX #define SDL_VIDEO_OPENGL_GLX 1 +#endif /* Enable system power support */ #define SDL_POWER_MACOSX 1 diff --git a/project/jni/sdl-1.3/include/SDL_config_minimal.h b/project/jni/sdl-1.3/include/SDL_config_minimal.h index c6c6d2666..2145d3ea8 100644 --- a/project/jni/sdl-1.3/include/SDL_config_minimal.h +++ b/project/jni/sdl-1.3/include/SDL_config_minimal.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_config_minimal_h @@ -31,19 +30,26 @@ * This is the minimal configuration that can be used to build SDL. */ +#include #include #if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +typedef unsigned int size_t; typedef signed char int8_t; typedef unsigned char uint8_t; typedef signed short int16_t; typedef unsigned short uint16_t; typedef signed int int32_t; typedef unsigned int uint32_t; -typedef unsigned int size_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; typedef unsigned long uintptr_t; #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ +#ifdef __GNUC__ +#define HAVE_GCC_SYNC_LOCK_TEST_AND_SET 1 +#endif + /* Enable the dummy audio driver (src/audio/dummy/\*.c) */ #define SDL_AUDIO_DRIVER_DUMMY 1 diff --git a/project/jni/sdl-1.3/include/SDL_config_nintendods.h b/project/jni/sdl-1.3/include/SDL_config_nintendods.h index be9a3105e..859e8a6bc 100644 --- a/project/jni/sdl-1.3/include/SDL_config_nintendods.h +++ b/project/jni/sdl-1.3/include/SDL_config_nintendods.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_config_nintendods_h @@ -46,7 +45,7 @@ typedef unsigned __PTRDIFF_TYPE__ uintptr_t; #endif #endif /* !_STDINT_H_ && !HAVE_STDINT_H */ -#define SDL_HAS_64BIT_TYPE 1 +#define SIZEOF_VOIDP 4 /* Useful headers */ #define HAVE_SYS_TYPES_H 1 @@ -113,9 +112,18 @@ typedef unsigned __PTRDIFF_TYPE__ uintptr_t; /* Enable various video drivers */ #define SDL_VIDEO_DRIVER_NDS 1 -/*#define SDL_VIDEO_DRIVER_DUMMY 1 TODO: uncomment this later*/ +#ifdef USE_HW_RENDERER +#define SDL_VIDEO_RENDER_NDS 1 +#else +#define SDL_VIDEO_RENDER_NDS 0 +#endif /* Enable system power support */ #define SDL_POWER_NINTENDODS 1 +/* Enable haptic support */ +#define SDL_HAPTIC_NDS 1 + +#define SDL_BYTEORDER SDL_LIL_ENDIAN + #endif /* _SDL_config_nintendods_h */ diff --git a/project/jni/sdl-1.3/include/SDL_config_pandora.h b/project/jni/sdl-1.3/include/SDL_config_pandora.h index fbdec93e1..15292fcd5 100644 --- a/project/jni/sdl-1.3/include/SDL_config_pandora.h +++ b/project/jni/sdl-1.3/include/SDL_config_pandora.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_config_h @@ -34,7 +33,6 @@ #define SIZEOF_VOIDP 4 #endif -#define SDL_HAS_64BIT_TYPE 1 #define SDL_BYTEORDER 1234 #define HAVE_ALLOCA_H 1 diff --git a/project/jni/sdl-1.3/include/SDL_config_windows.h b/project/jni/sdl-1.3/include/SDL_config_windows.h new file mode 100644 index 000000000..b980f0d1a --- /dev/null +++ b/project/jni/sdl-1.3/include/SDL_config_windows.h @@ -0,0 +1,207 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_config_windows_h +#define _SDL_config_windows_h + +#include "SDL_platform.h" + +/* This is a set of defines to configure the SDL features */ + +#if !defined(_STDINT_H_) && (!defined(HAVE_STDINT_H) || !_HAVE_STDINT_H) +#if defined(__GNUC__) || defined(__DMC__) || defined(__WATCOMC__) +#define HAVE_STDINT_H 1 +#elif defined(_MSC_VER) +typedef signed __int8 int8_t; +typedef unsigned __int8 uint8_t; +typedef signed __int16 int16_t; +typedef unsigned __int16 uint16_t; +typedef signed __int32 int32_t; +typedef unsigned __int32 uint32_t; +typedef signed __int64 int64_t; +typedef unsigned __int64 uint64_t; +#ifndef _UINTPTR_T_DEFINED +#ifdef _WIN64 +typedef unsigned __int64 uintptr_t; +#else +typedef unsigned int uintptr_t; +#endif +#define _UINTPTR_T_DEFINED +#endif +/* Older Visual C++ headers don't have the Win64-compatible typedefs... */ +#if ((_MSC_VER <= 1200) && (!defined(DWORD_PTR))) +#define DWORD_PTR DWORD +#endif +#if ((_MSC_VER <= 1200) && (!defined(LONG_PTR))) +#define LONG_PTR LONG +#endif +#else /* !__GNUC__ && !_MSC_VER */ +typedef signed char int8_t; +typedef unsigned char uint8_t; +typedef signed short int16_t; +typedef unsigned short uint16_t; +typedef signed int int32_t; +typedef unsigned int uint32_t; +typedef signed long long int64_t; +typedef unsigned long long uint64_t; +#ifndef _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED_ +typedef unsigned int size_t; +#endif +typedef unsigned int uintptr_t; +#endif /* __GNUC__ || _MSC_VER */ +#endif /* !_STDINT_H_ && !HAVE_STDINT_H */ + +#ifdef _WIN64 +# define SIZEOF_VOIDP 8 +#else +# define SIZEOF_VOIDP 4 +#endif + +/* Enabled for SDL 1.2 (binary compatibility) */ +//#define HAVE_LIBC 1 +#ifdef HAVE_LIBC +/* Useful headers */ +#define HAVE_STDIO_H 1 +#define STDC_HEADERS 1 +#define HAVE_STRING_H 1 +#define HAVE_CTYPE_H 1 +#define HAVE_MATH_H 1 +#ifndef _WIN32_WCE +#define HAVE_SIGNAL_H 1 +#endif + +/* C library functions */ +#define HAVE_MALLOC 1 +#define HAVE_CALLOC 1 +#define HAVE_REALLOC 1 +#define HAVE_FREE 1 +#define HAVE_ALLOCA 1 +#define HAVE_QSORT 1 +#define HAVE_ABS 1 +#define HAVE_MEMSET 1 +#define HAVE_MEMCPY 1 +#define HAVE_MEMMOVE 1 +#define HAVE_MEMCMP 1 +#define HAVE_STRLEN 1 +#define HAVE__STRREV 1 +#define HAVE__STRUPR 1 +#define HAVE__STRLWR 1 +#define HAVE_STRCHR 1 +#define HAVE_STRRCHR 1 +#define HAVE_STRSTR 1 +#define HAVE_ITOA 1 +#define HAVE__LTOA 1 +#define HAVE__ULTOA 1 +#define HAVE_STRTOL 1 +#define HAVE_STRTOUL 1 +#define HAVE_STRTOLL 1 +#define HAVE_STRTOD 1 +#define HAVE_ATOI 1 +#define HAVE_ATOF 1 +#define HAVE_STRCMP 1 +#define HAVE_STRNCMP 1 +#define HAVE__STRICMP 1 +#define HAVE__STRNICMP 1 +#define HAVE_SSCANF 1 +#define HAVE_M_PI 1 +#define HAVE_ATAN 1 +#define HAVE_ATAN2 1 +#define HAVE_CEIL 1 +#define HAVE_COPYSIGN 1 +#define HAVE_COS 1 +#define HAVE_COSF 1 +#define HAVE_FABS 1 +#define HAVE_FLOOR 1 +#define HAVE_LOG 1 +#define HAVE_POW 1 +#define HAVE_SCALBN 1 +#define HAVE_SIN 1 +#define HAVE_SINF 1 +#define HAVE_SQRT 1 +#else +#define HAVE_STDARG_H 1 +#define HAVE_STDDEF_H 1 +#endif + +/* Enable various audio drivers */ +#ifndef _WIN32_WCE +#define SDL_AUDIO_DRIVER_DSOUND 1 +#define SDL_AUDIO_DRIVER_XAUDIO2 1 +#endif +#define SDL_AUDIO_DRIVER_WINMM 1 +#define SDL_AUDIO_DRIVER_DISK 1 +#define SDL_AUDIO_DRIVER_DUMMY 1 + +/* Enable various input drivers */ +#ifdef _WIN32_WCE +#define SDL_JOYSTICK_DISABLED 1 +#define SDL_HAPTIC_DUMMY 1 +#else +#define SDL_JOYSTICK_DINPUT 1 +#define SDL_HAPTIC_DINPUT 1 +#endif + +/* Enable various shared object loading systems */ +#define SDL_LOADSO_WINDOWS 1 + +/* Enable various threading systems */ +#define SDL_THREAD_WINDOWS 1 + +/* Enable various timer systems */ +#ifdef _WIN32_WCE +#define SDL_TIMER_WINCE 1 +#else +#define SDL_TIMER_WINDOWS 1 +#endif + +/* Enable various video drivers */ +#define SDL_VIDEO_DRIVER_DUMMY 1 +#define SDL_VIDEO_DRIVER_WINDOWS 1 + +#ifndef _WIN32_WCE +#ifndef SDL_VIDEO_RENDER_D3D +#define SDL_VIDEO_RENDER_D3D 1 +#endif +#endif + +/* Enable OpenGL support */ +#ifndef _WIN32_WCE +#ifndef SDL_VIDEO_OPENGL +#define SDL_VIDEO_OPENGL 1 +#endif +#ifndef SDL_VIDEO_OPENGL_WGL +#define SDL_VIDEO_OPENGL_WGL 1 +#endif +#ifndef SDL_VIDEO_RENDER_OGL +#define SDL_VIDEO_RENDER_OGL 1 +#endif +#endif + +/* Enable system power support */ +#define SDL_POWER_WINDOWS 1 + +/* Enable assembly routines (Win64 doesn't have inline asm) */ +#ifndef _WIN64 +#define SDL_ASSEMBLY_ROUTINES 1 +#endif + +#endif /* _SDL_config_windows_h */ diff --git a/project/jni/sdl-1.3/include/SDL_config_wiz.h b/project/jni/sdl-1.3/include/SDL_config_wiz.h index 5cc12e37a..fa2e919ce 100644 --- a/project/jni/sdl-1.3/include/SDL_config_wiz.h +++ b/project/jni/sdl-1.3/include/SDL_config_wiz.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_config_h @@ -28,12 +27,6 @@ /* General platform specific identifiers */ #include "SDL_platform.h" -/* Make sure that this isn't included by Visual C++ */ -#ifdef _MSC_VER -#error You should copy include/SDL_config.h.default to include/SDL_config.h -#endif - -#define SDL_HAS_64BIT_TYPE 1 #define SDL_BYTEORDER 1234 #define HAVE_ALLOCA_H 1 diff --git a/project/jni/sdl-1.3/include/SDL_copying.h b/project/jni/sdl-1.3/include/SDL_copying.h index 3bd3e8dc9..91049cd7c 100644 --- a/project/jni/sdl-1.3/include/SDL_copying.h +++ b/project/jni/sdl-1.3/include/SDL_copying.h @@ -1,21 +1,20 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ diff --git a/project/jni/sdl-1.3/include/SDL_cpuinfo.h b/project/jni/sdl-1.3/include/SDL_cpuinfo.h index 0cc4998e6..7fb39edb4 100644 --- a/project/jni/sdl-1.3/include/SDL_cpuinfo.h +++ b/project/jni/sdl-1.3/include/SDL_cpuinfo.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -31,6 +30,39 @@ #include "SDL_stdinc.h" +/* Need to do this here because intrin.h has C++ code in it */ +/* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */ +#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE) +#include +#ifndef _WIN64 +#define __MMX__ +#define __3dNOW__ +#endif +#define __SSE__ +#define __SSE2__ +#elif defined(__MINGW64_VERSION_MAJOR) +#include +#else +#ifdef __ALTIVEC__ +#if HAVE_ALTIVEC_H && !defined(__APPLE_ALTIVEC__) +#include +#undef pixel +#endif +#endif +#ifdef __MMX__ +#include +#endif +#ifdef __3dNOW__ +#include +#endif +#ifdef __SSE__ +#include +#endif +#ifdef __SSE2__ +#include +#endif +#endif + #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ #ifdef __cplusplus @@ -39,36 +71,46 @@ extern "C" { /* *INDENT-ON* */ #endif +/* This is a guess for the cacheline size used for padding. + * Most x86 processors have a 64 byte cache line. + * The 64-bit PowerPC processors have a 128 byte cache line. + * We'll use the larger value to be generally safe. + */ +#define SDL_CACHELINE_SIZE 128 + /** * This function returns the number of CPU cores available. */ extern DECLSPEC int SDLCALL SDL_GetCPUCount(void); +/** + * This function returns the L1 cache line size of the CPU + * + * This is useful for determining multi-threaded structure padding + * or SIMD prefetch sizes. + */ +extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void); + /** * This function returns true if the CPU has the RDTSC instruction. */ extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void); +/** + * This function returns true if the CPU has AltiVec features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); + /** * This function returns true if the CPU has MMX features. */ extern DECLSPEC SDL_bool SDLCALL SDL_HasMMX(void); /** - * This function returns true if the CPU has MMX Ext.\ features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasMMXExt(void); - -/** - * This function returns true if the CPU has 3DNow!\ features. + * This function returns true if the CPU has 3DNow! features. */ extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNow(void); -/** - * This function returns true if the CPU has 3DNow!\ Ext.\ features. - */ -extern DECLSPEC SDL_bool SDLCALL SDL_Has3DNowExt(void); - /** * This function returns true if the CPU has SSE features. */ @@ -80,9 +122,20 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE(void); extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE2(void); /** - * This function returns true if the CPU has AltiVec features. + * This function returns true if the CPU has SSE3 features. */ -extern DECLSPEC SDL_bool SDLCALL SDL_HasAltiVec(void); +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE3(void); + +/** + * This function returns true if the CPU has SSE4.1 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE41(void); + +/** + * This function returns true if the CPU has SSE4.2 features. + */ +extern DECLSPEC SDL_bool SDLCALL SDL_HasSSE42(void); + /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/project/jni/sdl-1.3/include/SDL_endian.h b/project/jni/sdl-1.3/include/SDL_endian.h index de69e32d7..5b23e78af 100644 --- a/project/jni/sdl-1.3/include/SDL_endian.h +++ b/project/jni/sdl-1.3/include/SDL_endian.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -153,7 +152,6 @@ SDL_Swap32(Uint32 x) } #endif -#ifdef SDL_HAS_64BIT_TYPE #if defined(__GNUC__) && defined(__i386__) static __inline__ Uint64 SDL_Swap64(Uint64 x) @@ -195,14 +193,6 @@ SDL_Swap64(Uint64 x) return (x); } #endif -#else -/** - * This is mainly to keep compilers from complaining in SDL code. - * If there is no real 64-bit datatype, then compilers will complain about - * the fake 64-bit datatype that SDL provides when it compiles user code. - */ -#define SDL_Swap64(X) (X) -#endif /* SDL_HAS_64BIT_TYPE */ static __inline__ float diff --git a/project/jni/sdl-1.3/include/SDL_error.h b/project/jni/sdl-1.3/include/SDL_error.h index 5aa5c9162..d28b41665 100644 --- a/project/jni/sdl-1.3/include/SDL_error.h +++ b/project/jni/sdl-1.3/include/SDL_error.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -48,7 +47,7 @@ extern DECLSPEC void SDLCALL SDL_ClearError(void); * \name Internal error functions * * \internal - * Private error message function - used internally. + * Private error reporting function - used internally. */ /*@{*/ #define SDL_OutOfMemory() SDL_Error(SDL_ENOMEM) diff --git a/project/jni/sdl-1.3/include/SDL_events.h b/project/jni/sdl-1.3/include/SDL_events.h index 85b5078c0..13559a883 100644 --- a/project/jni/sdl-1.3/include/SDL_events.h +++ b/project/jni/sdl-1.3/include/SDL_events.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -105,9 +104,11 @@ typedef enum SDL_MULTIGESTURE, /* Clipboard events */ - SDL_CLIPBOARDUPDATE = 0x900, /**< The clipboard changed */ + /* Drag and drop events */ + SDL_DROPFILE = 0x1000, /**< The system requests a file open */ + /* Obsolete events */ SDL_EVENT_COMPAT1 = 0x7000, /**< SDL 1.2 events for compatibility */ SDL_EVENT_COMPAT2, @@ -151,7 +152,7 @@ typedef struct SDL_KeyboardEvent Uint8 repeat; /**< Non-zero if this is a key repeat */ Uint8 padding2; Uint8 padding3; - SDL_keysym keysym; /**< The key that was pressed or released */ + SDL_Keysym keysym; /**< The key that was pressed or released */ } SDL_KeyboardEvent; #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32) @@ -281,7 +282,7 @@ typedef struct SDL_JoyButtonEvent /** - * \brief Touch finger motion/finger event structure (event.tmotion.*) + * \brief Touch finger motion/finger event structure (event.tfinger.*) */ typedef struct SDL_TouchFingerEvent { @@ -303,7 +304,7 @@ typedef struct SDL_TouchFingerEvent /** - * \brief Touch finger motion/finger event structure (event.tmotion.*) + * \brief Touch finger motion/finger event structure (event.tbutton.*) */ typedef struct SDL_TouchButtonEvent { @@ -317,9 +318,8 @@ typedef struct SDL_TouchButtonEvent } SDL_TouchButtonEvent; - /** - * \brief Multiple Finger Gesture Event + * \brief Multiple Finger Gesture Event (event.mgesture.*) */ typedef struct SDL_MultiGestureEvent { @@ -334,6 +334,7 @@ typedef struct SDL_MultiGestureEvent Uint16 padding; } SDL_MultiGestureEvent; +/* (event.dgesture.*) */ typedef struct SDL_DollarGestureEvent { Uint32 type; /**< ::SDL_DOLLARGESTURE */ @@ -350,6 +351,16 @@ typedef struct SDL_DollarGestureEvent } SDL_DollarGestureEvent; +/** + * \brief An event used to request a file open by the system (event.drop.*) + * This event is disabled by default, you can enable it with SDL_EventState() + * \note If you enable this event, you must free the filename in the event. + */ +typedef struct SDL_DropEvent +{ + Uint32 type; /**< ::SDL_DROPFILE */ + char *file; /**< The file name, which should be freed with SDL_free() */ +} SDL_DropEvent; /** @@ -360,6 +371,7 @@ typedef struct SDL_QuitEvent Uint32 type; /**< ::SDL_QUIT */ } SDL_QuitEvent; + /** * \brief A user-defined event type (event.user.*) */ @@ -372,12 +384,14 @@ typedef struct SDL_UserEvent void *data2; /**< User defined data pointer */ } SDL_UserEvent; + struct SDL_SysWMmsg; typedef struct SDL_SysWMmsg SDL_SysWMmsg; /** * \brief A video driver dependent system event (event.syswm.*) - * + * This event is disabled by default, you can enable it with SDL_EventState() + * * \note If you want to use this event, you should include SDL_syswm.h. */ typedef struct SDL_SysWMEvent @@ -438,6 +452,7 @@ typedef union SDL_Event SDL_TouchButtonEvent tbutton; /**< Touch button event data */ SDL_MultiGestureEvent mgesture; /**< Multi Finger Gesture data */ SDL_DollarGestureEvent dgesture; /**< Multi Finger Gesture data */ + SDL_DropEvent drop; /**< Drag and drop event data */ /** Temporarily here for backwards compatibility */ /*@{*/ @@ -580,6 +595,18 @@ extern DECLSPEC void SDLCALL SDL_SetEventFilter(SDL_EventFilter filter, extern DECLSPEC SDL_bool SDLCALL SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata); +/** + * Add a function which is called when an event is added to the queue. + */ +extern DECLSPEC void SDLCALL SDL_AddEventWatch(SDL_EventFilter filter, + void *userdata); + +/** + * Remove an event watch function added with SDL_AddEventWatch() + */ +extern DECLSPEC void SDLCALL SDL_DelEventWatch(SDL_EventFilter filter, + void *userdata); + /** * Run the filter function on the current event queue, removing any * events for which the filter returns 0. diff --git a/project/jni/sdl-1.3/include/SDL_gesture.h b/project/jni/sdl-1.3/include/SDL_gesture.h index 78d3d4cff..940d346ce 100644 --- a/project/jni/sdl-1.3/include/SDL_gesture.h +++ b/project/jni/sdl-1.3/include/SDL_gesture.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/SDL_haptic.h b/project/jni/sdl-1.3/include/SDL_haptic.h index 52f33f152..6b354a2d1 100644 --- a/project/jni/sdl-1.3/include/SDL_haptic.h +++ b/project/jni/sdl-1.3/include/SDL_haptic.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2008 Edgar Simo + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -25,7 +24,7 @@ * * \brief The SDL Haptic subsystem allows you to control haptic (force feedback) * devices. - * + * * The basic usage is as follows: * - Initialize the Subsystem (::SDL_INIT_HAPTIC). * - Open a Haptic Device. @@ -37,7 +36,29 @@ * - (optional) Free the effect with SDL_HapticDestroyEffect(). * - Close the haptic device with SDL_HapticClose(). * - * \par Example: + * \par Simple rumble example: + * \code + * SDL_Haptic *haptic; + * + * // Open the device + * haptic = SDL_HapticOpen( 0 ); + * if (haptic == NULL) + * return -1; + * + * // Initialize simple rumble + * if (SDL_HapticRumbleInit( haptic ) != 0) + * return -1; + * + * // Play effect at 50% strength for 2 seconds + * if (SDL_HapticRumblePlay( haptic, 0.5, 2000 ) != 0) + * return -1; + * SDL_Delay( 2000 ); + * + * // Clean up + * SDL_HapticClose( haptic ); + * \endcode + * + * \par Complete example: * \code * int test_haptic( SDL_Joystick * joystick ) { * SDL_Haptic *haptic; @@ -81,6 +102,10 @@ * return 0; // Success * } * \endcode + * + * You can also find out more information on my blog: + * http://bobbens.dyndns.org/journal/2010/sdl_haptic/ + * * \author Edgar Simo Serra */ @@ -929,7 +954,7 @@ extern DECLSPEC int SDLCALL SDL_HapticNumAxes(SDL_Haptic * haptic); * * \param haptic Haptic device to check on. * \param effect Effect to check to see if it is supported. - * \return 1 if effect is supported, 0 if it isn't or -1 on error. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. * * \sa SDL_HapticQuery * \sa SDL_HapticNewEffect @@ -1109,6 +1134,58 @@ extern DECLSPEC int SDLCALL SDL_HapticUnpause(SDL_Haptic * haptic); */ extern DECLSPEC int SDLCALL SDL_HapticStopAll(SDL_Haptic * haptic); +/** + * \brief Checks to see if rumble is supported on a haptic device.. + * + * \param haptic Haptic device to check to see if it supports rumble. + * \return SDL_TRUE if effect is supported, SDL_FALSE if it isn't or -1 on error. + * + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleSupported(SDL_Haptic * haptic); + +/** + * \brief Initializes the haptic device for simple rumble playback. + * + * \param haptic Haptic device to initialize for simple rumble playback. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticOpen + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumblePlay + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleInit(SDL_Haptic * haptic); + +/** + * \brief Runs simple rumble on a haptic device + * + * \param haptic Haptic device to play rumble effect on. + * \param strength Strength of the rumble to play as a 0-1 float value. + * \param length Length of the rumble to play in miliseconds. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumbleStop + */ +extern DECLSPEC int SDLCALL SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length ); + +/** + * \brief Stops the simple rumble on a haptic device. + * + * \param haptic Haptic to stop the rumble on. + * \return 0 on success or -1 on error. + * + * \sa SDL_HapticRumbleSupported + * \sa SDL_HapticRumbleInit + * \sa SDL_HapticRumblePlay + */ +extern DECLSPEC int SDLCALL SDL_HapticRumbleStop(SDL_Haptic * haptic); + + /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/project/jni/sdl-1.3/include/SDL_hints.h b/project/jni/sdl-1.3/include/SDL_hints.h new file mode 100644 index 000000000..64323917a --- /dev/null +++ b/project/jni/sdl-1.3/include/SDL_hints.h @@ -0,0 +1,206 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_hints.h + * + * Official documentation for SDL configuration variables + * + * This file contains functions to set and get configuration hints, + * as well as listing each of them alphabetically. + * + * The convention for naming hints is SDL_HINT_X, where "SDL_X" is + * the environment variable that can be used to override the default. + * + * In general these hints are just that - they may or may not be + * supported or applicable on any given platform, but they provide + * a way for an application or user to give the library a hint as + * to how they would like the library to work. + */ + +#ifndef _SDL_hints_h +#define _SDL_hints_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/** + * \brief A variable controlling how 3D acceleration is used to accelerate the SDL 1.2 screen surface. + * + * SDL can try to accelerate the SDL 1.2 screen surface by using streaming + * textures with a 3D rendering engine. This variable controls whether and + * how this is done. + * + * This variable can be set to the following values: + * "0" - Disable 3D acceleration + * "1" - Enable 3D acceleration, using the default renderer. + * "X" - Enable 3D acceleration, using X where X is one of the valid rendering drivers. (e.g. "direct3d", "opengl", etc.) + * + * By default SDL tries to make a best guess for each platform whether + * to use acceleration or not. + */ +#define SDL_HINT_FRAMEBUFFER_ACCELERATION "SDL_FRAMEBUFFER_ACCELERATION" + +/** + * \brief A variable specifying which render driver to use. + * + * If the application doesn't pick a specific renderer to use, this variable + * specifies the name of the preferred renderer. If the preferred renderer + * can't be initialized, the normal default renderer is used. + * + * This variable is case insensitive and can be set to the following values: + * "direct3d" + * "opengl" + * "opengles2" + * "opengles" + * "software" + * + * The default varies by platform, but it's the first one in the list that + * is available on the current platform. + */ +#define SDL_HINT_RENDER_DRIVER "SDL_RENDER_DRIVER" + +/** + * \brief A variable controlling whether the OpenGL render driver uses shaders if they are available. + * + * This variable can be set to the following values: + * "0" - Disable shaders + * "1" - Enable shaders + * + * By default shaders are used if OpenGL supports them. + */ +#define SDL_HINT_RENDER_OPENGL_SHADERS "SDL_RENDER_OPENGL_SHADERS" + +/** + * \brief A variable controlling the scaling quality + * + * This variable can be set to the following values: + * "0" or "nearest" - Nearest pixel sampling + * "1" or "linear" - Linear filtering (supported by OpenGL and Direct3D) + * "2" or "best" - Anisotropic filtering (supported by Direct3D) + * + * By default nearest pixel sampling is used + */ +#define SDL_HINT_RENDER_SCALE_QUALITY "SDL_RENDER_SCALE_QUALITY" + +/** + * \brief A variable controlling whether updates to the SDL 1.2 screen surface should be synchronized with the vertical refresh, to avoid tearing. + * + * This variable can be set to the following values: + * "0" - Disable vsync + * "1" - Enable vsync + * + * By default SDL does not sync screen surface updates with vertical refresh. + */ +#define SDL_HINT_RENDER_VSYNC "SDL_RENDER_VSYNC" + +/** + * \brief A variable controlling whether the idle timer is disabled on iOS. + * + * When an iOS app does not receive touches for some time, the screen is + * dimmed automatically. For games where the accelerometer is the only input + * this is problematic. This functionality can be disabled by setting this + * hint. + * + * This variable can be set to the following values: + * "0" - Enable idle timer + * "1" - Disable idle timer + */ +#define SDL_HINT_IDLE_TIMER_DISABLED "SDL_IOS_IDLE_TIMER_DISABLED" + +/** + * \brief A variable controlling which orientations are allowed on iOS. + * + * In some circumstances it is necessary to be able to explicitly control + * which UI orientations are allowed. + * + * This variable is a space delimited list of the following values: + * "LandscapeLeft", "LandscapeRight", "Portrait" "PortraitUpsideDown" + */ +#define SDL_HINT_ORIENTATIONS "SDL_IOS_ORIENTATIONS" + + +/** + * \brief An enumeration of hint priorities + */ +typedef enum +{ + SDL_HINT_DEFAULT, + SDL_HINT_NORMAL, + SDL_HINT_OVERRIDE +} SDL_HintPriority; + + +/** + * \brief Set a hint with a specific priority + * + * The priority controls the behavior when setting a hint that already + * has a value. Hints will replace existing hints of their priority and + * lower. Environment variables are considered to have override priority. + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHintWithPriority(const char *name, + const char *value, + SDL_HintPriority priority); + +/** + * \brief Set a hint with normal priority + * + * \return SDL_TRUE if the hint was set, SDL_FALSE otherwise + */ +extern DECLSPEC SDL_bool SDLCALL SDL_SetHint(const char *name, + const char *value); + + +/** + * \brief Get a hint + * + * \return The string value of a hint variable. + */ +extern DECLSPEC const char * SDLCALL SDL_GetHint(const char *name); + +/** + * \brief Clear all hints + * + * This function is called during SDL_Quit() to free stored hints. + */ +extern DECLSPEC void SDLCALL SDL_ClearHints(void); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* _SDL_hints_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/include/SDL_input.h b/project/jni/sdl-1.3/include/SDL_input.h index 455138f1b..354d4d35e 100644 --- a/project/jni/sdl-1.3/include/SDL_input.h +++ b/project/jni/sdl-1.3/include/SDL_input.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/SDL_joystick.h b/project/jni/sdl-1.3/include/SDL_joystick.h index 2e70862ff..e83726a7e 100644 --- a/project/jni/sdl-1.3/include/SDL_joystick.h +++ b/project/jni/sdl-1.3/include/SDL_joystick.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/SDL_keyboard.h b/project/jni/sdl-1.3/include/SDL_keyboard.h index 4482ac028..1f9a66df2 100644 --- a/project/jni/sdl-1.3/include/SDL_keyboard.h +++ b/project/jni/sdl-1.3/include/SDL_keyboard.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -31,7 +30,7 @@ #include "SDL_stdinc.h" #include "SDL_error.h" -#include "SDL_keysym.h" +#include "SDL_keycode.h" #include "SDL_video.h" #include "begin_code.h" @@ -45,13 +44,13 @@ extern "C" { /** * \brief The SDL keysym structure, used in key events. */ -typedef struct SDL_keysym +typedef struct SDL_Keysym { - SDL_scancode scancode; /**< SDL physical key code - see ::SDL_scancode for details */ - SDLKey sym; /**< SDL virtual key code - see ::SDLKey for details */ + SDL_Scancode scancode; /**< SDL physical key code - see ::SDL_Scancode for details */ + SDL_Keycode sym; /**< SDL virtual key code - see ::SDL_Keycode for details */ Uint16 mod; /**< current key modifiers */ Uint32 unicode; /**< \deprecated use SDL_TextInputEvent instead */ -} SDL_keysym; +} SDL_Keysym; /* Function prototypes */ @@ -65,7 +64,7 @@ extern DECLSPEC SDL_Window * SDLCALL SDL_GetKeyboardFocus(void); * * \param numkeys if non-NULL, receives the length of the returned array. * - * \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values. + * \return An array of key states. Indexes into this array are obtained by using ::SDL_Scancode values. * * \b Example: * \code @@ -80,47 +79,54 @@ extern DECLSPEC Uint8 *SDLCALL SDL_GetKeyboardState(int *numkeys); /** * \brief Get the current key modifier state for the keyboard. */ -extern DECLSPEC SDLMod SDLCALL SDL_GetModState(void); +extern DECLSPEC SDL_Keymod SDLCALL SDL_GetModState(void); /** * \brief Set the current key modifier state for the keyboard. * * \note This does not change the keyboard state, only the key modifier flags. */ -extern DECLSPEC void SDLCALL SDL_SetModState(SDLMod modstate); +extern DECLSPEC void SDLCALL SDL_SetModState(SDL_Keymod modstate); /** * \brief Get the key code corresponding to the given scancode according * to the current keyboard layout. * - * See ::SDLKey for details. + * See ::SDL_Keycode for details. * * \sa SDL_GetKeyName() */ -extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode); +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromScancode(SDL_Scancode scancode); /** * \brief Get the scancode corresponding to the given key code according to the * current keyboard layout. * - * See ::SDL_scancode for details. + * See ::SDL_Scancode for details. * * \sa SDL_GetScancodeName() */ -extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key); +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromKey(SDL_Keycode key); /** * \brief Get a human-readable name for a scancode. * - * \return A pointer to a UTF-8 string that stays valid at least until the next - * call to this function. If you need it around any longer, you must - * copy it. If the scancode doesn't have a name, this function returns + * \return A pointer to the name for the scancode. + * If the scancode doesn't have a name, this function returns * an empty string (""). * - * \sa SDL_scancode + * \sa SDL_Scancode */ -extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode - scancode); +extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_Scancode scancode); + +/** + * \brief Get a scancode from a human-readable name + * + * \return scancode, or SDL_SCANCODE_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Scancode + */ +extern DECLSPEC SDL_Scancode SDLCALL SDL_GetScancodeFromName(const char *name); /** * \brief Get a human-readable name for a key. @@ -130,9 +136,18 @@ extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode * copy it. If the key doesn't have a name, this function returns an * empty string (""). * - * \sa SDLKey + * \sa SDL_Key */ -extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDLKey key); +extern DECLSPEC const char *SDLCALL SDL_GetKeyName(SDL_Keycode key); + +/** + * \brief Get a key code from a human-readable name + * + * \return key code, or SDLK_UNKNOWN if the name wasn't recognized + * + * \sa SDL_Keycode + */ +extern DECLSPEC SDL_Keycode SDLCALL SDL_GetKeyFromName(const char *name); /** * \brief Start accepting Unicode text input events. diff --git a/project/jni/sdl-1.3/include/SDL_keysym.h b/project/jni/sdl-1.3/include/SDL_keycode.h similarity index 92% rename from project/jni/sdl-1.3/include/SDL_keysym.h rename to project/jni/sdl-1.3/include/SDL_keycode.h index 77ff77281..5be1f7157 100644 --- a/project/jni/sdl-1.3/include/SDL_keysym.h +++ b/project/jni/sdl-1.3/include/SDL_keycode.h @@ -1,33 +1,32 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** - * \file SDL_keysym.h + * \file SDL_keycode.h * * Defines constants which identify keyboard keys and modifiers. */ -#ifndef _SDL_keysym_h -#define _SDL_keysym_h +#ifndef _SDL_keycode_h +#define _SDL_keycode_h #include "SDL_stdinc.h" #include "SDL_scancode.h" @@ -40,7 +39,7 @@ * the unmodified character that would be generated by pressing the key, or * an SDLK_* constant for those keys that do not generate characters. */ -typedef Sint32 SDLKey; +typedef Sint32 SDL_Keycode; #define SDLK_SCANCODE_MASK (1<<30) #define SDL_SCANCODE_TO_KEYCODE(X) (X | SDLK_SCANCODE_MASK) @@ -330,13 +329,13 @@ typedef enum KMOD_CAPS = 0x2000, KMOD_MODE = 0x4000, KMOD_RESERVED = 0x8000 -} SDLMod; +} SDL_Keymod; #define KMOD_CTRL (KMOD_LCTRL|KMOD_RCTRL) #define KMOD_SHIFT (KMOD_LSHIFT|KMOD_RSHIFT) #define KMOD_ALT (KMOD_LALT|KMOD_RALT) #define KMOD_GUI (KMOD_LGUI|KMOD_RGUI) -#endif /* _SDL_keysym_h */ +#endif /* _SDL_keycode_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/include/SDL_loadso.h b/project/jni/sdl-1.3/include/SDL_loadso.h index f22d8dd7f..821ca2d7d 100644 --- a/project/jni/sdl-1.3/include/SDL_loadso.h +++ b/project/jni/sdl-1.3/include/SDL_loadso.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/SDL_log.h b/project/jni/sdl-1.3/include/SDL_log.h new file mode 100644 index 000000000..cd7358418 --- /dev/null +++ b/project/jni/sdl-1.3/include/SDL_log.h @@ -0,0 +1,211 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_log.h + * + * Simple log messages with categories and priorities. + * + * By default logs are quiet, but if you're debugging SDL you might want: + * + * SDL_LogSetAllPriority(SDL_LOG_PRIORITY_WARN); + * + * Here's where the messages go on different platforms: + * Windows: debug output stream + * Android: log output + * Others: standard error output (stderr) + */ + +#ifndef _SDL_log_h +#define _SDL_log_h + +#include "SDL_stdinc.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + + +/** + * \brief The maximum size of a log message + * + * Messages longer than the maximum size will be truncated + */ +#define SDL_MAX_LOG_MESSAGE 4096 + +/** + * \brief The predefined log categories + * + * By default the application category is enabled at the INFO level, + * and all other categories are enabled at the CRITICAL level. + */ +enum +{ + SDL_LOG_CATEGORY_APPLICATION, + SDL_LOG_CATEGORY_ERROR, + SDL_LOG_CATEGORY_SYSTEM, + SDL_LOG_CATEGORY_AUDIO, + SDL_LOG_CATEGORY_VIDEO, + SDL_LOG_CATEGORY_RENDER, + SDL_LOG_CATEGORY_INPUT, + + /* Reserved for future SDL library use */ + SDL_LOG_CATEGORY_RESERVED1, + SDL_LOG_CATEGORY_RESERVED2, + SDL_LOG_CATEGORY_RESERVED3, + SDL_LOG_CATEGORY_RESERVED4, + SDL_LOG_CATEGORY_RESERVED5, + SDL_LOG_CATEGORY_RESERVED6, + SDL_LOG_CATEGORY_RESERVED7, + SDL_LOG_CATEGORY_RESERVED8, + SDL_LOG_CATEGORY_RESERVED9, + SDL_LOG_CATEGORY_RESERVED10, + + /* Beyond this point is reserved for application use, e.g. + enum { + MYAPP_CATEGORY_AWESOME1 = SDL_LOG_CATEGORY_CUSTOM, + MYAPP_CATEGORY_AWESOME2, + MYAPP_CATEGORY_AWESOME3, + ... + }; + */ + SDL_LOG_CATEGORY_CUSTOM +}; + +/** + * \brief The predefined log priorities + */ +typedef enum +{ + SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_NUM_LOG_PRIORITIES +} SDL_LogPriority; + + +/** + * \brief Set the priority of all log categories + */ +extern DECLSPEC void SDLCALL SDL_LogSetAllPriority(SDL_LogPriority priority); + +/** + * \brief Set the priority of a particular log category + */ +extern DECLSPEC void SDLCALL SDL_LogSetPriority(int category, + SDL_LogPriority priority); + +/** + * \brief Get the priority of a particular log category + */ +extern DECLSPEC SDL_LogPriority SDLCALL SDL_LogGetPriority(int category); + +/** + * \brief Reset all priorities to default. + * + * \note This is called in SDL_Quit(). + */ +extern DECLSPEC void SDLCALL SDL_LogResetPriorities(void); + +/** + * \brief Log a message with SDL_LOG_CATEGORY_APPLICATION and SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_Log(const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_VERBOSE + */ +extern DECLSPEC void SDLCALL SDL_LogVerbose(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_DEBUG + */ +extern DECLSPEC void SDLCALL SDL_LogDebug(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_INFO + */ +extern DECLSPEC void SDLCALL SDL_LogInfo(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_WARN + */ +extern DECLSPEC void SDLCALL SDL_LogWarn(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_ERROR + */ +extern DECLSPEC void SDLCALL SDL_LogError(int category, const char *fmt, ...); + +/** + * \brief Log a message with SDL_LOG_PRIORITY_CRITICAL + */ +extern DECLSPEC void SDLCALL SDL_LogCritical(int category, const char *fmt, ...); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessage(int category, + SDL_LogPriority priority, + const char *fmt, ...); + +/** + * \brief Log a message with the specified category and priority. + */ +extern DECLSPEC void SDLCALL SDL_LogMessageV(int category, + SDL_LogPriority priority, + const char *fmt, va_list ap); + +/** + * \brief The prototype for the log output function + */ +typedef void (*SDL_LogOutputFunction)(void *userdata, int category, SDL_LogPriority priority, const char *message); + +/** + * \brief Get the current log output function. + */ +extern DECLSPEC void SDLCALL SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata); + +/** + * \brief This function allows you to replace the default log output + * function with one of your own. + */ +extern DECLSPEC void SDLCALL SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* _SDL_log_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/include/SDL_main.h b/project/jni/sdl-1.3/include/SDL_main.h index 06b0ffe37..905fd53fb 100644 --- a/project/jni/sdl-1.3/include/SDL_main.h +++ b/project/jni/sdl-1.3/include/SDL_main.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_main_h @@ -31,10 +30,11 @@ * Redefine main() on some platforms so that it is called by SDL. */ -#if defined(__WIN32__) || \ - (defined(__MWERKS__) && !defined(__BEOS__)) || \ - defined(__SYMBIAN32__) || defined(__IPHONEOS__) || \ - defined(ANDROID) +#if defined(__WIN32__) || defined(__IPHONEOS__) || defined(__ANDROID__) +#ifndef SDL_MAIN_HANDLED +#define SDL_MAIN_NEEDED +#endif +#endif #ifdef __cplusplus #define C_LINKAGE "C" @@ -57,7 +57,9 @@ * \endcode */ +#ifdef SDL_MAIN_NEEDED #define main SDL_main +#endif /** * The prototype for the application's main() function @@ -65,9 +67,6 @@ extern C_LINKAGE int SDL_main(int argc, char *argv[]); -/* From the SDL library code -- needed for registering the app on Win32 */ -#ifdef __WIN32__ - #include "begin_code.h" #ifdef __cplusplus /* *INDENT-OFF* */ @@ -75,6 +74,8 @@ extern "C" { /* *INDENT-ON* */ #endif +#ifdef __WIN32__ + /** * This can be called to set the application class at startup */ @@ -82,15 +83,15 @@ extern DECLSPEC int SDLCALL SDL_RegisterApp(char *name, Uint32 style, void *hInst); extern DECLSPEC void SDLCALL SDL_UnregisterApp(void); +#endif /* __WIN32__ */ + + #ifdef __cplusplus /* *INDENT-OFF* */ } /* *INDENT-ON* */ #endif #include "close_code.h" -#endif - -#endif /* Need to redefine main()? */ #endif /* _SDL_main_h */ diff --git a/project/jni/sdl-1.3/include/SDL_mouse.h b/project/jni/sdl-1.3/include/SDL_mouse.h index cb3cd9ccf..de7d14149 100644 --- a/project/jni/sdl-1.3/include/SDL_mouse.h +++ b/project/jni/sdl-1.3/include/SDL_mouse.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -146,6 +145,15 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateCursor(const Uint8 * data, int w, int h, int hot_x, int hot_y); +/** + * \brief Create a color cursor. + * + * \sa SDL_FreeCursor() + */ +extern DECLSPEC SDL_Cursor *SDLCALL SDL_CreateColorCursor(SDL_Surface *surface, + int hot_x, + int hot_y); + /** * \brief Set the active cursor. */ diff --git a/project/jni/sdl-1.3/include/SDL_mutex.h b/project/jni/sdl-1.3/include/SDL_mutex.h index e066f944b..0e8726702 100644 --- a/project/jni/sdl-1.3/include/SDL_mutex.h +++ b/project/jni/sdl-1.3/include/SDL_mutex.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_mutex_h @@ -164,6 +163,31 @@ typedef struct SDL_cond SDL_cond; /** * Create a condition variable. + * + * Typical use of condition variables: + * + * Thread A: + * SDL_LockMutex(lock); + * while ( ! condition ) { + * SDL_CondWait(cond, lock); + * } + * SDL_UnlockMutex(lock); + * + * Thread B: + * SDL_LockMutex(lock); + * ... + * condition = true; + * ... + * SDL_CondSignal(cond); + * SDL_UnlockMutex(lock); + * + * There is some discussion whether to signal the condition variable + * with the mutex locked or not. There is some potential performance + * benefit to unlocking first on some platforms, but there are some + * potential race conditions depending on how your code is structured. + * + * In general it's safer to signal the condition variable while the + * mutex is locked. */ extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void); @@ -181,6 +205,7 @@ extern DECLSPEC int SDLCALL SDL_CondSignal(SDL_cond * cond); /** * Restart all threads that are waiting on the condition variable. + * * \return 0 or -1 on error. */ extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond); diff --git a/project/jni/sdl-1.3/include/SDL_opengl.h b/project/jni/sdl-1.3/include/SDL_opengl.h index b7589468b..fad97447b 100644 --- a/project/jni/sdl-1.3/include/SDL_opengl.h +++ b/project/jni/sdl-1.3/include/SDL_opengl.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -31,6 +30,8 @@ #include "SDL_config.h" +#ifndef __IPHONEOS__ + #ifdef __WIN32__ #define WIN32_LEAN_AND_MEAN #ifndef NOMINMAX @@ -38,6 +39,11 @@ #endif #include #endif + +#ifdef __HAIKU__ /* !!! FIXME: temp compiler warning fix... */ +#define NO_SDL_GLEXT 1 +#endif + #ifdef __glext_h_ /* Someone has already included glext.h */ #define NO_SDL_GLEXT @@ -47,11 +53,9 @@ #endif #if defined(__MACOSX__) #include /* Header File For The OpenGL Library */ -#include /* Header File For The GLU Library */ #define __X_GL_H #else #include /* Header File For The OpenGL Library */ -#include /* Header File For The GLU Library */ #endif #ifndef NO_SDL_GLEXT #undef __glext_h_ @@ -5108,21 +5112,35 @@ typedef char GLchar; #ifndef GL_VERSION_1_5 /* GL types for handling large vertex buffer objects */ +#if defined(__APPLE__) +typedef long GLintptr; +typedef long GLsizeiptr; +#else typedef ptrdiff_t GLintptr; typedef ptrdiff_t GLsizeiptr; #endif +#endif #ifndef GL_ARB_vertex_buffer_object /* GL types for handling large vertex buffer objects */ +#if defined(__APPLE__) +typedef long GLintptrARB; +typedef long GLsizeiptrARB; +#else typedef ptrdiff_t GLintptrARB; typedef ptrdiff_t GLsizeiptrARB; #endif +#endif #ifndef GL_ARB_shader_objects /* GL types for program/shader text and shader object handles */ typedef char GLcharARB; +#if defined(__APPLE__) +typedef void *GLhandleARB; +#else typedef unsigned int GLhandleARB; #endif +#endif /* GL type for "half" precision (s10e5) float data in host memory */ #ifndef GL_ARB_half_float_pixel @@ -11107,6 +11125,8 @@ typedef void (APIENTRYP PFNGLVDPAUUNMAPSURFACESNVPROC) (GLsizei numSurface, cons /* *INDENT-ON* */ #endif /* NO_SDL_GLEXT */ +#endif /* !__IPHONEOS__ */ + #endif /* _SDL_opengl_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/include/SDL_opengles.h b/project/jni/sdl-1.3/include/SDL_opengles.h index d685a8b3b..a2bb64bda 100644 --- a/project/jni/sdl-1.3/include/SDL_opengles.h +++ b/project/jni/sdl-1.3/include/SDL_opengles.h @@ -1,1039 +1,38 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - */ + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ /** * \file SDL_opengles.h * - * This is a simple file to encapsulate the OpenGL ES API headers. - * - * Headers copied from The Kronos Group website. - * http://www.khronos.org/opengles/ + * This is a simple file to encapsulate the OpenGL ES 1.X API headers. */ -#ifndef __gles_h_ -#define __gles_h_ - -/* $Id: gl.h 4533 2007-11-26 11:19:35Z markc $ */ - -#ifdef __cplusplus -extern "C" -{ -#endif - #ifdef __IPHONEOS__ -#include /* Header File For The OpenGL ES Library */ +#include +#include +#else +#include +#include #endif #ifndef APIENTRY #define APIENTRY #endif - -#ifndef GL_APIENTRY -#define GL_APIENTRY -#endif - -#ifndef GL_API -#define GL_API -#endif /* GL_API */ - -/* -** License Applicability. Except to the extent portions of this file are -** made subject to an alternative license as permitted in the SGI Free -** Software License B, Version 1.0 (the "License"), the contents of this -** file are subject only to the provisions of the License. You may not use -** this file except in compliance with the License. You may obtain a copy -** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600 -** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at: -** -** http://oss.sgi.com/projects/FreeB -** -** Note that, as provided in the License, the Software is distributed on an -** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS -** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND -** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A -** PARTICULAR PURPOSE, AND NON-INFRINGEMENT. -** -** Original Code. The Original Code is: OpenGL Sample Implementation, -** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics, -** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc. -** Copyright in any portions created by third parties is as indicated -** elsewhere herein. All Rights Reserved. -** -** Additional Notice Provisions: The application programming interfaces -** established by SGI in conjunction with the Original Code are The -** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released -** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version -** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X -** Window System(R) (Version 1.3), released October 19, 1998. This software -** was created using the OpenGL(R) version 1.2.1 Sample Implementation -** published by SGI, but has not been independently verified as being -** compliant with the OpenGL(R) version 1.2.1 Specification. -*/ - - typedef unsigned int GLenum; - typedef unsigned char GLboolean; - typedef unsigned int GLbitfield; - typedef signed char GLbyte; - typedef short GLshort; - typedef int GLint; - typedef int GLsizei; - typedef unsigned char GLubyte; - typedef unsigned short GLushort; - typedef unsigned int GLuint; - typedef float GLfloat; - typedef float GLclampf; - typedef void GLvoid; - typedef int GLfixed; - typedef int GLclampx; - - typedef int GLintptr; - typedef int GLsizeiptr; - - -/*************************************************************/ - -/* OpenGL ES core versions */ -#define GL_VERSION_ES_CM_1_0 1 -#define GL_VERSION_ES_CL_1_0 1 -#define GL_VERSION_ES_CM_1_1 1 -#define GL_VERSION_ES_CL_1_1 1 - -/* ClearBufferMask */ -#define GL_DEPTH_BUFFER_BIT 0x00000100 -#define GL_STENCIL_BUFFER_BIT 0x00000400 -#define GL_COLOR_BUFFER_BIT 0x00004000 - -/* Boolean */ -#define GL_FALSE 0 -#define GL_TRUE 1 - -/* BeginMode */ -#define GL_POINTS 0x0000 -#define GL_LINES 0x0001 -#define GL_LINE_LOOP 0x0002 -#define GL_LINE_STRIP 0x0003 -#define GL_TRIANGLES 0x0004 -#define GL_TRIANGLE_STRIP 0x0005 -#define GL_TRIANGLE_FAN 0x0006 - -/* AlphaFunction */ -#define GL_NEVER 0x0200 -#define GL_LESS 0x0201 -#define GL_EQUAL 0x0202 -#define GL_LEQUAL 0x0203 -#define GL_GREATER 0x0204 -#define GL_NOTEQUAL 0x0205 -#define GL_GEQUAL 0x0206 -#define GL_ALWAYS 0x0207 - -/* BlendingFactorDest */ -#define GL_ZERO 0 -#define GL_ONE 1 -#define GL_SRC_COLOR 0x0300 -#define GL_ONE_MINUS_SRC_COLOR 0x0301 -#define GL_SRC_ALPHA 0x0302 -#define GL_ONE_MINUS_SRC_ALPHA 0x0303 -#define GL_DST_ALPHA 0x0304 -#define GL_ONE_MINUS_DST_ALPHA 0x0305 - -/* BlendingFactorSrc */ -/* GL_ZERO */ -/* GL_ONE */ -#define GL_DST_COLOR 0x0306 -#define GL_ONE_MINUS_DST_COLOR 0x0307 -#define GL_SRC_ALPHA_SATURATE 0x0308 -/* GL_SRC_ALPHA */ -/* GL_ONE_MINUS_SRC_ALPHA */ -/* GL_DST_ALPHA */ -/* GL_ONE_MINUS_DST_ALPHA */ - -/* ClipPlaneName */ -#define GL_CLIP_PLANE0 0x3000 -#define GL_CLIP_PLANE1 0x3001 -#define GL_CLIP_PLANE2 0x3002 -#define GL_CLIP_PLANE3 0x3003 -#define GL_CLIP_PLANE4 0x3004 -#define GL_CLIP_PLANE5 0x3005 - -/* ColorMaterialFace */ -/* GL_FRONT_AND_BACK */ - -/* ColorMaterialParameter */ -/* GL_AMBIENT_AND_DIFFUSE */ - -/* ColorPointerType */ -/* GL_UNSIGNED_BYTE */ -/* GL_FLOAT */ -/* GL_FIXED */ - -/* CullFaceMode */ -#define GL_FRONT 0x0404 -#define GL_BACK 0x0405 -#define GL_FRONT_AND_BACK 0x0408 - -/* DepthFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* EnableCap */ -#define GL_FOG 0x0B60 -#define GL_LIGHTING 0x0B50 -#define GL_TEXTURE_2D 0x0DE1 -#define GL_CULL_FACE 0x0B44 -#define GL_ALPHA_TEST 0x0BC0 -#define GL_BLEND 0x0BE2 -#define GL_COLOR_LOGIC_OP 0x0BF2 -#define GL_DITHER 0x0BD0 -#define GL_STENCIL_TEST 0x0B90 -#define GL_DEPTH_TEST 0x0B71 -/* GL_LIGHT0 */ -/* GL_LIGHT1 */ -/* GL_LIGHT2 */ -/* GL_LIGHT3 */ -/* GL_LIGHT4 */ -/* GL_LIGHT5 */ -/* GL_LIGHT6 */ -/* GL_LIGHT7 */ -#define GL_POINT_SMOOTH 0x0B10 -#define GL_LINE_SMOOTH 0x0B20 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_COLOR_MATERIAL 0x0B57 -#define GL_NORMALIZE 0x0BA1 -#define GL_RESCALE_NORMAL 0x803A -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_VERTEX_ARRAY 0x8074 -#define GL_NORMAL_ARRAY 0x8075 -#define GL_COLOR_ARRAY 0x8076 -#define GL_TEXTURE_COORD_ARRAY 0x8078 -#define GL_MULTISAMPLE 0x809D -#define GL_SAMPLE_ALPHA_TO_COVERAGE 0x809E -#define GL_SAMPLE_ALPHA_TO_ONE 0x809F -#define GL_SAMPLE_COVERAGE 0x80A0 - -/* ErrorCode */ -#define GL_NO_ERROR 0 -#define GL_INVALID_ENUM 0x0500 -#define GL_INVALID_VALUE 0x0501 -#define GL_INVALID_OPERATION 0x0502 -#define GL_STACK_OVERFLOW 0x0503 -#define GL_STACK_UNDERFLOW 0x0504 -#define GL_OUT_OF_MEMORY 0x0505 - -/* FogMode */ -/* GL_LINEAR */ -#define GL_EXP 0x0800 -#define GL_EXP2 0x0801 - -/* FogParameter */ -#define GL_FOG_DENSITY 0x0B62 -#define GL_FOG_START 0x0B63 -#define GL_FOG_END 0x0B64 -#define GL_FOG_MODE 0x0B65 -#define GL_FOG_COLOR 0x0B66 - -/* FrontFaceDirection */ -#define GL_CW 0x0900 -#define GL_CCW 0x0901 - -/* GetPName */ -#define GL_CURRENT_COLOR 0x0B00 -#define GL_CURRENT_NORMAL 0x0B02 -#define GL_CURRENT_TEXTURE_COORDS 0x0B03 -#define GL_POINT_SIZE 0x0B11 -#define GL_POINT_SIZE_MIN 0x8126 -#define GL_POINT_SIZE_MAX 0x8127 -#define GL_POINT_FADE_THRESHOLD_SIZE 0x8128 -#define GL_POINT_DISTANCE_ATTENUATION 0x8129 -#define GL_SMOOTH_POINT_SIZE_RANGE 0x0B12 -#define GL_LINE_WIDTH 0x0B21 -#define GL_SMOOTH_LINE_WIDTH_RANGE 0x0B22 -#define GL_ALIASED_POINT_SIZE_RANGE 0x846D -#define GL_ALIASED_LINE_WIDTH_RANGE 0x846E -#define GL_CULL_FACE_MODE 0x0B45 -#define GL_FRONT_FACE 0x0B46 -#define GL_SHADE_MODEL 0x0B54 -#define GL_DEPTH_RANGE 0x0B70 -#define GL_DEPTH_WRITEMASK 0x0B72 -#define GL_DEPTH_CLEAR_VALUE 0x0B73 -#define GL_DEPTH_FUNC 0x0B74 -#define GL_STENCIL_CLEAR_VALUE 0x0B91 -#define GL_STENCIL_FUNC 0x0B92 -#define GL_STENCIL_VALUE_MASK 0x0B93 -#define GL_STENCIL_FAIL 0x0B94 -#define GL_STENCIL_PASS_DEPTH_FAIL 0x0B95 -#define GL_STENCIL_PASS_DEPTH_PASS 0x0B96 -#define GL_STENCIL_REF 0x0B97 -#define GL_STENCIL_WRITEMASK 0x0B98 -#define GL_MATRIX_MODE 0x0BA0 -#define GL_VIEWPORT 0x0BA2 -#define GL_MODELVIEW_STACK_DEPTH 0x0BA3 -#define GL_PROJECTION_STACK_DEPTH 0x0BA4 -#define GL_TEXTURE_STACK_DEPTH 0x0BA5 -#define GL_MODELVIEW_MATRIX 0x0BA6 -#define GL_PROJECTION_MATRIX 0x0BA7 -#define GL_TEXTURE_MATRIX 0x0BA8 -#define GL_ALPHA_TEST_FUNC 0x0BC1 -#define GL_ALPHA_TEST_REF 0x0BC2 -#define GL_BLEND_DST 0x0BE0 -#define GL_BLEND_SRC 0x0BE1 -#define GL_LOGIC_OP_MODE 0x0BF0 -#define GL_SCISSOR_BOX 0x0C10 -#define GL_SCISSOR_TEST 0x0C11 -#define GL_COLOR_CLEAR_VALUE 0x0C22 -#define GL_COLOR_WRITEMASK 0x0C23 -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 -#define GL_MAX_LIGHTS 0x0D31 -#define GL_MAX_CLIP_PLANES 0x0D32 -#define GL_MAX_TEXTURE_SIZE 0x0D33 -#define GL_MAX_MODELVIEW_STACK_DEPTH 0x0D36 -#define GL_MAX_PROJECTION_STACK_DEPTH 0x0D38 -#define GL_MAX_TEXTURE_STACK_DEPTH 0x0D39 -#define GL_MAX_VIEWPORT_DIMS 0x0D3A -#define GL_MAX_TEXTURE_UNITS 0x84E2 -#define GL_SUBPIXEL_BITS 0x0D50 -#define GL_RED_BITS 0x0D52 -#define GL_GREEN_BITS 0x0D53 -#define GL_BLUE_BITS 0x0D54 -#define GL_ALPHA_BITS 0x0D55 -#define GL_DEPTH_BITS 0x0D56 -#define GL_STENCIL_BITS 0x0D57 -#define GL_POLYGON_OFFSET_UNITS 0x2A00 -#define GL_POLYGON_OFFSET_FILL 0x8037 -#define GL_POLYGON_OFFSET_FACTOR 0x8038 -#define GL_TEXTURE_BINDING_2D 0x8069 -#define GL_VERTEX_ARRAY_SIZE 0x807A -#define GL_VERTEX_ARRAY_TYPE 0x807B -#define GL_VERTEX_ARRAY_STRIDE 0x807C -#define GL_NORMAL_ARRAY_TYPE 0x807E -#define GL_NORMAL_ARRAY_STRIDE 0x807F -#define GL_COLOR_ARRAY_SIZE 0x8081 -#define GL_COLOR_ARRAY_TYPE 0x8082 -#define GL_COLOR_ARRAY_STRIDE 0x8083 -#define GL_TEXTURE_COORD_ARRAY_SIZE 0x8088 -#define GL_TEXTURE_COORD_ARRAY_TYPE 0x8089 -#define GL_TEXTURE_COORD_ARRAY_STRIDE 0x808A -#define GL_VERTEX_ARRAY_POINTER 0x808E -#define GL_NORMAL_ARRAY_POINTER 0x808F -#define GL_COLOR_ARRAY_POINTER 0x8090 -#define GL_TEXTURE_COORD_ARRAY_POINTER 0x8092 -#define GL_SAMPLE_BUFFERS 0x80A8 -#define GL_SAMPLES 0x80A9 -#define GL_SAMPLE_COVERAGE_VALUE 0x80AA -#define GL_SAMPLE_COVERAGE_INVERT 0x80AB - -/* OpenGL ES 1.0 defines, they gone in 1.1 and 2.0 */ -#ifndef GL_MAX_ELEMENTS_VERTICES -#define GL_MAX_ELEMENTS_VERTICES 0x80E8 -#endif /* GL_MAX_ELEMENTS_VERTICES */ -#ifndef GL_MAX_ELEMENTS_INDICES -#define GL_MAX_ELEMENTS_INDICES 0x80E9 -#endif /* GL_MAX_ELEMENTS_INDICES */ - -/* GetTextureParameter */ -/* GL_TEXTURE_MAG_FILTER */ -/* GL_TEXTURE_MIN_FILTER */ -/* GL_TEXTURE_WRAP_S */ -/* GL_TEXTURE_WRAP_T */ - -#define GL_NUM_COMPRESSED_TEXTURE_FORMATS 0x86A2 -#define GL_COMPRESSED_TEXTURE_FORMATS 0x86A3 - -/* HintMode */ -#define GL_DONT_CARE 0x1100 -#define GL_FASTEST 0x1101 -#define GL_NICEST 0x1102 - -/* HintTarget */ -#define GL_PERSPECTIVE_CORRECTION_HINT 0x0C50 -#define GL_POINT_SMOOTH_HINT 0x0C51 -#define GL_LINE_SMOOTH_HINT 0x0C52 -#define GL_FOG_HINT 0x0C54 -#define GL_GENERATE_MIPMAP_HINT 0x8192 - -/* LightModelParameter */ -#define GL_LIGHT_MODEL_AMBIENT 0x0B53 -#define GL_LIGHT_MODEL_TWO_SIDE 0x0B52 - -/* LightParameter */ -#define GL_AMBIENT 0x1200 -#define GL_DIFFUSE 0x1201 -#define GL_SPECULAR 0x1202 -#define GL_POSITION 0x1203 -#define GL_SPOT_DIRECTION 0x1204 -#define GL_SPOT_EXPONENT 0x1205 -#define GL_SPOT_CUTOFF 0x1206 -#define GL_CONSTANT_ATTENUATION 0x1207 -#define GL_LINEAR_ATTENUATION 0x1208 -#define GL_QUADRATIC_ATTENUATION 0x1209 - -/* DataType */ -#define GL_BYTE 0x1400 -#define GL_UNSIGNED_BYTE 0x1401 -#define GL_SHORT 0x1402 -#define GL_UNSIGNED_SHORT 0x1403 -#define GL_FLOAT 0x1406 -#define GL_FIXED 0x140C - -/* LogicOp */ -#define GL_CLEAR 0x1500 -#define GL_AND 0x1501 -#define GL_AND_REVERSE 0x1502 -#define GL_COPY 0x1503 -#define GL_AND_INVERTED 0x1504 -#define GL_NOOP 0x1505 -#define GL_XOR 0x1506 -#define GL_OR 0x1507 -#define GL_NOR 0x1508 -#define GL_EQUIV 0x1509 -#define GL_INVERT 0x150A -#define GL_OR_REVERSE 0x150B -#define GL_COPY_INVERTED 0x150C -#define GL_OR_INVERTED 0x150D -#define GL_NAND 0x150E -#define GL_SET 0x150F - -/* MaterialFace */ -/* GL_FRONT_AND_BACK */ - -/* MaterialParameter */ -#define GL_EMISSION 0x1600 -#define GL_SHININESS 0x1601 -#define GL_AMBIENT_AND_DIFFUSE 0x1602 -/* GL_AMBIENT */ -/* GL_DIFFUSE */ -/* GL_SPECULAR */ - -/* MatrixMode */ -#define GL_MODELVIEW 0x1700 -#define GL_PROJECTION 0x1701 -#define GL_TEXTURE 0x1702 - -/* NormalPointerType */ -/* GL_BYTE */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ - -/* PixelFormat */ -#define GL_ALPHA 0x1906 -#define GL_RGB 0x1907 -#define GL_RGBA 0x1908 -#define GL_LUMINANCE 0x1909 -#define GL_LUMINANCE_ALPHA 0x190A - -/* PixelStoreParameter */ -#define GL_UNPACK_ALIGNMENT 0x0CF5 -#define GL_PACK_ALIGNMENT 0x0D05 - -/* PixelType */ -/* GL_UNSIGNED_BYTE */ -#define GL_UNSIGNED_SHORT_4_4_4_4 0x8033 -#define GL_UNSIGNED_SHORT_5_5_5_1 0x8034 -#define GL_UNSIGNED_SHORT_5_6_5 0x8363 - -/* ShadingModel */ -#define GL_FLAT 0x1D00 -#define GL_SMOOTH 0x1D01 - -/* StencilFunction */ -/* GL_NEVER */ -/* GL_LESS */ -/* GL_EQUAL */ -/* GL_LEQUAL */ -/* GL_GREATER */ -/* GL_NOTEQUAL */ -/* GL_GEQUAL */ -/* GL_ALWAYS */ - -/* StencilOp */ -/* GL_ZERO */ -#define GL_KEEP 0x1E00 -#define GL_REPLACE 0x1E01 -#define GL_INCR 0x1E02 -#define GL_DECR 0x1E03 -/* GL_INVERT */ - -/* StringName */ -#define GL_VENDOR 0x1F00 -#define GL_RENDERER 0x1F01 -#define GL_VERSION 0x1F02 -#define GL_EXTENSIONS 0x1F03 - -/* TexCoordPointerType */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ -/* GL_BYTE */ - -/* TextureEnvMode */ -#define GL_MODULATE 0x2100 -#define GL_DECAL 0x2101 -/* GL_BLEND */ -#define GL_ADD 0x0104 -/* GL_REPLACE */ - -/* TextureEnvParameter */ -#define GL_TEXTURE_ENV_MODE 0x2200 -#define GL_TEXTURE_ENV_COLOR 0x2201 - -/* TextureEnvTarget */ -#define GL_TEXTURE_ENV 0x2300 - -/* TextureMagFilter */ -#define GL_NEAREST 0x2600 -#define GL_LINEAR 0x2601 - -/* TextureMinFilter */ -/* GL_NEAREST */ -/* GL_LINEAR */ -#define GL_NEAREST_MIPMAP_NEAREST 0x2700 -#define GL_LINEAR_MIPMAP_NEAREST 0x2701 -#define GL_NEAREST_MIPMAP_LINEAR 0x2702 -#define GL_LINEAR_MIPMAP_LINEAR 0x2703 - -/* TextureParameterName */ -#define GL_TEXTURE_MAG_FILTER 0x2800 -#define GL_TEXTURE_MIN_FILTER 0x2801 -#define GL_TEXTURE_WRAP_S 0x2802 -#define GL_TEXTURE_WRAP_T 0x2803 -#define GL_GENERATE_MIPMAP 0x8191 - -/* TextureTarget */ -/* GL_TEXTURE_2D */ - -/* TextureUnit */ -#define GL_TEXTURE0 0x84C0 -#define GL_TEXTURE1 0x84C1 -#define GL_TEXTURE2 0x84C2 -#define GL_TEXTURE3 0x84C3 -#define GL_TEXTURE4 0x84C4 -#define GL_TEXTURE5 0x84C5 -#define GL_TEXTURE6 0x84C6 -#define GL_TEXTURE7 0x84C7 -#define GL_TEXTURE8 0x84C8 -#define GL_TEXTURE9 0x84C9 -#define GL_TEXTURE10 0x84CA -#define GL_TEXTURE11 0x84CB -#define GL_TEXTURE12 0x84CC -#define GL_TEXTURE13 0x84CD -#define GL_TEXTURE14 0x84CE -#define GL_TEXTURE15 0x84CF -#define GL_TEXTURE16 0x84D0 -#define GL_TEXTURE17 0x84D1 -#define GL_TEXTURE18 0x84D2 -#define GL_TEXTURE19 0x84D3 -#define GL_TEXTURE20 0x84D4 -#define GL_TEXTURE21 0x84D5 -#define GL_TEXTURE22 0x84D6 -#define GL_TEXTURE23 0x84D7 -#define GL_TEXTURE24 0x84D8 -#define GL_TEXTURE25 0x84D9 -#define GL_TEXTURE26 0x84DA -#define GL_TEXTURE27 0x84DB -#define GL_TEXTURE28 0x84DC -#define GL_TEXTURE29 0x84DD -#define GL_TEXTURE30 0x84DE -#define GL_TEXTURE31 0x84DF -#define GL_ACTIVE_TEXTURE 0x84E0 -#define GL_CLIENT_ACTIVE_TEXTURE 0x84E1 - -/* TextureWrapMode */ -#define GL_REPEAT 0x2901 -#define GL_CLAMP_TO_EDGE 0x812F - -/* VertexPointerType */ -/* GL_SHORT */ -/* GL_FLOAT */ -/* GL_FIXED */ -/* GL_BYTE */ - -/* LightName */ -#define GL_LIGHT0 0x4000 -#define GL_LIGHT1 0x4001 -#define GL_LIGHT2 0x4002 -#define GL_LIGHT3 0x4003 -#define GL_LIGHT4 0x4004 -#define GL_LIGHT5 0x4005 -#define GL_LIGHT6 0x4006 -#define GL_LIGHT7 0x4007 - -/* Buffer Objects */ -#define GL_ARRAY_BUFFER 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER 0x8893 - -#define GL_ARRAY_BUFFER_BINDING 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING 0x8898 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING 0x889A - -#define GL_STATIC_DRAW 0x88E4 -#define GL_DYNAMIC_DRAW 0x88E8 - -#define GL_BUFFER_SIZE 0x8764 -#define GL_BUFFER_USAGE 0x8765 - -/* Texture combine + dot3 */ -#define GL_SUBTRACT 0x84E7 -#define GL_COMBINE 0x8570 -#define GL_COMBINE_RGB 0x8571 -#define GL_COMBINE_ALPHA 0x8572 -#define GL_RGB_SCALE 0x8573 -#define GL_ADD_SIGNED 0x8574 -#define GL_INTERPOLATE 0x8575 -#define GL_CONSTANT 0x8576 -#define GL_PRIMARY_COLOR 0x8577 -#define GL_PREVIOUS 0x8578 -#define GL_OPERAND0_RGB 0x8590 -#define GL_OPERAND1_RGB 0x8591 -#define GL_OPERAND2_RGB 0x8592 -#define GL_OPERAND0_ALPHA 0x8598 -#define GL_OPERAND1_ALPHA 0x8599 -#define GL_OPERAND2_ALPHA 0x859A - -#define GL_ALPHA_SCALE 0x0D1C - -#define GL_SRC0_RGB 0x8580 -#define GL_SRC1_RGB 0x8581 -#define GL_SRC2_RGB 0x8582 -#define GL_SRC0_ALPHA 0x8588 -#define GL_SRC1_ALPHA 0x8589 -#define GL_SRC2_ALPHA 0x858A - -#define GL_DOT3_RGB 0x86AE -#define GL_DOT3_RGBA 0x86AF - -/*------------------------------------------------------------------------* - * required OES extension tokens - *------------------------------------------------------------------------*/ - -/* OES_read_format */ -#ifndef GL_OES_read_format -#define GL_IMPLEMENTATION_COLOR_READ_TYPE_OES 0x8B9A -#define GL_IMPLEMENTATION_COLOR_READ_FORMAT_OES 0x8B9B -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_PALETTE4_RGB8_OES 0x8B90 -#define GL_PALETTE4_RGBA8_OES 0x8B91 -#define GL_PALETTE4_R5_G6_B5_OES 0x8B92 -#define GL_PALETTE4_RGBA4_OES 0x8B93 -#define GL_PALETTE4_RGB5_A1_OES 0x8B94 -#define GL_PALETTE8_RGB8_OES 0x8B95 -#define GL_PALETTE8_RGBA8_OES 0x8B96 -#define GL_PALETTE8_R5_G6_B5_OES 0x8B97 -#define GL_PALETTE8_RGBA4_OES 0x8B98 -#define GL_PALETTE8_RGB5_A1_OES 0x8B99 -#endif - -/* OES_point_size_array */ -#ifndef GL_OES_point_size_array -#define GL_POINT_SIZE_ARRAY_OES 0x8B9C -#define GL_POINT_SIZE_ARRAY_TYPE_OES 0x898A -#define GL_POINT_SIZE_ARRAY_STRIDE_OES 0x898B -#define GL_POINT_SIZE_ARRAY_POINTER_OES 0x898C -#define GL_POINT_SIZE_ARRAY_BUFFER_BINDING_OES 0x8B9F -#endif - -/* GL_OES_point_sprite */ -#ifndef GL_OES_point_sprite -#define GL_POINT_SPRITE_OES 0x8861 -#define GL_COORD_REPLACE_OES 0x8862 -#endif - -/* GL_OES_draw_texture */ -#ifndef GL_OES_draw_texture -#define GL_TEXTURE_CROP_RECT_OES 0x8B9D -#endif /* GL_OES_draw_texture */ - -/* GL_OES_vertex_buffer_object */ -#ifndef GL_OES_vertex_buffer_object -#define GL_ARRAY_BUFFER_OES 0x8892 -#define GL_ELEMENT_ARRAY_BUFFER_OES 0x8893 -#define GL_ARRAY_BUFFER_BINDING_OES 0x8894 -#define GL_ELEMENT_ARRAY_BUFFER_BINDING_OES 0x8895 -#define GL_VERTEX_ARRAY_BUFFER_BINDING_OES 0x8896 -#define GL_NORMAL_ARRAY_BUFFER_BINDING_OES 0x8897 -#define GL_COLOR_ARRAY_BUFFER_BINDING_OES 0x8898 -#define GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_OES 0x889A -#define GL_STATIC_DRAW_OES 0x88E4 -#define GL_DYNAMIC_DRAW_OES 0x88E8 -#define GL_WRITE_ONLY_OES 0x88B9 -#define GL_BUFFER_SIZE_OES 0x8764 -#define GL_BUFFER_USAGE_OES 0x8765 -#define GL_BUFFER_ACCESS_OES 0x88BB -#endif /* GL_OES_vertex_buffer_object */ - -/*************************************************************/ - -/* Available only in Common profile */ - GL_API void GL_APIENTRY glAlphaFunc(GLenum func, GLclampf ref); - GL_API void GL_APIENTRY glClearColor(GLclampf red, GLclampf green, - GLclampf blue, GLclampf alpha); - GL_API void GL_APIENTRY glClearDepthf(GLclampf depth); - GL_API void GL_APIENTRY glClipPlanef(GLenum plane, - const GLfloat * equation); - GL_API void GL_APIENTRY glColor4f(GLfloat red, GLfloat green, - GLfloat blue, GLfloat alpha); - GL_API void GL_APIENTRY glDepthRangef(GLclampf zNear, GLclampf zFar); - GL_API void GL_APIENTRY glFogf(GLenum pname, GLfloat param); - GL_API void GL_APIENTRY glFogfv(GLenum pname, const GLfloat * params); - GL_API void GL_APIENTRY glFrustumf(GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar); - GL_API void GL_APIENTRY glGetClipPlanef(GLenum pname, GLfloat eqn[4]); - GL_API void GL_APIENTRY glGetFloatv(GLenum pname, GLfloat * params); - GL_API void GL_APIENTRY glGetLightfv(GLenum light, GLenum pname, - GLfloat * params); - GL_API void GL_APIENTRY glGetMaterialfv(GLenum face, GLenum pname, - GLfloat * params); - GL_API void GL_APIENTRY glGetTexEnvfv(GLenum env, GLenum pname, - GLfloat * params); - GL_API void GL_APIENTRY glGetTexParameterfv(GLenum target, GLenum pname, - GLfloat * params); - GL_API void GL_APIENTRY glLightModelf(GLenum pname, GLfloat param); - GL_API void GL_APIENTRY glLightModelfv(GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glLightf(GLenum light, GLenum pname, - GLfloat param); - GL_API void GL_APIENTRY glLightfv(GLenum light, GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glLineWidth(GLfloat width); - GL_API void GL_APIENTRY glLoadMatrixf(const GLfloat * m); - GL_API void GL_APIENTRY glMaterialf(GLenum face, GLenum pname, - GLfloat param); - GL_API void GL_APIENTRY glMaterialfv(GLenum face, GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glMultMatrixf(const GLfloat * m); - GL_API void GL_APIENTRY glMultiTexCoord4f(GLenum target, GLfloat s, - GLfloat t, GLfloat r, - GLfloat q); - GL_API void GL_APIENTRY glNormal3f(GLfloat nx, GLfloat ny, GLfloat nz); - GL_API void GL_APIENTRY glOrthof(GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar); - GL_API void GL_APIENTRY glPointParameterf(GLenum pname, GLfloat param); - GL_API void GL_APIENTRY glPointParameterfv(GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glPointSize(GLfloat size); - GL_API void GL_APIENTRY glPolygonOffset(GLfloat factor, GLfloat units); - GL_API void GL_APIENTRY glRotatef(GLfloat angle, GLfloat x, GLfloat y, - GLfloat z); - GL_API void GL_APIENTRY glScalef(GLfloat x, GLfloat y, GLfloat z); - GL_API void GL_APIENTRY glTexEnvf(GLenum target, GLenum pname, - GLfloat param); - GL_API void GL_APIENTRY glTexEnvfv(GLenum target, GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glTexParameterf(GLenum target, GLenum pname, - GLfloat param); - GL_API void GL_APIENTRY glTexParameterfv(GLenum target, GLenum pname, - const GLfloat * params); - GL_API void GL_APIENTRY glTranslatef(GLfloat x, GLfloat y, GLfloat z); - -/* Available in both Common and Common-Lite profiles */ - GL_API void GL_APIENTRY glActiveTexture(GLenum texture); - GL_API void GL_APIENTRY glAlphaFuncx(GLenum func, GLclampx ref); - GL_API void GL_APIENTRY glBindBuffer(GLenum target, GLuint buffer); - GL_API void GL_APIENTRY glBindTexture(GLenum target, GLuint texture); - GL_API void GL_APIENTRY glBlendFunc(GLenum sfactor, GLenum dfactor); - GL_API void GL_APIENTRY glBufferData(GLenum target, GLsizeiptr size, - const GLvoid * data, GLenum usage); - GL_API void GL_APIENTRY glBufferSubData(GLenum target, GLintptr offset, - GLsizeiptr size, - const GLvoid * data); - GL_API void GL_APIENTRY glClear(GLbitfield mask); - GL_API void GL_APIENTRY glClearColorx(GLclampx red, GLclampx green, - GLclampx blue, GLclampx alpha); - GL_API void GL_APIENTRY glClearDepthx(GLclampx depth); - GL_API void GL_APIENTRY glClearStencil(GLint s); - GL_API void GL_APIENTRY glClientActiveTexture(GLenum texture); - GL_API void GL_APIENTRY glClipPlanex(GLenum plane, - const GLfixed * equation); - GL_API void GL_APIENTRY glColor4ub(GLubyte red, GLubyte green, - GLubyte blue, GLubyte alpha); - GL_API void GL_APIENTRY glColor4x(GLfixed red, GLfixed green, - GLfixed blue, GLfixed alpha); - GL_API void GL_APIENTRY glColorMask(GLboolean red, GLboolean green, - GLboolean blue, GLboolean alpha); - GL_API void GL_APIENTRY glColorPointer(GLint size, GLenum type, - GLsizei stride, - const GLvoid * pointer); - GL_API void GL_APIENTRY glCompressedTexImage2D(GLenum target, GLint level, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLint border, - GLsizei imageSize, - const GLvoid * data); - GL_API void GL_APIENTRY glCompressedTexSubImage2D(GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLsizei imageSize, - const GLvoid * data); - GL_API void GL_APIENTRY glCopyTexImage2D(GLenum target, GLint level, - GLenum internalformat, GLint x, - GLint y, GLsizei width, - GLsizei height, GLint border); - GL_API void GL_APIENTRY glCopyTexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLint x, GLint y, - GLsizei width, - GLsizei height); - GL_API void GL_APIENTRY glCullFace(GLenum mode); - GL_API void GL_APIENTRY glDeleteBuffers(GLsizei n, - const GLuint * buffers); - GL_API void GL_APIENTRY glDeleteTextures(GLsizei n, - const GLuint * textures); - GL_API void GL_APIENTRY glDepthFunc(GLenum func); - GL_API void GL_APIENTRY glDepthMask(GLboolean flag); - GL_API void GL_APIENTRY glDepthRangex(GLclampx zNear, GLclampx zFar); - GL_API void GL_APIENTRY glDisable(GLenum cap); - GL_API void GL_APIENTRY glDisableClientState(GLenum array); - GL_API void GL_APIENTRY glDrawArrays(GLenum mode, GLint first, - GLsizei count); - GL_API void GL_APIENTRY glDrawElements(GLenum mode, GLsizei count, - GLenum type, - const GLvoid * indices); - GL_API void GL_APIENTRY glEnable(GLenum cap); - GL_API void GL_APIENTRY glEnableClientState(GLenum array); - GL_API void GL_APIENTRY glFinish(void); - GL_API void GL_APIENTRY glFlush(void); - GL_API void GL_APIENTRY glFogx(GLenum pname, GLfixed param); - GL_API void GL_APIENTRY glFogxv(GLenum pname, const GLfixed * params); - GL_API void GL_APIENTRY glFrontFace(GLenum mode); - GL_API void GL_APIENTRY glFrustumx(GLfixed left, GLfixed right, - GLfixed bottom, GLfixed top, - GLfixed zNear, GLfixed zFar); - GL_API void GL_APIENTRY glGetBooleanv(GLenum pname, GLboolean * params); - GL_API void GL_APIENTRY glGetBufferParameteriv(GLenum target, - GLenum pname, - GLint * params); - GL_API void GL_APIENTRY glGetClipPlanex(GLenum pname, GLfixed eqn[4]); - GL_API void GL_APIENTRY glGenBuffers(GLsizei n, GLuint * buffers); - GL_API void GL_APIENTRY glGenTextures(GLsizei n, GLuint * textures); - GL_API GLenum GL_APIENTRY glGetError(void); - GL_API void GL_APIENTRY glGetFixedv(GLenum pname, GLfixed * params); - GL_API void GL_APIENTRY glGetIntegerv(GLenum pname, GLint * params); - GL_API void GL_APIENTRY glGetLightxv(GLenum light, GLenum pname, - GLfixed * params); - GL_API void GL_APIENTRY glGetMaterialxv(GLenum face, GLenum pname, - GLfixed * params); - GL_API void GL_APIENTRY glGetPointerv(GLenum pname, void **params); - GL_API const GLubyte *GL_APIENTRY glGetString(GLenum name); - GL_API void GL_APIENTRY glGetTexEnviv(GLenum env, GLenum pname, - GLint * params); - GL_API void GL_APIENTRY glGetTexEnvxv(GLenum env, GLenum pname, - GLfixed * params); - GL_API void GL_APIENTRY glGetTexParameteriv(GLenum target, GLenum pname, - GLint * params); - GL_API void GL_APIENTRY glGetTexParameterxv(GLenum target, GLenum pname, - GLfixed * params); - GL_API void GL_APIENTRY glHint(GLenum target, GLenum mode); - GL_API GLboolean GL_APIENTRY glIsBuffer(GLuint buffer); - GL_API GLboolean GL_APIENTRY glIsEnabled(GLenum cap); - GL_API GLboolean GL_APIENTRY glIsTexture(GLuint texture); - GL_API void GL_APIENTRY glLightModelx(GLenum pname, GLfixed param); - GL_API void GL_APIENTRY glLightModelxv(GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glLightx(GLenum light, GLenum pname, - GLfixed param); - GL_API void GL_APIENTRY glLightxv(GLenum light, GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glLineWidthx(GLfixed width); - GL_API void GL_APIENTRY glLoadIdentity(void); - GL_API void GL_APIENTRY glLoadMatrixx(const GLfixed * m); - GL_API void GL_APIENTRY glLogicOp(GLenum opcode); - GL_API void GL_APIENTRY glMaterialx(GLenum face, GLenum pname, - GLfixed param); - GL_API void GL_APIENTRY glMaterialxv(GLenum face, GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glMatrixMode(GLenum mode); - GL_API void GL_APIENTRY glMultMatrixx(const GLfixed * m); - GL_API void GL_APIENTRY glMultiTexCoord4x(GLenum target, GLfixed s, - GLfixed t, GLfixed r, - GLfixed q); - GL_API void GL_APIENTRY glNormal3x(GLfixed nx, GLfixed ny, GLfixed nz); - GL_API void GL_APIENTRY glNormalPointer(GLenum type, GLsizei stride, - const GLvoid * pointer); - GL_API void GL_APIENTRY glOrthox(GLfixed left, GLfixed right, - GLfixed bottom, GLfixed top, - GLfixed zNear, GLfixed zFar); - GL_API void GL_APIENTRY glPixelStorei(GLenum pname, GLint param); - GL_API void GL_APIENTRY glPointParameterx(GLenum pname, GLfixed param); - GL_API void GL_APIENTRY glPointParameterxv(GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glPointSizex(GLfixed size); - GL_API void GL_APIENTRY glPolygonOffsetx(GLfixed factor, GLfixed units); - GL_API void GL_APIENTRY glPopMatrix(void); - GL_API void GL_APIENTRY glPushMatrix(void); - GL_API void GL_APIENTRY glReadPixels(GLint x, GLint y, GLsizei width, - GLsizei height, GLenum format, - GLenum type, GLvoid * pixels); - GL_API void GL_APIENTRY glRotatex(GLfixed angle, GLfixed x, GLfixed y, - GLfixed z); - GL_API void GL_APIENTRY glSampleCoverage(GLclampf value, - GLboolean invert); - GL_API void GL_APIENTRY glSampleCoveragex(GLclampx value, - GLboolean invert); - GL_API void GL_APIENTRY glScalex(GLfixed x, GLfixed y, GLfixed z); - GL_API void GL_APIENTRY glScissor(GLint x, GLint y, GLsizei width, - GLsizei height); - GL_API void GL_APIENTRY glShadeModel(GLenum mode); - GL_API void GL_APIENTRY glStencilFunc(GLenum func, GLint ref, - GLuint mask); - GL_API void GL_APIENTRY glStencilMask(GLuint mask); - GL_API void GL_APIENTRY glStencilOp(GLenum fail, GLenum zfail, - GLenum zpass); - GL_API void GL_APIENTRY glTexCoordPointer(GLint size, GLenum type, - GLsizei stride, - const GLvoid * pointer); - GL_API void GL_APIENTRY glTexEnvi(GLenum target, GLenum pname, - GLint param); - GL_API void GL_APIENTRY glTexEnvx(GLenum target, GLenum pname, - GLfixed param); - GL_API void GL_APIENTRY glTexEnviv(GLenum target, GLenum pname, - const GLint * params); - GL_API void GL_APIENTRY glTexEnvxv(GLenum target, GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glTexImage2D(GLenum target, GLint level, - GLint internalformat, GLsizei width, - GLsizei height, GLint border, - GLenum format, GLenum type, - const GLvoid * pixels); - GL_API void GL_APIENTRY glTexParameteri(GLenum target, GLenum pname, - GLint param); - GL_API void GL_APIENTRY glTexParameterx(GLenum target, GLenum pname, - GLfixed param); - GL_API void GL_APIENTRY glTexParameteriv(GLenum target, GLenum pname, - const GLint * params); - GL_API void GL_APIENTRY glTexParameterxv(GLenum target, GLenum pname, - const GLfixed * params); - GL_API void GL_APIENTRY glTexSubImage2D(GLenum target, GLint level, - GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, - GLenum format, GLenum type, - const GLvoid * pixels); - GL_API void GL_APIENTRY glTranslatex(GLfixed x, GLfixed y, GLfixed z); - GL_API void GL_APIENTRY glVertexPointer(GLint size, GLenum type, - GLsizei stride, - const GLvoid * pointer); - GL_API void GL_APIENTRY glViewport(GLint x, GLint y, GLsizei width, - GLsizei height); - -/*------------------------------------------------------------------------* - * Required OES extension functions - *------------------------------------------------------------------------*/ - -/* GL_OES_read_format */ -#ifndef GL_OES_read_format -#define GL_OES_read_format 1 -#endif - -/* GL_OES_compressed_paletted_texture */ -#ifndef GL_OES_compressed_paletted_texture -#define GL_OES_compressed_paletted_texture 1 -#endif - -/* GL_OES_point_size_array */ -#ifndef GL_OES_point_size_array -#define GL_OES_point_size_array 1 - GL_API void GL_APIENTRY glPointSizePointerOES(GLenum type, GLsizei stride, - const GLvoid * pointer); -#endif - -/* GL_OES_query_matrix */ -#ifndef GL_OES_query_matrix -#define GL_OES_query_matrix 1 - GL_API GLbitfield GL_APIENTRY glQueryMatrixxOES(GLfixed mantissa[16], - GLint exponent[16]); -#endif /* GL_OES_query_matrix */ - -/* GL_OES_point_sprite */ -#ifndef GL_OES_point_sprite -#define GL_OES_point_sprite 1 -#endif - -/* GL_OES_draw_texture */ -#ifndef GL_OES_draw_texture -#define GL_OES_draw_texture 1 - GL_API void GL_APIENTRY glDrawTexsOES(GLshort x, GLshort y, GLshort z, - GLshort width, GLshort height); - GL_API void GL_APIENTRY glDrawTexiOES(GLint x, GLint y, GLint z, - GLint width, GLint height); - GL_API void GL_APIENTRY glDrawTexxOES(GLfixed x, GLfixed y, GLfixed z, - GLfixed width, GLfixed height); - GL_API void GL_APIENTRY glDrawTexsvOES(const GLshort * coords); - GL_API void GL_APIENTRY glDrawTexivOES(const GLint * coords); - GL_API void GL_APIENTRY glDrawTexxvOES(const GLfixed * coords); - GL_API void GL_APIENTRY glDrawTexfOES(GLfloat x, GLfloat y, GLfloat z, - GLfloat width, GLfloat height); - GL_API void GL_APIENTRY glDrawTexfvOES(const GLfloat * coords); -#endif /* GL_OES_draw_texture */ - -/* GL_OES_single_precision */ -#ifndef GL_OES_single_precision -#define GL_OES_single_precision 1 - GL_API void GL_APIENTRY glDepthRangefOES(GLclampf zNear, GLclampf zFar); - GL_API void GL_APIENTRY glFrustumfOES(GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar); - GL_API void GL_APIENTRY glOrthofOES(GLfloat left, GLfloat right, - GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar); - GL_API void GL_APIENTRY glClipPlanefOES(GLenum plane, - const GLfloat * equation); - GL_API void GL_APIENTRY glGetClipPlanefOES(GLenum pname, GLfloat eqn[4]); - GL_API void GL_APIENTRY glClearDepthfOES(GLclampf depth); -#endif /* GL_OES_single_precision */ - -/* GL_OES_vertex_buffer_object */ -#ifndef GL_OES_vertex_buffer_object -#define GL_OES_vertex_buffer_object 1 - GL_API void APIENTRY glBindBufferOES(GLenum, GLuint); - GL_API void APIENTRY glDeleteBuffersOES(GLsizei, const GLuint *); - GL_API void APIENTRY glGenBuffersOES(GLsizei, GLuint *); - GL_API GLboolean APIENTRY glIsBufferOES(GLuint); - GL_API void APIENTRY glBufferDataOES(GLenum, GLsizeiptr, const GLvoid *, - GLenum); - GL_API void APIENTRY glBufferSubDataOES(GLenum, GLintptr, GLsizeiptr, - const GLvoid *); - GL_API void APIENTRY glGetBufferParameterivOES(GLenum, GLenum, GLint *); -#endif /* GL_OES_vertex_buffer_object */ - -#ifdef __cplusplus -} -#endif - -#endif /* __gles_h_ */ diff --git a/project/jni/sdl-1.3/include/SDL_opengles2.h b/project/jni/sdl-1.3/include/SDL_opengles2.h new file mode 100644 index 000000000..f750d3315 --- /dev/null +++ b/project/jni/sdl-1.3/include/SDL_opengles2.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_opengles.h + * + * This is a simple file to encapsulate the OpenGL ES 2.0 API headers. + */ + +#ifdef __IPHONEOS__ +#include +#include +#else +#include +#include +#endif + +#ifndef APIENTRY +#define APIENTRY +#endif diff --git a/project/jni/sdl-1.3/include/SDL_pixels.h b/project/jni/sdl-1.3/include/SDL_pixels.h index 766350783..5939d2c7c 100644 --- a/project/jni/sdl-1.3/include/SDL_pixels.h +++ b/project/jni/sdl-1.3/include/SDL_pixels.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -122,18 +121,24 @@ enum #define SDL_PIXELORDER(X) (((X) >> 20) & 0x0F) #define SDL_PIXELLAYOUT(X) (((X) >> 16) & 0x0F) #define SDL_BITSPERPIXEL(X) (((X) >> 8) & 0xFF) -#define SDL_BYTESPERPIXEL(X) (((X) >> 0) & 0xFF) +#define SDL_BYTESPERPIXEL(X) \ + (SDL_ISPIXELFORMAT_FOURCC(X) ? \ + ((((X) == SDL_PIXELFORMAT_YUY2) || \ + ((X) == SDL_PIXELFORMAT_UYVY) || \ + ((X) == SDL_PIXELFORMAT_YVYU)) ? 2 : 1) : (((X) >> 0) & 0xFF)) #define SDL_ISPIXELFORMAT_INDEXED(format) \ - ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ - (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8)) + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX1) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX4) || \ + (SDL_PIXELTYPE(format) == SDL_PIXELTYPE_INDEX8))) #define SDL_ISPIXELFORMAT_ALPHA(format) \ - ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ - (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ - (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ - (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA)) + (!SDL_ISPIXELFORMAT_FOURCC(format) && \ + ((SDL_PIXELORDER(format) == SDL_PACKEDORDER_ARGB) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_RGBA) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_ABGR) || \ + (SDL_PIXELORDER(format) == SDL_PACKEDORDER_BGRA))) #define SDL_ISPIXELFORMAT_FOURCC(format) \ ((format) && !((format) & 0x80000000)) @@ -143,16 +148,16 @@ enum { SDL_PIXELFORMAT_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, - 1, 0), - SDL_PIXELFORMAT_INDEX1MSB = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_4321, 0, 1, 0), + SDL_PIXELFORMAT_INDEX1MSB = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX1, SDL_BITMAPORDER_1234, 0, + 1, 0), SDL_PIXELFORMAT_INDEX4LSB = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, 4, 0), SDL_PIXELFORMAT_INDEX4MSB = - SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_4321, 0, + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX4, SDL_BITMAPORDER_1234, 0, 4, 0), SDL_PIXELFORMAT_INDEX8 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_INDEX8, 0, 0, 8, 1), @@ -207,9 +212,15 @@ enum SDL_PIXELFORMAT_RGB888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XRGB, SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_RGBX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_RGBX, + SDL_PACKEDLAYOUT_8888, 24, 4), SDL_PIXELFORMAT_BGR888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_XBGR, SDL_PACKEDLAYOUT_8888, 24, 4), + SDL_PIXELFORMAT_BGRX8888 = + SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_BGRX, + SDL_PACKEDLAYOUT_8888, 24, 4), SDL_PIXELFORMAT_ARGB8888 = SDL_DEFINE_PIXELFORMAT(SDL_PIXELTYPE_PACKED32, SDL_PACKEDORDER_ARGB, SDL_PACKEDLAYOUT_8888, 32, 4), @@ -247,27 +258,28 @@ typedef struct SDL_Color } SDL_Color; #define SDL_Colour SDL_Color -typedef struct SDL_Palette SDL_Palette; -typedef int (*SDL_PaletteChangedFunc) (void *userdata, SDL_Palette * palette); -typedef struct SDL_PaletteWatch SDL_PaletteWatch; - -struct SDL_Palette +typedef struct SDL_Palette { int ncolors; SDL_Color *colors; - + Uint32 version; int refcount; - SDL_PaletteWatch *watch; -}; +} SDL_Palette; /** * \note Everything in the pixel format structure is read-only. */ typedef struct SDL_PixelFormat { + Uint32 format; SDL_Palette *palette; Uint8 BitsPerPixel; Uint8 BytesPerPixel; + Uint8 padding[2]; + Uint32 Rmask; + Uint32 Gmask; + Uint32 Bmask; + Uint32 Amask; Uint8 Rloss; Uint8 Gloss; Uint8 Bloss; @@ -276,10 +288,8 @@ typedef struct SDL_PixelFormat Uint8 Gshift; Uint8 Bshift; Uint8 Ashift; - Uint32 Rmask; - Uint32 Gmask; - Uint32 Bmask; - Uint32 Amask; + int refcount; + struct SDL_PixelFormat *next; } SDL_PixelFormat; /** @@ -315,6 +325,16 @@ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, Uint32 Bmask, Uint32 Amask); +/** + * \brief Create an SDL_PixelFormat structure from a pixel format enum. + */ +extern DECLSPEC SDL_PixelFormat * SDLCALL SDL_AllocFormat(Uint32 pixel_format); + +/** + * \brief Free an SDL_PixelFormat structure. + */ +extern DECLSPEC void SDLCALL SDL_FreeFormat(SDL_PixelFormat *format); + /** * \brief Create a palette structure with the specified number of color * entries. @@ -328,23 +348,10 @@ extern DECLSPEC Uint32 SDLCALL SDL_MasksToPixelFormatEnum(int bpp, extern DECLSPEC SDL_Palette *SDLCALL SDL_AllocPalette(int ncolors); /** - * \brief Add a callback function which is called when the palette changes. - * - * \sa SDL_DelPaletteWatch() + * \brief Set the palette for a pixel format structure. */ -extern DECLSPEC int SDLCALL SDL_AddPaletteWatch(SDL_Palette * palette, - SDL_PaletteChangedFunc - callback, void *userdata); - -/** - * \brief Remove a callback function previously added with - * SDL_AddPaletteWatch(). - * - * \sa SDL_AddPaletteWatch() - */ -extern DECLSPEC void SDLCALL SDL_DelPaletteWatch(SDL_Palette * palette, - SDL_PaletteChangedFunc - callback, void *userdata); +extern DECLSPEC int SDLCALL SDL_SetPixelFormatPalette(SDL_PixelFormat * format, + SDL_Palette *palette); /** * \brief Set a range of colors in a palette. @@ -403,6 +410,12 @@ extern DECLSPEC void SDLCALL SDL_GetRGBA(Uint32 pixel, Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a); +/** + * \brief Calculate a 256 entry gamma ramp for a gamma value. + */ +extern DECLSPEC void SDLCALL SDL_CalculateGammaRamp(float gamma, Uint16 * ramp); + + /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ diff --git a/project/jni/sdl-1.3/include/SDL_platform.h b/project/jni/sdl-1.3/include/SDL_platform.h index f4635e069..ec29b06b8 100644 --- a/project/jni/sdl-1.3/include/SDL_platform.h +++ b/project/jni/sdl-1.3/include/SDL_platform.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -65,28 +64,16 @@ #undef __LINUX__ #define __LINUX__ 1 #endif -/* Hack, do not enable this */ -/* #if defined(ANDROID) #undef __ANDROID__ -#undef __LINUX__ +#undef __LINUX__ /*do we need to do this?*/ #define __ANDROID__ 1 #endif -*/ #if defined(__APPLE__) /* lets us know what version of Mac OS X we're compiling on */ #include "AvailabilityMacros.h" #include "TargetConditionals.h" -#ifndef MAC_OS_X_VERSION_10_4 -#define MAC_OS_X_VERSION_10_4 1040 -#endif -#ifndef MAC_OS_X_VERSION_10_5 -#define MAC_OS_X_VERSION_10_5 1050 -#endif -#ifndef MAC_OS_X_VERSION_10_6 -#define MAC_OS_X_VERSION_10_6 1060 -#endif #if TARGET_OS_IPHONE /* if compiling for iPhone */ #undef __IPHONEOS__ diff --git a/project/jni/sdl-1.3/include/SDL_power.h b/project/jni/sdl-1.3/include/SDL_power.h index 9141422f0..6cc11978a 100644 --- a/project/jni/sdl-1.3/include/SDL_power.h +++ b/project/jni/sdl-1.3/include/SDL_power.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_power_h diff --git a/project/jni/sdl-1.3/include/SDL_quit.h b/project/jni/sdl-1.3/include/SDL_quit.h index c5e0db3c9..d6f11a80c 100644 --- a/project/jni/sdl-1.3/include/SDL_quit.h +++ b/project/jni/sdl-1.3/include/SDL_quit.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -54,6 +53,6 @@ /* There are no functions directly affecting the quit event */ #define SDL_QuitRequested() \ - (SDL_PumpEvents(), SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUITMASK)) + (SDL_PumpEvents(), (SDL_PeepEvents(NULL,0,SDL_PEEKEVENT,SDL_QUIT,SDL_QUIT) > 0)) #endif /* _SDL_quit_h */ diff --git a/project/jni/sdl-1.3/include/SDL_rect.h b/project/jni/sdl-1.3/include/SDL_rect.h index 4229d34db..a6576ac4b 100644 --- a/project/jni/sdl-1.3/include/SDL_rect.h +++ b/project/jni/sdl-1.3/include/SDL_rect.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -72,12 +71,13 @@ typedef struct SDL_Rect /** * \brief Returns true if the rectangle has no area. */ -#define SDL_RectEmpty(X) (((X)->w <= 0) || ((X)->h <= 0)) +#define SDL_RectEmpty(X) ((!(X)) || ((X)->w <= 0) || ((X)->h <= 0)) /** * \brief Returns true if the two rectangles are equal. */ -#define SDL_RectEquals(A, B) (((A)->x == (B)->x) && ((A)->y == (B)->y) && \ +#define SDL_RectEquals(A, B) (((A)) && ((B)) && \ + ((A)->x == (B)->x) && ((A)->y == (B)->y) && \ ((A)->w == (B)->w) && ((A)->h == (B)->h)) /** diff --git a/project/jni/sdl-1.3/include/SDL_render.h b/project/jni/sdl-1.3/include/SDL_render.h new file mode 100644 index 000000000..09ea53c47 --- /dev/null +++ b/project/jni/sdl-1.3/include/SDL_render.h @@ -0,0 +1,615 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/** + * \file SDL_render.h + * + * Header file for SDL 2D rendering functions. + * + * This API supports the following features: + * * single pixel points + * * single pixel lines + * * filled rectangles + * * texture images + * + * The primitives may be drawn in opaque, blended, or additive modes. + * + * The texture images may be drawn in opaque, blended, or additive modes. + * They can have an additional color tint or alpha modulation applied to + * them, and may also be stretched with linear interpolation. + * + * This API is designed to accelerate simple 2D operations. You may + * want more functionality such as rotation and particle effects and + * in that case you should use SDL's OpenGL/Direct3D support or one + * of the many good 3D engines. + */ + +#ifndef _SDL_render_h +#define _SDL_render_h + +#include "SDL_stdinc.h" +#include "SDL_rect.h" +#include "SDL_video.h" + +#include "begin_code.h" +/* Set up for C function definitions, even when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +extern "C" { +/* *INDENT-ON* */ +#endif + +/** + * \brief Flags used when creating a rendering context + */ +typedef enum +{ + SDL_RENDERER_SOFTWARE = 0x00000001, /**< The renderer is a software fallback */ + SDL_RENDERER_ACCELERATED = 0x00000002, /**< The renderer uses hardware + acceleration */ + SDL_RENDERER_PRESENTVSYNC = 0x00000004 /**< Present is synchronized + with the refresh rate */ +} SDL_RendererFlags; + +/** + * \brief Information on the capabilities of a render driver or context. + */ +typedef struct SDL_RendererInfo +{ + const char *name; /**< The name of the renderer */ + Uint32 flags; /**< Supported ::SDL_RendererFlags */ + Uint32 num_texture_formats; /**< The number of available texture formats */ + Uint32 texture_formats[16]; /**< The available texture formats */ + int max_texture_width; /**< The maximimum texture width */ + int max_texture_height; /**< The maximimum texture height */ +} SDL_RendererInfo; + +/** + * \brief The access pattern allowed for a texture. + */ +typedef enum +{ + SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ + SDL_TEXTUREACCESS_STREAMING /**< Changes frequently, lockable */ +} SDL_TextureAccess; + +/** + * \brief The texture channel modulation used in SDL_RenderCopy(). + */ +typedef enum +{ + SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ + SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ + SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ +} SDL_TextureModulate; + +/** + * \brief A structure representing rendering state + */ +struct SDL_Renderer; +typedef struct SDL_Renderer SDL_Renderer; + +/** + * \brief An efficient driver-specific representation of pixel data + */ +struct SDL_Texture; +typedef struct SDL_Texture SDL_Texture; + + +/* Function prototypes */ + +/** + * \brief Get the number of 2D rendering drivers available for the current + * display. + * + * A render driver is a set of code that handles rendering and texture + * management on a particular display. Normally there is only one, but + * some drivers may have several available with different capabilities. + * + * \sa SDL_GetRenderDriverInfo() + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); + +/** + * \brief Get information about a specific 2D rendering driver for the current + * display. + * + * \param index The index of the driver to query information about. + * \param info A pointer to an SDL_RendererInfo struct to be filled with + * information on the rendering driver. + * + * \return 0 on success, -1 if the index was out of range. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, + SDL_RendererInfo * info); + +/** + * \brief Create a 2D rendering context for a window. + * + * \param window The window where rendering is displayed. + * \param index The index of the rendering driver to initialize, or -1 to + * initialize the first one supporting the requested flags. + * \param flags ::SDL_RendererFlags. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateSoftwareRenderer() + * \sa SDL_GetRendererInfo() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateRenderer(SDL_Window * window, + int index, Uint32 flags); + +/** + * \brief Create a 2D software rendering context for a surface. + * + * \param surface The surface where rendering is done. + * + * \return A valid rendering context or NULL if there was an error. + * + * \sa SDL_CreateRenderer() + * \sa SDL_DestroyRenderer() + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_CreateSoftwareRenderer(SDL_Surface * surface); + +/** + * \brief Get the renderer associated with a window. + */ +extern DECLSPEC SDL_Renderer * SDLCALL SDL_GetRenderer(SDL_Window * window); + +/** + * \brief Get information about a rendering context. + */ +extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_Renderer * renderer, + SDL_RendererInfo * info); + +/** + * \brief Create a texture for a rendering context. + * + * \param format The format of the texture. + * \param access One of the enumerated values in ::SDL_TextureAccess. + * \param w The width of the texture in pixels. + * \param h The height of the texture in pixels. + * + * \return The created texture is returned, or 0 if no rendering context was + * active, the format was unsupported, or the width or height were out + * of range. + * + * \sa SDL_QueryTexture() + * \sa SDL_UpdateTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(SDL_Renderer * renderer, + Uint32 format, + int access, int w, + int h); + +/** + * \brief Create a texture from an existing surface. + * + * \param surface The surface containing pixel data used to fill the texture. + * + * \return The created texture is returned, or 0 on error. + * + * \note The surface is not modified or freed by this function. + * + * \sa SDL_QueryTexture() + * \sa SDL_DestroyTexture() + */ +extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface); + +/** + * \brief Query the attributes of a texture + * + * \param texture A texture to be queried. + * \param format A pointer filled in with the raw format of the texture. The + * actual format may differ, but pixel transfers will use this + * format. + * \param access A pointer filled in with the actual access to the texture. + * \param w A pointer filled in with the width of the texture in pixels. + * \param h A pointer filled in with the height of the texture in pixels. + * + * \return 0 on success, or -1 if the texture is not valid. + */ +extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, + Uint32 * format, int *access, + int *w, int *h); + +/** + * \brief Set an additional color value used in render copy operations. + * + * \param texture The texture to update. + * \param r The red color value multiplied into copy operations. + * \param g The green color value multiplied into copy operations. + * \param b The blue color value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or color modulation + * is not supported. + * + * \sa SDL_GetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, + Uint8 r, Uint8 g, Uint8 b); + + +/** + * \brief Get the additional color value used in render copy operations. + * + * \param texture The texture to query. + * \param r A pointer filled in with the current red color value. + * \param g A pointer filled in with the current green color value. + * \param b A pointer filled in with the current blue color value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureColorMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, + Uint8 * r, Uint8 * g, + Uint8 * b); + +/** + * \brief Set an additional alpha value used in render copy operations. + * + * \param texture The texture to update. + * \param alpha The alpha value multiplied into copy operations. + * + * \return 0 on success, or -1 if the texture is not valid or alpha modulation + * is not supported. + * + * \sa SDL_GetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, + Uint8 alpha); + +/** + * \brief Get the additional alpha value used in render copy operations. + * + * \param texture The texture to query. + * \param alpha A pointer filled in with the current alpha value. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureAlphaMod() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, + Uint8 * alpha); + +/** + * \brief Set the blend mode used for texture copy operations. + * + * \param texture The texture to update. + * \param blendMode ::SDL_BlendMode to use for texture blending. + * + * \return 0 on success, or -1 if the texture is not valid or the blend mode is + * not supported. + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for texture copy operations. + * + * \param texture The texture to query. + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \sa SDL_SetTextureBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, + SDL_BlendMode *blendMode); + +/** + * \brief Update the given texture rectangle with new pixel data. + * + * \param texture The texture to update + * \param rect A pointer to the rectangle of pixels to update, or NULL to + * update the entire texture. + * \param pixels The raw pixel data. + * \param pitch The number of bytes between rows of pixel data. + * + * \return 0 on success, or -1 if the texture is not valid. + * + * \note This is a fairly slow function. + */ +extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, + const SDL_Rect * rect, + const void *pixels, int pitch); + +/** + * \brief Lock a portion of the texture for pixel access. + * + * \param texture The texture to lock for access, which was created with + * ::SDL_TEXTUREACCESS_STREAMING. + * \param rect A pointer to the rectangle to lock for access. If the rect + * is NULL, the entire texture will be locked. + * \param pixels This is filled in with a pointer to the locked pixels, + * appropriately offset by the locked area. + * \param pitch This is filled in with the pitch of the locked pixels. + * + * \return 0 on success, or -1 if the texture is not valid or was not created with ::SDL_TEXTUREACCESS_STREAMING. + * + * \sa SDL_UnlockTexture() + */ +extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, + const SDL_Rect * rect, + void **pixels, int *pitch); + +/** + * \brief Unlock a texture, uploading the changes to video memory, if needed. + * + * \sa SDL_LockTexture() + */ +extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); + +/** + * \brief Set the drawing area for rendering on the current target. + * + * \param rect The rectangle representing the drawing area, or NULL to set the viewport to the entire target. + * + * The x,y of the viewport rect represents the origin for rendering. + * + * \note When the window is resized, the current viewport is automatically + * centered within the new window size. + */ +extern DECLSPEC int SDLCALL SDL_RenderSetViewport(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Get the drawing area for the current target. + */ +extern DECLSPEC void SDLCALL SDL_RenderGetViewport(SDL_Renderer * renderer, + SDL_Rect * rect); + +/** + * \brief Set the color used for drawing operations (Rect, Line and Clear). + * + * \param r The red value used to draw on the rendering target. + * \param g The green value used to draw on the rendering target. + * \param b The blue value used to draw on the rendering target. + * \param a The alpha value used to draw on the rendering target, usually + * ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDL_SetRenderDrawColor(SDL_Renderer * renderer, + Uint8 r, Uint8 g, Uint8 b, + Uint8 a); + +/** + * \brief Get the color used for drawing operations (Rect, Line and Clear). + * + * \param r A pointer to the red value used to draw on the rendering target. + * \param g A pointer to the green value used to draw on the rendering target. + * \param b A pointer to the blue value used to draw on the rendering target. + * \param a A pointer to the alpha value used to draw on the rendering target, + * usually ::SDL_ALPHA_OPAQUE (255). + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDL_GetRenderDrawColor(SDL_Renderer * renderer, + Uint8 * r, Uint8 * g, Uint8 * b, + Uint8 * a); + +/** + * \brief Set the blend mode used for drawing operations (Fill and Line). + * + * \param blendMode ::SDL_BlendMode to use for blending. + * + * \return 0 on success, or -1 on error + * + * \note If the blend mode is not supported, the closest supported mode is + * chosen. + * + * \sa SDL_GetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode blendMode); + +/** + * \brief Get the blend mode used for drawing operations. + * + * \param blendMode A pointer filled in with the current blend mode. + * + * \return 0 on success, or -1 on error + * + * \sa SDL_SetRenderDrawBlendMode() + */ +extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, + SDL_BlendMode *blendMode); + +/** + * \brief Clear the current rendering target with the drawing color + * + * This function clears the entire rendering target, ignoring the viewport. + */ +extern DECLSPEC int SDLCALL SDL_RenderClear(SDL_Renderer * renderer); + +/** + * \brief Draw a point on the current rendering target. + * + * \param x The x coordinate of the point. + * \param y The y coordinate of the point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(SDL_Renderer * renderer, + int x, int y); + +/** + * \brief Draw multiple points on the current rendering target. + * + * \param points The points to draw + * \param count The number of points to draw + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a line on the current rendering target. + * + * \param x1 The x coordinate of the start point. + * \param y1 The y coordinate of the start point. + * \param x2 The x coordinate of the end point. + * \param y2 The y coordinate of the end point. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLine(SDL_Renderer * renderer, + int x1, int y1, int x2, int y2); + +/** + * \brief Draw a series of connected lines on the current rendering target. + * + * \param points The points along the lines + * \param count The number of points, drawing count-1 lines + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, + int count); + +/** + * \brief Draw a rectangle on the current rendering target. + * + * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Draw some number of rectangles on the current rendering target. + * + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderDrawRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Fill a rectangle on the current rendering target with the drawing color. + * + * \param rect A pointer to the destination rectangle, or NULL for the entire + * rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRect(SDL_Renderer * renderer, + const SDL_Rect * rect); + +/** + * \brief Fill some number of rectangles on the current rendering target with the drawing color. + * + * \param rects A pointer to an array of destination rectangles. + * \param count The number of rectangles. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, + int count); + +/** + * \brief Copy a portion of the texture to the current rendering target. + * + * \param texture The source texture. + * \param srcrect A pointer to the source rectangle, or NULL for the entire + * texture. + * \param dstrect A pointer to the destination rectangle, or NULL for the + * entire rendering target. + * + * \return 0 on success, or -1 on error + */ +extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Renderer * renderer, + SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect); + +/** + * \brief Read pixels from the current rendering target. + * + * \param rect A pointer to the rectangle to read, or NULL for the entire + * render target. + * \param format The desired format of the pixel data, or 0 to use the format + * of the rendering target + * \param pixels A pointer to be filled in with the pixel data + * \param pitch The pitch of the pixels parameter. + * + * \return 0 on success, or -1 if pixel reading is not supported. + * + * \warning This is a very slow operation, and should not be used frequently. + */ +extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer, + const SDL_Rect * rect, + Uint32 format, + void *pixels, int pitch); + +/** + * \brief Update the screen with rendering performed. + */ +extern DECLSPEC void SDLCALL SDL_RenderPresent(SDL_Renderer * renderer); + +/** + * \brief Destroy the specified texture. + * + * \sa SDL_CreateTexture() + * \sa SDL_CreateTextureFromSurface() + */ +extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); + +/** + * \brief Destroy the rendering context for a window and free associated + * textures. + * + * \sa SDL_CreateRenderer() + */ +extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Renderer * renderer); + + +/* Ends C function definitions when using C++ */ +#ifdef __cplusplus +/* *INDENT-OFF* */ +} +/* *INDENT-ON* */ +#endif +#include "close_code.h" + +#endif /* _SDL_render_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/include/SDL_revision.h b/project/jni/sdl-1.3/include/SDL_revision.h index e3d7b7525..f5eb3cceb 100644 --- a/project/jni/sdl-1.3/include/SDL_revision.h +++ b/project/jni/sdl-1.3/include/SDL_revision.h @@ -1 +1,2 @@ -#define SDL_REVISION "hg-5001:77df56570442" +#define SDL_REVISION "hg-5868:33245988e8a2" +#define SDL_REVISION_NUMBER 5868 diff --git a/project/jni/sdl-1.3/include/SDL_rwops.h b/project/jni/sdl-1.3/include/SDL_rwops.h index 5d32b3cf2..d260f9599 100644 --- a/project/jni/sdl-1.3/include/SDL_rwops.h +++ b/project/jni/sdl-1.3/include/SDL_rwops.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -83,7 +82,20 @@ typedef struct SDL_RWops Uint32 type; union { -#ifdef __WIN32__ +#if defined(ANDROID) + struct + { + void *fileName; + void *fileNameRef; + void *inputStream; + void *inputStreamRef; + void *readableByteChannel; + void *readableByteChannelRef; + void *readMethod; + long position; + int size; + } androidio; +#elif defined(__WIN32__) struct { SDL_bool append; @@ -94,8 +106,9 @@ typedef struct SDL_RWops size_t size; size_t left; } buffer; - } win32io; + } windowsio; #endif + #ifdef HAVE_STDIO_H struct { diff --git a/project/jni/sdl-1.3/include/SDL_scancode.h b/project/jni/sdl-1.3/include/SDL_scancode.h index 0efaf8850..a9aea662e 100644 --- a/project/jni/sdl-1.3/include/SDL_scancode.h +++ b/project/jni/sdl-1.3/include/SDL_scancode.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -35,7 +34,7 @@ * \brief The SDL keyboard scancode representation. * * Values of this type are used to represent keyboard keys, among other places - * in the \link SDL_keysym::scancode key.keysym.scancode \endlink field of the + * in the \link SDL_Keysym::scancode key.keysym.scancode \endlink field of the * SDL_Event structure. * * The values in this enumeration are based on the USB usage page standard: @@ -392,7 +391,7 @@ typedef enum SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes for array bounds */ -} SDL_scancode; +} SDL_Scancode; #endif /* _SDL_scancode_h */ diff --git a/project/jni/sdl-1.3/include/SDL_screenkeyboard.h b/project/jni/sdl-1.3/include/SDL_screenkeyboard.h index 2a3547a5b..e6cb5f619 100644 --- a/project/jni/sdl-1.3/include/SDL_screenkeyboard.h +++ b/project/jni/sdl-1.3/include/SDL_screenkeyboard.h @@ -25,7 +25,12 @@ #include "SDL_stdinc.h" #include "SDL_video.h" +#if SDL_VERSION_ATLEAST(1,3,0) +#include "SDL_keycode.h" +#include "SDL_compat.h" +#else #include "SDL_keysym.h" +#endif /* On-screen keyboard exposed to the application, it's yet available on Android platform only */ diff --git a/project/jni/sdl-1.3/include/SDL_shape.h b/project/jni/sdl-1.3/include/SDL_shape.h index 2af49defa..fc56afac6 100644 --- a/project/jni/sdl-1.3/include/SDL_shape.h +++ b/project/jni/sdl-1.3/include/SDL_shape.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_shape_h diff --git a/project/jni/sdl-1.3/include/SDL_stdinc.h b/project/jni/sdl-1.3/include/SDL_stdinc.h index 2bda655e2..89cbc3c58 100644 --- a/project/jni/sdl-1.3/include/SDL_stdinc.h +++ b/project/jni/sdl-1.3/include/SDL_stdinc.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -144,22 +143,14 @@ typedef int32_t Sint32; */ typedef uint32_t Uint32; -#ifdef SDL_HAS_64BIT_TYPE /** * \brief A signed 64-bit integer type. - * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Sint32! */ typedef int64_t Sint64; /** * \brief An unsigned 64-bit integer type. - * \warning On platforms without any sort of 64-bit datatype, this is equivalent to Uint32! */ typedef uint64_t Uint64; -#else -/* This is really just a hack to prevent the compiler from complaining */ -typedef Sint32 Sint64; -typedef Uint32 Uint64; -#endif /*@}*//*Basic data types*/ @@ -174,13 +165,8 @@ SDL_COMPILE_TIME_ASSERT(uint16, sizeof(Uint16) == 2); SDL_COMPILE_TIME_ASSERT(sint16, sizeof(Sint16) == 2); SDL_COMPILE_TIME_ASSERT(uint32, sizeof(Uint32) == 4); SDL_COMPILE_TIME_ASSERT(sint32, sizeof(Sint32) == 4); -#if !defined(__NINTENDODS__) && !defined(ANDROID) -/* TODO: figure out why the following happens: - include/SDL_stdinc.h:150: error: size of array 'SDL_dummy_uint64' is negative - include/SDL_stdinc.h:151: error: size of array 'SDL_dummy_sint64' is negative */ SDL_COMPILE_TIME_ASSERT(uint64, sizeof(Uint64) == 8); SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); -#endif #endif /* DOXYGEN_SHOULD_IGNORE_THIS */ /** \endcond */ @@ -196,7 +182,7 @@ SDL_COMPILE_TIME_ASSERT(sint64, sizeof(Sint64) == 8); /** \cond */ #ifndef DOXYGEN_SHOULD_IGNORE_THIS -#if !defined(__NINTENDODS__) && !defined(ANDROID) +#if !defined(__NINTENDODS__) && !defined(__ANDROID__) /* TODO: include/SDL_stdinc.h:174: error: size of array 'SDL_dummy_enum' is negative */ typedef enum { @@ -352,8 +338,8 @@ do { \ #endif /* We can count on memcpy existing on Mac OS X and being well-tuned. */ -#if defined(__MACH__) && defined(__APPLE__) -#define SDL_memcpy(dst, src, len) memcpy(dst, src, len) +#if defined(__MACOSX__) +#define SDL_memcpy memcpy #elif defined(__GNUC__) && defined(i386) #define SDL_memcpy(dst, src, len) \ do { \ @@ -385,8 +371,8 @@ extern DECLSPEC void *SDLCALL SDL_memcpy(void *dst, const void *src, #endif /* We can count on memcpy existing on Mac OS X and being well-tuned. */ -#if defined(__MACH__) && defined(__APPLE__) -#define SDL_memcpy4(dst, src, len) memcpy(dst, src, (len)*4) +#if defined(__MACOSX__) +#define SDL_memcpy4(dst, src, len) SDL_memcpy((dst), (src), (len) << 2) #elif defined(__GNUC__) && defined(i386) #define SDL_memcpy4(dst, src, len) \ do { \ @@ -400,54 +386,14 @@ do { \ } while(0) #endif #ifndef SDL_memcpy4 -#define SDL_memcpy4(dst, src, len) SDL_memcpy(dst, src, (len) << 2) -#endif - -#if defined(__GNUC__) && defined(i386) -#define SDL_revcpy(dst, src, len) \ -do { \ - int u0, u1, u2; \ - char *dstp = SDL_static_cast(char *, dst); \ - char *srcp = SDL_static_cast(char *, src); \ - int n = (len); \ - if ( n >= 4 ) { \ - __asm__ __volatile__ ( \ - "std\n\t" \ - "rep ; movsl\n\t" \ - "cld\n\t" \ - : "=&c" (u0), "=&D" (u1), "=&S" (u2) \ - : "0" (n >> 2), \ - "1" (dstp+(n-4)), "2" (srcp+(n-4)) \ - : "memory" ); \ - } \ - switch (n & 3) { \ - case 3: dstp[2] = srcp[2]; \ - case 2: dstp[1] = srcp[1]; \ - case 1: dstp[0] = srcp[0]; \ - break; \ - default: \ - break; \ - } \ -} while(0) -#endif -#ifndef SDL_revcpy -extern DECLSPEC void *SDLCALL SDL_revcpy(void *dst, const void *src, - size_t len); +#define SDL_memcpy4(dst, src, len) SDL_memcpy((dst), (src), (len) << 2) #endif #ifdef HAVE_MEMMOVE #define SDL_memmove memmove -#elif defined(HAVE_BCOPY) -#define SDL_memmove(d, s, n) bcopy((s), (d), (n)) #else -#define SDL_memmove(dst, src, len) \ -do { \ - if ( dst < src ) { \ - SDL_memcpy(dst, src, len); \ - } else { \ - SDL_revcpy(dst, src, len); \ - } \ -} while(0) +extern DECLSPEC void *SDLCALL SDL_memmove(void *dst, const void *src, + size_t len); #endif #ifdef HAVE_MEMCMP @@ -588,8 +534,6 @@ extern DECLSPEC unsigned long SDLCALL SDL_strtoul(const char *string, char **endp, int base); #endif -#ifdef SDL_HAS_64BIT_TYPE - #ifdef HAVE__I64TOA #define SDL_lltoa _i64toa #else @@ -618,8 +562,6 @@ extern DECLSPEC Uint64 SDLCALL SDL_strtoull(const char *string, char **endp, int base); #endif -#endif /* SDL_HAS_64BIT_TYPE */ - #ifdef HAVE_STRTOD #define SDL_strtod strtod #else diff --git a/project/jni/sdl-1.3/include/SDL_surface.h b/project/jni/sdl-1.3/include/SDL_surface.h index d8a3f4ff4..f8c95b275 100644 --- a/project/jni/sdl-1.3/include/SDL_surface.h +++ b/project/jni/sdl-1.3/include/SDL_surface.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -33,7 +32,6 @@ #include "SDL_pixels.h" #include "SDL_rect.h" #include "SDL_blendmode.h" -#include "SDL_scalemode.h" #include "SDL_rwops.h" #include "begin_code.h" @@ -55,6 +53,7 @@ extern "C" { /*@{*/ #define SDL_PREALLOC 0x00000001 /**< Surface uses preallocated memory */ #define SDL_RLEACCEL 0x00000002 /**< Surface is RLE encoded */ +#define SDL_DONTFREE 0x00000004 /**< Surface is referenced internally */ /*@}*//*Surface flags*/ /** @@ -89,9 +88,6 @@ typedef struct SDL_Surface /** info for fast blit mapping to other surfaces */ struct SDL_BlitMap *map; /**< Private */ - /** format version, bumped at every change to invalidate blit maps */ - int format_version; /**< Private */ - /** Reference count -- used when freeing surface */ int refcount; /**< Read-mostly */ } SDL_Surface; @@ -317,37 +313,6 @@ extern DECLSPEC int SDLCALL SDL_SetSurfaceBlendMode(SDL_Surface * surface, extern DECLSPEC int SDLCALL SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode); -/** - * \brief Set the scale mode used for blit operations. - * - * \param surface The surface to update. - * \param scaleMode ::SDL_ScaleMode to use for blit scaling. - * - * \return 0 on success, or -1 if the surface is not valid or the scale mode is - * not supported. - * - * \note If the scale mode is not supported, the closest supported mode is - * chosen. Currently only ::SDL_TEXTURESCALEMODE_FAST is supported on - * surfaces. - * - * \sa SDL_GetSurfaceScaleMode() - */ -extern DECLSPEC int SDLCALL SDL_SetSurfaceScaleMode(SDL_Surface * surface, - SDL_ScaleMode scaleMode); - -/** - * \brief Get the scale mode used for blit operations. - * - * \param surface The surface to query. - * \param scaleMode A pointer filled in with the current scale mode. - * - * \return 0 on success, or -1 if the surface is not valid. - * - * \sa SDL_SetSurfaceScaleMode() - */ -extern DECLSPEC int SDLCALL SDL_GetSurfaceScaleMode(SDL_Surface * surface, - SDL_ScaleMode *scaleMode); - /** * Sets the clipping rectangle for the destination surface in a blit. * @@ -385,9 +350,13 @@ extern DECLSPEC void SDLCALL SDL_GetClipRect(SDL_Surface * surface, */ extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurface (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags); +extern DECLSPEC SDL_Surface *SDLCALL SDL_ConvertSurfaceFormat + (SDL_Surface * src, Uint32 pixel_format, Uint32 flags); /** * \brief Copy a block of pixels of one format to another format + * + * \return 0 on success, or -1 if there was an error */ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, Uint32 src_format, @@ -395,85 +364,6 @@ extern DECLSPEC int SDLCALL SDL_ConvertPixels(int width, int height, Uint32 dst_format, void * dst, int dst_pitch); -/** - * Draws a point with \c color. - * - * The color should be a pixel of the format used by the surface, and - * can be generated by the SDL_MapRGB() function. - * - * \return 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_DrawPoint - (SDL_Surface * dst, int x, int y, Uint32 color); -extern DECLSPEC int SDLCALL SDL_DrawPoints - (SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color); - -/** - * Blends a point with an RGBA value. - * - * \return 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_BlendPoint - (SDL_Surface * dst, int x, int y, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -extern DECLSPEC int SDLCALL SDL_BlendPoints - (SDL_Surface * dst, const SDL_Point * points, int count, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - -/** - * Draws a line with \c color. - * - * The color should be a pixel of the format used by the surface, and - * can be generated by the SDL_MapRGB() function. - * - * \return 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_DrawLine - (SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color); -extern DECLSPEC int SDLCALL SDL_DrawLines - (SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color); - -/** - * Blends an RGBA value along a line. - * - * \return 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_BlendLine - (SDL_Surface * dst, int x1, int y1, int x2, int y2, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -extern DECLSPEC int SDLCALL SDL_BlendLines - (SDL_Surface * dst, const SDL_Point * points, int count, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - -/** - * Draws the given rectangle with \c color. - * - * If \c rect is NULL, the whole surface will be outlined with \c color. - * - * The color should be a pixel of the format used by the surface, and - * can be generated by the SDL_MapRGB() function. - * - * \return 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_DrawRect - (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); -extern DECLSPEC int SDLCALL SDL_DrawRects - (SDL_Surface * dst, const SDL_Rect ** rects, int count, Uint32 color); - -/** - * Blends an RGBA value into the outline of the given rectangle. - * - * If \c rect is NULL, the whole surface will have a blended outline. - * - * \return 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_BlendRect - (SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -extern DECLSPEC int SDLCALL SDL_BlendRects - (SDL_Surface * dst, const SDL_Rect ** rects, int count, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); - /** * Performs a fast fill of the given rectangle with \c color. * @@ -487,21 +377,7 @@ extern DECLSPEC int SDLCALL SDL_BlendRects extern DECLSPEC int SDLCALL SDL_FillRect (SDL_Surface * dst, const SDL_Rect * rect, Uint32 color); extern DECLSPEC int SDLCALL SDL_FillRects - (SDL_Surface * dst, const SDL_Rect ** rects, int count, Uint32 color); - -/** - * Blends an RGBA value into the given rectangle. - * - * If \c rect is NULL, the whole surface will be blended with the color. - * - * \return This function returns 0 on success, or -1 on error. - */ -extern DECLSPEC int SDLCALL SDL_BlendFillRect - (SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); -extern DECLSPEC int SDLCALL SDL_BlendFillRects - (SDL_Surface * dst, const SDL_Rect ** rects, int count, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + (SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color); /** * Performs a fast blit from the source surface to the destination surface. @@ -559,22 +435,6 @@ extern DECLSPEC int SDLCALL SDL_BlendFillRects source colour key. \endverbatim * - * If either of the surfaces were in video memory, and the blit returns -2, - * the video memory was lost, so it should be reloaded with artwork and - * re-blitted: - * @code - * while ( SDL_BlitSurface(image, imgrect, screen, dstrect) == -2 ) { - * while ( SDL_LockSurface(image) < 0 ) - * Sleep(10); - * -- Write image pixels to image->pixels -- - * SDL_UnlockSurface(image); - * } - * @endcode - * - * This happens under DirectX 5.0 when the system switches away from your - * fullscreen application. The lock will also fail until you have access - * to the video memory again. - * * You should call SDL_BlitSurface() unless you know exactly how SDL * blitting works internally and how to use the other blit functions. */ @@ -607,6 +467,25 @@ extern DECLSPEC int SDLCALL SDL_SoftStretch(SDL_Surface * src, SDL_Surface * dst, const SDL_Rect * dstrect); +#define SDL_BlitScaled SDL_UpperBlitScaled + +/** + * This is the public scaled blit function, SDL_BlitScaled(), and it performs + * rectangle validation and clipping before passing it to SDL_LowerBlitScaled() + */ +extern DECLSPEC int SDLCALL SDL_UpperBlitScaled + (SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + +/** + * This is a semi-private blit function and it performs low-level surface + * scaled blitting only. + */ +extern DECLSPEC int SDLCALL SDL_LowerBlitScaled + (SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect); + + /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ diff --git a/project/jni/sdl-1.3/include/SDL_syswm.h b/project/jni/sdl-1.3/include/SDL_syswm.h index f0e240889..677e398b2 100644 --- a/project/jni/sdl-1.3/include/SDL_syswm.h +++ b/project/jni/sdl-1.3/include/SDL_syswm.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -54,7 +53,7 @@ extern "C" { struct SDL_SysWMinfo; #else -#if defined(SDL_VIDEO_DRIVER_WIN32) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) #define WIN32_LEAN_AND_MEAN #include #endif @@ -77,7 +76,7 @@ struct SDL_SysWMinfo; #endif /* defined(SDL_VIDEO_DRIVER_X11) */ #if defined(SDL_VIDEO_DRIVER_DIRECTFB) -#include +#include #endif #if defined(SDL_VIDEO_DRIVER_COCOA) @@ -88,6 +87,14 @@ typedef struct _NSWindow NSWindow; #endif #endif +#if defined(SDL_VIDEO_DRIVER_UIKIT) +#ifdef __OBJC__ +#include +#else +typedef struct _UIWindow UIWindow; +#endif +#endif + /** * These are the various supported windowing subsystems */ @@ -98,6 +105,7 @@ typedef enum SDL_SYSWM_X11, SDL_SYSWM_DIRECTFB, SDL_SYSWM_COCOA, + SDL_SYSWM_UIKIT, } SDL_SYSWM_TYPE; /** @@ -109,7 +117,7 @@ struct SDL_SysWMmsg SDL_SYSWM_TYPE subsystem; union { -#if defined(SDL_VIDEO_DRIVER_WIN32) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) struct { HWND hwnd; /**< The window for the message */ UINT msg; /**< The type of message */ @@ -133,7 +141,15 @@ struct SDL_SysWMmsg /* No Cocoa window events yet */ } cocoa; #endif - } /*msg*/; +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { + /* No UIKit window events yet */ + } uikit; +#endif + /* Can't have an empty union */ + int dummy; + } msg; }; /** @@ -148,7 +164,7 @@ struct SDL_SysWMinfo SDL_SYSWM_TYPE subsystem; union { -#if defined(SDL_VIDEO_DRIVER_WIN32) +#if defined(SDL_VIDEO_DRIVER_WINDOWS) struct { HWND window; /**< The window handle */ @@ -175,7 +191,15 @@ struct SDL_SysWMinfo NSWindow *window; /* The Cocoa window */ } cocoa; #endif - } /*info*/; +#if defined(SDL_VIDEO_DRIVER_UIKIT) + struct + { + UIWindow *window; /* The UIKit window */ + } uikit; +#endif + /* Can't have an empty union */ + int dummy; + } info; }; #endif /* SDL_PROTOTYPES_ONLY */ diff --git a/project/jni/sdl-1.3/include/SDL_thread.h b/project/jni/sdl-1.3/include/SDL_thread.h index 1c8a76a25..49b8b22ff 100644 --- a/project/jni/sdl-1.3/include/SDL_thread.h +++ b/project/jni/sdl-1.3/include/SDL_thread.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_thread_h @@ -50,6 +49,16 @@ typedef struct SDL_Thread SDL_Thread; /* The SDL thread ID */ typedef unsigned long SDL_threadID; +/* The SDL thread priority + * + * Note: On many systems you require special privileges to set high priority. + */ +typedef enum { + SDL_THREAD_PRIORITY_LOW, + SDL_THREAD_PRIORITY_NORMAL, + SDL_THREAD_PRIORITY_HIGH +} SDL_ThreadPriority; + /* The function passed to SDL_CreateThread() It is passed a void* user context parameter and returns an int. */ @@ -81,17 +90,6 @@ typedef int (SDLCALL * SDL_ThreadFunction) (void *data); #include /* This has _beginthread() and _endthread() defined! */ #endif -#ifdef __GNUC__ -typedef unsigned long (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned - (__stdcall * - func) (void *), - void *arg, - unsigned, - unsigned - *threadID); -typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); -#else typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, unsigned (__stdcall * func) (void @@ -99,13 +97,12 @@ typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, void *arg, unsigned, unsigned *threadID); typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); -#endif /** * Create a thread. */ extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(SDL_ThreadFunction fn, void *data, +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread); @@ -114,26 +111,50 @@ SDL_CreateThread(SDL_ThreadFunction fn, void *data, /** * Create a thread. */ -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, NULL, NULL) +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, NULL, NULL) #else /** * Create a thread. */ -#define SDL_CreateThread(fn, data) SDL_CreateThread(fn, data, _beginthreadex, _endthreadex) +#define SDL_CreateThread(fn, name, data) SDL_CreateThread(fn, name, data, _beginthreadex, _endthreadex) #endif #else /** * Create a thread. + * + * Thread naming is a little complicated: Most systems have very small + * limits for the string length (BeOS has 32 bytes, Linux currently has 16, + * Visual C++ 6.0 has nine!), and possibly other arbitrary rules. You'll + * have to see what happens with your system's debugger. The name should be + * UTF-8 (but using the naming limits of C identifiers is a better bet). + * There are no requirements for thread naming conventions, so long as the + * string is null-terminated UTF-8, but these guidelines are helpful in + * choosing a name: + * + * http://stackoverflow.com/questions/149932/naming-conventions-for-threads + * + * If a system imposes requirements, SDL will try to munge the string for + * it (truncate, etc), but the original string contents will be available + * from SDL_GetThreadName(). */ extern DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(SDL_ThreadFunction fn, void *data); +SDL_CreateThread(SDL_ThreadFunction fn, const char *name, void *data); #endif +/** + * Get the thread name, as it was specified in SDL_CreateThread(). + * This function returns a pointer to a UTF-8 string that names the + * specified thread, or NULL if it doesn't have a name. This is internal + * memory, not to be free()'d by the caller, and remains valid until the + * specified thread is cleaned up by SDL_WaitThread(). + */ +extern DECLSPEC const char *SDLCALL SDL_GetThreadName(SDL_Thread *thread); + /** * Get the thread identifier for the current thread. */ @@ -146,6 +167,11 @@ extern DECLSPEC SDL_threadID SDLCALL SDL_ThreadID(void); */ extern DECLSPEC SDL_threadID SDLCALL SDL_GetThreadID(SDL_Thread * thread); +/** + * Set the priority for the current thread + */ +extern DECLSPEC int SDLCALL SDL_SetThreadPriority(SDL_ThreadPriority priority); + /** * Wait for a thread to finish. * diff --git a/project/jni/sdl-1.3/include/SDL_timer.h b/project/jni/sdl-1.3/include/SDL_timer.h index 91160f6f9..bb1abaecd 100644 --- a/project/jni/sdl-1.3/include/SDL_timer.h +++ b/project/jni/sdl-1.3/include/SDL_timer.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_timer_h @@ -41,104 +40,60 @@ extern "C" { #endif /** - * This is the OS scheduler timeslice, in milliseconds. - */ -#define SDL_TIMESLICE 10 - -/** - * This is the maximum resolution of the SDL timer on all platforms. - */ -#define TIMER_RESOLUTION 10 /**< Experimentally determined */ - -/** - * Get the number of milliseconds since the SDL library initialization. + * \brief Get the number of milliseconds since the SDL library initialization. * - * Note that this value wraps if the program runs for more than ~49 days. + * \note This value wraps if the program runs for more than ~49 days. */ extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void); /** - * Wait a specified number of milliseconds before returning. + * \brief Get the current value of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceCounter(void); + +/** + * \brief Get the count per second of the high resolution counter + */ +extern DECLSPEC Uint64 SDLCALL SDL_GetPerformanceFrequency(void); + +/** + * \brief Wait a specified number of milliseconds before returning. */ extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms); /** * Function prototype for the timer callback function. - */ -typedef Uint32(SDLCALL * SDL_TimerCallback) (Uint32 interval); - -/** - * Set a callback to run after the specified number of milliseconds has - * elapsed. The callback function is passed the current timer interval - * and returns the next timer interval. If the returned value is the - * same as the one passed in, the periodic alarm continues, otherwise a - * new alarm is scheduled. If the callback returns 0, the periodic alarm - * is cancelled. - * - * To cancel a currently running timer, call - * \code SDL_SetTimer(0, NULL); \endcode - * - * The timer callback function may run in a different thread than your - * main code, and so shouldn't call any functions from within itself. - * - * The maximum resolution of this timer is 10 ms, which means that if - * you request a 16 ms timer, your callback will run approximately 20 ms - * later on an unloaded system. If you wanted to set a flag signaling - * a frame update at 30 frames per second (every 33 ms), you might set a - * timer for 30 ms: - * \code - * SDL_SetTimer((33/10)*10, flag_update); - * \endcode - * - * If you use this function, you need to pass ::SDL_INIT_TIMER to SDL_Init(). - * - * Under UNIX, you should not use raise or use SIGALRM and this function - * in the same program, as it is implemented using setitimer(). You also - * should not use this function in multi-threaded applications as signals - * to multi-threaded apps have undefined behavior in some implementations. - * - * \return 0 if successful, or -1 if there was an error. - */ -extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, - SDL_TimerCallback callback); - -/** - * \name Peter timers - * New timer API, supports multiple timers - * Written by Stephane Peter - */ -/*@{*/ - -/** - * Function prototype for the new timer callback function. * * The callback function is passed the current timer interval and returns * the next timer interval. If the returned value is the same as the one * passed in, the periodic alarm continues, otherwise a new alarm is * scheduled. If the callback returns 0, the periodic alarm is cancelled. */ -typedef Uint32(SDLCALL * SDL_NewTimerCallback) (Uint32 interval, void *param); +typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param); /** - * Definition of the timer ID type. + * Definition of the timer ID type. */ -typedef struct _SDL_TimerID *SDL_TimerID; +typedef int SDL_TimerID; /** - * Add a new timer to the pool of timers already running. - * \return A timer ID, or NULL when an error occurs. + * \brief Add a new timer to the pool of timers already running. + * + * \return A timer ID, or NULL when an error occurs. */ extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval, - SDL_NewTimerCallback - callback, void *param); + SDL_TimerCallback callback, + void *param); /** - * Remove one of the multiple timers knowing its ID. - * \return A boolean value indicating success or failure. + * \brief Remove a timer knowing its ID. + * + * \return A boolean value indicating success or failure. + * + * \warning It is not safe to remove a timer multiple times. */ extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t); -/*@}*//*Peter timers*/ /* Ends C function definitions when using C++ */ #ifdef __cplusplus diff --git a/project/jni/sdl-1.3/include/SDL_touch.h b/project/jni/sdl-1.3/include/SDL_touch.h index e6b3c9557..587efcbfb 100644 --- a/project/jni/sdl-1.3/include/SDL_touch.h +++ b/project/jni/sdl-1.3/include/SDL_touch.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/SDL_types.h b/project/jni/sdl-1.3/include/SDL_types.h index 86279fe4a..7b1217e11 100644 --- a/project/jni/sdl-1.3/include/SDL_types.h +++ b/project/jni/sdl-1.3/include/SDL_types.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/SDL_version.h b/project/jni/sdl-1.3/include/SDL_version.h index d334b9034..3d7ce28fd 100644 --- a/project/jni/sdl-1.3/include/SDL_version.h +++ b/project/jni/sdl-1.3/include/SDL_version.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -30,7 +29,6 @@ #define _SDL_version_h #include "SDL_stdinc.h" -#include "SDL_revision.h" #include "begin_code.h" /* Set up for C function definitions, even when using C++ */ @@ -145,6 +143,16 @@ extern DECLSPEC void SDLCALL SDL_GetVersion(SDL_version * ver); */ extern DECLSPEC const char *SDLCALL SDL_GetRevision(void); +/** + * \brief Get the revision number of SDL that is linked against your program. + * + * Returns a number uniquely identifying the exact revision of the SDL + * library in use. It is an incrementing number based on commits to + * hg.libsdl.org. + */ +extern DECLSPEC int SDLCALL SDL_GetRevisionNumber(void); + + /* Ends C function definitions when using C++ */ #ifdef __cplusplus /* *INDENT-OFF* */ diff --git a/project/jni/sdl-1.3/include/SDL_video.h b/project/jni/sdl-1.3/include/SDL_video.h index 12227fc36..fcdc7788e 100644 --- a/project/jni/sdl-1.3/include/SDL_video.h +++ b/project/jni/sdl-1.3/include/SDL_video.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** @@ -32,8 +31,6 @@ #include "SDL_stdinc.h" #include "SDL_pixels.h" #include "SDL_rect.h" -#include "SDL_blendmode.h" -#include "SDL_scalemode.h" #include "SDL_surface.h" #include "begin_code.h" @@ -99,13 +96,14 @@ typedef struct SDL_Window SDL_Window; */ typedef enum { - SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window, implies borderless */ + SDL_WINDOW_FULLSCREEN = 0x00000001, /**< fullscreen window */ SDL_WINDOW_OPENGL = 0x00000002, /**< window usable with OpenGL context */ SDL_WINDOW_SHOWN = 0x00000004, /**< window is visible */ - SDL_WINDOW_BORDERLESS = 0x00000008, /**< no window decoration */ - SDL_WINDOW_RESIZABLE = 0x00000010, /**< window can be resized */ - SDL_WINDOW_MINIMIZED = 0x00000020, /**< window is minimized */ - SDL_WINDOW_MAXIMIZED = 0x00000040, /**< window is maximized */ + SDL_WINDOW_HIDDEN = 0x00000008, /**< window is not visible */ + SDL_WINDOW_BORDERLESS = 0x00000010, /**< no window decoration */ + SDL_WINDOW_RESIZABLE = 0x00000020, /**< window can be resized */ + SDL_WINDOW_MINIMIZED = 0x00000040, /**< window is minimized */ + SDL_WINDOW_MAXIMIZED = 0x00000080, /**< window is maximized */ SDL_WINDOW_INPUT_GRABBED = 0x00000100, /**< window has grabbed input focus */ SDL_WINDOW_INPUT_FOCUS = 0x00000200, /**< window has input focus */ SDL_WINDOW_MOUSE_FOCUS = 0x00000400, /**< window has mouse focus */ @@ -115,12 +113,20 @@ typedef enum /** * \brief Used to indicate that you don't care what the window position is. */ -#define SDL_WINDOWPOS_UNDEFINED 0x7FFFFFF +#define SDL_WINDOWPOS_UNDEFINED_MASK 0x1FFF0000 +#define SDL_WINDOWPOS_UNDEFINED_DISPLAY(X) (SDL_WINDOWPOS_UNDEFINED_MASK|(X)) +#define SDL_WINDOWPOS_UNDEFINED SDL_WINDOWPOS_UNDEFINED_DISPLAY(0) +#define SDL_WINDOWPOS_ISUNDEFINED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_UNDEFINED_MASK) /** * \brief Used to indicate that the window position should be centered. */ -#define SDL_WINDOWPOS_CENTERED 0x7FFFFFE +#define SDL_WINDOWPOS_CENTERED_MASK 0x2FFF0000 +#define SDL_WINDOWPOS_CENTERED_DISPLAY(X) (SDL_WINDOWPOS_CENTERED_MASK|(X)) +#define SDL_WINDOWPOS_CENTERED SDL_WINDOWPOS_CENTERED_DISPLAY(0) +#define SDL_WINDOWPOS_ISCENTERED(X) \ + (((X)&0xFFFF0000) == SDL_WINDOWPOS_CENTERED_MASK) /** * \brief Event subtype for window events @@ -134,7 +140,8 @@ typedef enum redrawn */ SDL_WINDOWEVENT_MOVED, /**< Window has been moved to data1, data2 */ - SDL_WINDOWEVENT_RESIZED, /**< Window size changed to data1xdata2 */ + SDL_WINDOWEVENT_RESIZED, /**< Window has been resized to data1xdata2 */ + SDL_WINDOWEVENT_SIZE_CHANGED, /**< The window size has changed, either as a result of an API call or through the system or user changing the window size. */ SDL_WINDOWEVENT_MINIMIZED, /**< Window has been minimized */ SDL_WINDOWEVENT_MAXIMIZED, /**< Window has been maximized */ SDL_WINDOWEVENT_RESTORED, /**< Window has been restored to normal size @@ -147,80 +154,6 @@ typedef enum window be closed */ } SDL_WindowEventID; -/** - * \brief Flags used when creating a rendering context - */ -typedef enum -{ - SDL_RENDERER_SINGLEBUFFER = 0x00000001, /**< Render directly to the - window, if possible */ - - SDL_RENDERER_PRESENTCOPY = 0x00000002, /**< Present uses a copy from - back buffer to the front - buffer */ - - SDL_RENDERER_PRESENTFLIP2 = 0x00000004, /**< Present uses a flip, - swapping back buffer and - front buffer */ - - SDL_RENDERER_PRESENTFLIP3 = 0x00000008, /**< Present uses a flip, - rotating between two back - buffers and a front buffer - */ - - SDL_RENDERER_PRESENTDISCARD = 0x00000010, /**< Present leaves the contents - of the backbuffer undefined - */ - - SDL_RENDERER_PRESENTVSYNC = 0x00000020, /**< Present is synchronized - with the refresh rate */ - - SDL_RENDERER_ACCELERATED = 0x00000040 /**< The renderer uses hardware - acceleration */ - - } SDL_RendererFlags; - -/** - * \brief Information on the capabilities of a render driver or context. - */ -typedef struct SDL_RendererInfo -{ - const char *name; /**< The name of the renderer */ - Uint32 flags; /**< Supported ::SDL_RendererFlags */ - Uint32 mod_modes; /**< A mask of supported channel modulation */ - Uint32 blend_modes; /**< A mask of supported blend modes */ - Uint32 scale_modes; /**< A mask of supported scale modes */ - Uint32 num_texture_formats; /**< The number of available texture formats */ - Uint32 texture_formats[50]; /**< The available texture formats */ - int max_texture_width; /**< The maximimum texture width */ - int max_texture_height; /**< The maximimum texture height */ -} SDL_RendererInfo; - -/** - * \brief The access pattern allowed for a texture. - */ -typedef enum -{ - SDL_TEXTUREACCESS_STATIC, /**< Changes rarely, not lockable */ - SDL_TEXTUREACCESS_STREAMING /**< Changes frequently, lockable */ -} SDL_TextureAccess; - -/** - * \brief The texture channel modulation used in SDL_RenderCopy(). - */ -typedef enum -{ - SDL_TEXTUREMODULATE_NONE = 0x00000000, /**< No modulation */ - SDL_TEXTUREMODULATE_COLOR = 0x00000001, /**< srcC = srcC * color */ - SDL_TEXTUREMODULATE_ALPHA = 0x00000002 /**< srcA = srcA * alpha */ -} SDL_TextureModulate; - -/** - * \brief An efficient driver-specific representation of pixel data - */ -struct SDL_Texture; -typedef struct SDL_Texture SDL_Texture; - /** * \brief An opaque handle to an OpenGL context. */ @@ -278,8 +211,6 @@ extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); * \param driver_name Initialize a specific driver by name, or NULL for the * default video driver. * - * \param flags FIXME: Still needed? - * * \return 0 on success, -1 on error * * This function initializes the video subsystem; setting up a connection @@ -288,8 +219,7 @@ extern DECLSPEC const char *SDLCALL SDL_GetVideoDriver(int index); * * \sa SDL_VideoQuit() */ -extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name, - Uint32 flags); +extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name); /** * \brief Shuts down the video subsystem. @@ -315,7 +245,6 @@ extern DECLSPEC const char *SDLCALL SDL_GetCurrentVideoDriver(void); * \brief Returns the number of available video displays. * * \sa SDL_GetDisplayBounds() - * \sa SDL_SelectVideoDisplay() */ extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); @@ -327,34 +256,14 @@ extern DECLSPEC int SDLCALL SDL_GetNumVideoDisplays(void); * * \sa SDL_GetNumVideoDisplays() */ -extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int index, SDL_Rect * rect); +extern DECLSPEC int SDLCALL SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect); /** - * \brief Set the index of the currently selected display. - * - * \return 0 on success, or -1 if the index is out of range. - * - * \sa SDL_GetNumVideoDisplays() - * \sa SDL_GetCurrentVideoDisplay() - */ -extern DECLSPEC int SDLCALL SDL_SelectVideoDisplay(int index); - -/** - * \brief Get the index of the currently selected display. - * - * \return The index of the currently selected display. - * - * \sa SDL_GetNumVideoDisplays() - * \sa SDL_SelectVideoDisplay() - */ -extern DECLSPEC int SDLCALL SDL_GetCurrentVideoDisplay(void); - -/** - * \brief Returns the number of available display modes for the current display. + * \brief Returns the number of available display modes. * * \sa SDL_GetDisplayMode() */ -extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void); +extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(int displayIndex); /** * \brief Fill in information about a specific display mode. @@ -367,19 +276,18 @@ extern DECLSPEC int SDLCALL SDL_GetNumDisplayModes(void); * * \sa SDL_GetNumDisplayModes() */ -extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int index, +extern DECLSPEC int SDLCALL SDL_GetDisplayMode(int displayIndex, int modeIndex, SDL_DisplayMode * mode); /** - * \brief Fill in information about the desktop display mode for the current - * display. + * \brief Fill in information about the desktop display mode. */ -extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode); +extern DECLSPEC int SDLCALL SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode); /** * \brief Fill in information about the current display mode. */ -extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode); +extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode); /** @@ -402,16 +310,21 @@ extern DECLSPEC int SDLCALL SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode); * \sa SDL_GetNumDisplayModes() * \sa SDL_GetDisplayMode() */ -extern DECLSPEC SDL_DisplayMode *SDLCALL SDL_GetClosestDisplayMode(const - SDL_DisplayMode - * mode, - SDL_DisplayMode - * closest); +extern DECLSPEC SDL_DisplayMode * SDLCALL SDL_GetClosestDisplayMode(int displayIndex, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); /** - * \brief Set the display mode used when a fullscreen window is visible - * on the currently selected display. By default the window's - * dimensions and the desktop format and refresh rate are used. + * \brief Get the display index associated with a window. + * + * \return the display index of the display containing the center of the + * window, or -1 on error. + */ +extern DECLSPEC int SDLCALL SDL_GetWindowDisplay(SDL_Window * window); + +/** + * \brief Set the display mode used when a fullscreen window is visible. + * + * By default the window's dimensions and the desktop format and refresh rate + * are used. * * \param mode The mode to use, or NULL for the default mode. * @@ -426,7 +339,7 @@ extern DECLSPEC int SDLCALL SDL_SetWindowDisplayMode(SDL_Window * window, /** * \brief Fill in information about the display mode used when a fullscreen - * window is visible on the currently selected display. + * window is visible. * * \sa SDL_SetWindowDisplayMode() * \sa SDL_SetWindowFullscreen() @@ -435,72 +348,9 @@ extern DECLSPEC int SDLCALL SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode); /** - * \brief Set the palette entries for indexed display modes. - * - * \return 0 on success, or -1 if the display mode isn't palettized or the - * colors couldn't be set. + * \brief Get the pixel format associated with the window. */ -extern DECLSPEC int SDLCALL SDL_SetDisplayPalette(const SDL_Color * colors, - int firstcolor, - int ncolors); - -/** - * \brief Gets the palette entries for indexed display modes. - * - * \return 0 on success, or -1 if the display mode isn't palettized - */ -extern DECLSPEC int SDLCALL SDL_GetDisplayPalette(SDL_Color * colors, - int firstcolor, - int ncolors); - -/** - * \brief Set the gamma correction for each of the color channels on the - * currently selected display. - * - * \return 0 on success, or -1 if setting the gamma isn't supported. - * - * \sa SDL_SetGammaRamp() - */ -extern DECLSPEC int SDLCALL SDL_SetGamma(float red, float green, float blue); - -/** - * \brief Set the gamma ramp for the currently selected display. - * - * \param red The translation table for the red channel, or NULL. - * \param green The translation table for the green channel, or NULL. - * \param blue The translation table for the blue channel, or NULL. - * - * \return 0 on success, or -1 if gamma ramps are unsupported. - * - * Set the gamma translation table for the red, green, and blue channels - * of the video hardware. Each table is an array of 256 16-bit quantities, - * representing a mapping between the input and output for that channel. - * The input is the index into the array, and the output is the 16-bit - * gamma value at that index, scaled to the output color precision. - * - * \sa SDL_GetGammaRamp() - */ -extern DECLSPEC int SDLCALL SDL_SetGammaRamp(const Uint16 * red, - const Uint16 * green, - const Uint16 * blue); - -/** - * \brief Get the gamma ramp for the currently selected display. - * - * \param red A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the red channel, or NULL. - * \param green A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the green channel, or NULL. - * \param blue A pointer to a 256 element array of 16-bit quantities to hold - * the translation table for the blue channel, or NULL. - * - * \return 0 on success, or -1 if gamma ramps are unsupported. - * - * \sa SDL_SetGammaRamp() - */ -extern DECLSPEC int SDLCALL SDL_GetGammaRamp(Uint16 * red, Uint16 * green, - Uint16 * blue); - +extern DECLSPEC Uint32 SDLCALL SDL_GetWindowPixelFormat(SDL_Window * window); /** * \brief Create a window with the specified position, dimensions, and flags. @@ -576,24 +426,39 @@ extern DECLSPEC void SDLCALL SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon); /** - * \brief Associate an arbitrary pointer with a window. + * \brief Associate an arbitrary named pointer with a window. * + * \param window The window to associate with the pointer. + * \param name The name of the pointer. + * \param userdata The associated pointer. + * + * \return The previous value associated with 'name' + * + * \note The name is case-sensitive. + * * \sa SDL_GetWindowData() */ -extern DECLSPEC void SDLCALL SDL_SetWindowData(SDL_Window * window, - void *userdata); +extern DECLSPEC void* SDLCALL SDL_SetWindowData(SDL_Window * window, + const char *name, + void *userdata); /** * \brief Retrieve the data pointer associated with a window. * + * \param window The window to query. + * \param name The name of the pointer. + * + * \return The value associated with 'name' + * * \sa SDL_SetWindowData() */ -extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window); +extern DECLSPEC void *SDLCALL SDL_GetWindowData(SDL_Window * window, + const char *name); /** * \brief Set the position of a window. * - * \param window The window to reposition. + * \param window The window to reposition. * \param x The x coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or ::SDL_WINDOWPOS_UNDEFINED. * \param y The y coordinate of the window, ::SDL_WINDOWPOS_CENTERED, or @@ -683,602 +548,129 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window); * \sa SDL_GetWindowDisplayMode() */ extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window, - int fullscreen); + SDL_bool fullscreen); + +/** + * \brief Get the SDL surface associated with the window. + * + * \return The window's framebuffer surface, or NULL on error. + * + * A new surface will be created with the optimal format for the window, + * if necessary. This surface will be freed when the window is destroyed. + * + * \note You may not combine this with 3D or the rendering API on this window. + * + * \sa SDL_UpdateWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC SDL_Surface * SDLCALL SDL_GetWindowSurface(SDL_Window * window); + +/** + * \brief Copy the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRects() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurface(SDL_Window * window); + +/** + * \brief Copy a number of rectangles on the window surface to the screen. + * + * \return 0 on success, or -1 on error. + * + * \sa SDL_GetWindowSurface() + * \sa SDL_UpdateWindowSurfaceRect() + */ +extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window, + SDL_Rect * rects, + int numrects); /** * \brief Set a window's input grab mode. * - * \param mode This is 1 to grab input, and 0 to release input. + * \param grabbed This is SDL_TRUE to grab input, and SDL_FALSE to release input. * * \sa SDL_GetWindowGrab() */ extern DECLSPEC void SDLCALL SDL_SetWindowGrab(SDL_Window * window, - int mode); + SDL_bool grabbed); /** * \brief Get a window's input grab mode. * - * \return This returns 1 if input is grabbed, and 0 otherwise. + * \return This returns SDL_TRUE if input is grabbed, and SDL_FALSE otherwise. * * \sa SDL_SetWindowGrab() */ -extern DECLSPEC int SDLCALL SDL_GetWindowGrab(SDL_Window * window); +extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowGrab(SDL_Window * window); /** - * \brief Get driver specific information about a window. + * \brief Set the brightness (gamma correction) for a window. * - * \note Include SDL_syswm.h for the declaration of SDL_SysWMinfo. + * \return 0 on success, or -1 if setting the brightness isn't supported. + * + * \sa SDL_GetWindowBrightness() + * \sa SDL_SetWindowGammaRamp() */ -struct SDL_SysWMinfo; -extern DECLSPEC SDL_bool SDLCALL SDL_GetWindowWMInfo(SDL_Window * window, - struct SDL_SysWMinfo - *info); +extern DECLSPEC int SDLCALL SDL_SetWindowBrightness(SDL_Window * window, float brightness); + +/** + * \brief Get the brightness (gamma correction) for a window. + * + * \return The last brightness value passed to SDL_SetWindowBrightness() + * + * \sa SDL_SetWindowBrightness() + */ +extern DECLSPEC float SDLCALL SDL_GetWindowBrightness(SDL_Window * window); + +/** + * \brief Set the gamma ramp for a window. + * + * \param red The translation table for the red channel, or NULL. + * \param green The translation table for the green channel, or NULL. + * \param blue The translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * Set the gamma translation table for the red, green, and blue channels + * of the video hardware. Each table is an array of 256 16-bit quantities, + * representing a mapping between the input and output for that channel. + * The input is the index into the array, and the output is the 16-bit + * gamma value at that index, scaled to the output color precision. + * + * \sa SDL_GetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_SetWindowGammaRamp(SDL_Window * window, + const Uint16 * red, + const Uint16 * green, + const Uint16 * blue); + +/** + * \brief Get the gamma ramp for a window. + * + * \param red A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the red channel, or NULL. + * \param green A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the green channel, or NULL. + * \param blue A pointer to a 256 element array of 16-bit quantities to hold + * the translation table for the blue channel, or NULL. + * + * \return 0 on success, or -1 if gamma ramps are unsupported. + * + * \sa SDL_SetWindowGammaRamp() + */ +extern DECLSPEC int SDLCALL SDL_GetWindowGammaRamp(SDL_Window * window, + Uint16 * red, + Uint16 * green, + Uint16 * blue); /** * \brief Destroy a window. */ extern DECLSPEC void SDLCALL SDL_DestroyWindow(SDL_Window * window); -/** - * \brief Get the number of 2D rendering drivers available for the current - * display. - * - * A render driver is a set of code that handles rendering and texture - * management on a particular display. Normally there is only one, but - * some drivers may have several available with different capabilities. - * - * \sa SDL_GetRenderDriverInfo() - * \sa SDL_CreateRenderer() - */ -extern DECLSPEC int SDLCALL SDL_GetNumRenderDrivers(void); - -/** - * \brief Get information about a specific 2D rendering driver for the current - * display. - * - * \param index The index of the driver to query information about. - * \param info A pointer to an SDL_RendererInfo struct to be filled with - * information on the rendering driver. - * - * \return 0 on success, -1 if the index was out of range. - * - * \sa SDL_CreateRenderer() - */ -extern DECLSPEC int SDLCALL SDL_GetRenderDriverInfo(int index, - SDL_RendererInfo * info); - -/** - * \brief Create and make active a 2D rendering context for a window. - * - * \param window The window where rendering is displayed. - * \param index The index of the rendering driver to initialize, or -1 to - * initialize the first one supporting the requested flags. - * \param flags ::SDL_RendererFlags. - * - * \return 0 on success, -1 if there was an error creating the renderer. - * - * \sa SDL_SelectRenderer() - * \sa SDL_GetRendererInfo() - * \sa SDL_DestroyRenderer() - */ -extern DECLSPEC int SDLCALL SDL_CreateRenderer(SDL_Window * window, - int index, Uint32 flags); - -/** - * \brief Select the rendering context for a particular window. - * - * \return 0 on success, -1 if the selected window doesn't have a - * rendering context. - */ -extern DECLSPEC int SDLCALL SDL_SelectRenderer(SDL_Window * window); - -/** - * \brief Get information about the current rendering context. - */ -extern DECLSPEC int SDLCALL SDL_GetRendererInfo(SDL_RendererInfo * info); - -/** - * \brief Create a texture for the current rendering context. - * - * \param format The format of the texture. - * \param access One of the enumerated values in ::SDL_TextureAccess. - * \param w The width of the texture in pixels. - * \param h The height of the texture in pixels. - * - * \return The created texture is returned, or 0 if no rendering context was - * active, the format was unsupported, or the width or height were out - * of range. - * - * \sa SDL_QueryTexture() - * \sa SDL_DestroyTexture() - */ -extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTexture(Uint32 format, - int access, int w, - int h); - -/** - * \brief Create a texture from an existing surface. - * - * \param format The format of the texture, or 0 to pick an appropriate format. - * \param surface The surface containing pixel data used to fill the texture. - * - * \return The created texture is returned, or 0 if no rendering context was - * active, the format was unsupported, or the surface width or height - * were out of range. - * - * \note The surface is not modified or freed by this function. - * - * \sa SDL_QueryTexture() - * \sa SDL_DestroyTexture() - */ -extern DECLSPEC SDL_Texture * SDLCALL SDL_CreateTextureFromSurface(Uint32 - format, - SDL_Surface - * surface); - -/** - * \brief Query the attributes of a texture - * - * \param texture A texture to be queried. - * \param format A pointer filled in with the raw format of the texture. The - * actual format may differ, but pixel transfers will use this - * format. - * \param access A pointer filled in with the actual access to the texture. - * \param w A pointer filled in with the width of the texture in pixels. - * \param h A pointer filled in with the height of the texture in pixels. - * - * \return 0 on success, or -1 if the texture is not valid. - */ -extern DECLSPEC int SDLCALL SDL_QueryTexture(SDL_Texture * texture, - Uint32 * format, int *access, - int *w, int *h); - -/** - * \brief Query the pixels of a texture, if the texture does not need to be - * locked for pixel access. - * - * \param texture A texture to be queried, which was created with - * ::SDL_TEXTUREACCESS_STREAMING. - * \param pixels A pointer filled with a pointer to the pixels for the - * texture. - * \param pitch A pointer filled in with the pitch of the pixel data. - * - * \return 0 on success, or -1 if the texture is not valid, or must be locked - * for pixel access. - */ -extern DECLSPEC int SDLCALL SDL_QueryTexturePixels(SDL_Texture * texture, - void **pixels, int *pitch); - -/** - * \brief Set the color palette of an indexed texture. - * - * \param texture The texture to update. - * \param colors The array of RGB color data. - * \param firstcolor The first index to update. - * \param ncolors The number of palette entries to fill with the color data. - * - * \return 0 on success, or -1 if the texture is not valid or not an indexed - * texture. - */ -extern DECLSPEC int SDLCALL SDL_SetTexturePalette(SDL_Texture * texture, - const SDL_Color * colors, - int firstcolor, - int ncolors); - -/** - * \brief Get the color palette from an indexed texture if it has one. - * - * \param texture The texture to update. - * \param colors The array to fill with RGB color data. - * \param firstcolor The first index to retrieve. - * \param ncolors The number of palette entries to retrieve. - * - * \return 0 on success, or -1 if the texture is not valid or not an indexed - * texture. - */ -extern DECLSPEC int SDLCALL SDL_GetTexturePalette(SDL_Texture * texture, - SDL_Color * colors, - int firstcolor, - int ncolors); - -/** - * \brief Set an additional color value used in render copy operations. - * - * \param texture The texture to update. - * \param r The red color value multiplied into copy operations. - * \param g The green color value multiplied into copy operations. - * \param b The blue color value multiplied into copy operations. - * - * \return 0 on success, or -1 if the texture is not valid or color modulation - * is not supported. - * - * \sa SDL_GetTextureColorMod() - */ -extern DECLSPEC int SDLCALL SDL_SetTextureColorMod(SDL_Texture * texture, - Uint8 r, Uint8 g, Uint8 b); - - -/** - * \brief Get the additional color value used in render copy operations. - * - * \param texture The texture to query. - * \param r A pointer filled in with the current red color value. - * \param g A pointer filled in with the current green color value. - * \param b A pointer filled in with the current blue color value. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureColorMod() - */ -extern DECLSPEC int SDLCALL SDL_GetTextureColorMod(SDL_Texture * texture, - Uint8 * r, Uint8 * g, - Uint8 * b); - -/** - * \brief Set an additional alpha value used in render copy operations. - * - * \param texture The texture to update. - * \param alpha The alpha value multiplied into copy operations. - * - * \return 0 on success, or -1 if the texture is not valid or alpha modulation - * is not supported. - * - * \sa SDL_GetTextureAlphaMod() - */ -extern DECLSPEC int SDLCALL SDL_SetTextureAlphaMod(SDL_Texture * texture, - Uint8 alpha); - -/** - * \brief Get the additional alpha value used in render copy operations. - * - * \param texture The texture to query. - * \param alpha A pointer filled in with the current alpha value. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureAlphaMod() - */ -extern DECLSPEC int SDLCALL SDL_GetTextureAlphaMod(SDL_Texture * texture, - Uint8 * alpha); - -/** - * \brief Set the blend mode used for texture copy operations. - * - * \param texture The texture to update. - * \param blendMode ::SDL_BlendMode to use for texture blending. - * - * \return 0 on success, or -1 if the texture is not valid or the blend mode is - * not supported. - * - * \note If the blend mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetTextureBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_SetTextureBlendMode(SDL_Texture * texture, - SDL_BlendMode blendMode); - -/** - * \brief Get the blend mode used for texture copy operations. - * - * \param texture The texture to query. - * \param blendMode A pointer filled in with the current blend mode. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_GetTextureBlendMode(SDL_Texture * texture, - SDL_BlendMode *blendMode); - -/** - * \brief Set the scale mode used for texture copy operations. - * - * \param texture The texture to update. - * \param scaleMode ::SDL_ScaleMode to use for texture scaling. - * - * \return 0 on success, or -1 if the texture is not valid or the scale mode is - * not supported. - * - * \note If the scale mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetTextureScaleMode() - */ -extern DECLSPEC int SDLCALL SDL_SetTextureScaleMode(SDL_Texture * texture, - SDL_ScaleMode scaleMode); - -/** - * \brief Get the scale mode used for texture copy operations. - * - * \param texture The texture to query. - * \param scaleMode A pointer filled in with the current scale mode. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \sa SDL_SetTextureScaleMode() - */ -extern DECLSPEC int SDLCALL SDL_GetTextureScaleMode(SDL_Texture * texture, - SDL_ScaleMode *scaleMode); - -/** - * \brief Update the given texture rectangle with new pixel data. - * - * \param texture The texture to update - * \param rect A pointer to the rectangle of pixels to update, or NULL to - * update the entire texture. - * \param pixels The raw pixel data. - * \param pitch The number of bytes between rows of pixel data. - * - * \return 0 on success, or -1 if the texture is not valid. - * - * \note This is a fairly slow function. - */ -extern DECLSPEC int SDLCALL SDL_UpdateTexture(SDL_Texture * texture, - const SDL_Rect * rect, - const void *pixels, int pitch); - -/** - * \brief Lock a portion of the texture for pixel access. - * - * \param texture The texture to lock for access, which was created with - * ::SDL_TEXTUREACCESS_STREAMING. - * \param rect A pointer to the rectangle to lock for access. If the rect - * is NULL, the entire texture will be locked. - * \param markDirty If this is nonzero, the locked area will be marked dirty - * when the texture is unlocked. - * \param pixels This is filled in with a pointer to the locked pixels, - * appropriately offset by the locked area. - * \param pitch This is filled in with the pitch of the locked pixels. - * - * \return 0 on success, or -1 if the texture is not valid or was created with - * ::SDL_TEXTUREACCESS_STATIC. - * - * \sa SDL_DirtyTexture() - * \sa SDL_UnlockTexture() - */ -extern DECLSPEC int SDLCALL SDL_LockTexture(SDL_Texture * texture, - const SDL_Rect * rect, - int markDirty, void **pixels, - int *pitch); - -/** - * \brief Unlock a texture, uploading the changes to video memory, if needed. - * - * \sa SDL_LockTexture() - * \sa SDL_DirtyTexture() - */ -extern DECLSPEC void SDLCALL SDL_UnlockTexture(SDL_Texture * texture); - -/** - * \brief Mark the specified rectangles of the texture as dirty. - * - * \param texture The texture to mark dirty, which was created with - * ::SDL_TEXTUREACCESS_STREAMING. - * \param numrects The number of rectangles pointed to by rects. - * \param rects The pointer to an array of dirty rectangles. - * - * \sa SDL_LockTexture() - * \sa SDL_UnlockTexture() - */ -extern DECLSPEC void SDLCALL SDL_DirtyTexture(SDL_Texture * texture, - int numrects, - const SDL_Rect * rects); - -/** - * \brief Set the color used for drawing operations (Fill and Line). - * - * \param r The red value used to draw on the rendering target. - * \param g The green value used to draw on the rendering target. - * \param b The blue value used to draw on the rendering target. - * \param a The alpha value used to draw on the rendering target, usually - * ::SDL_ALPHA_OPAQUE (255). - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, - Uint8 a); - -/** - * \brief Get the color used for drawing operations (Fill and Line). - * - * \param r A pointer to the red value used to draw on the rendering target. - * \param g A pointer to the green value used to draw on the rendering target. - * \param b A pointer to the blue value used to draw on the rendering target. - * \param a A pointer to the alpha value used to draw on the rendering target, - * usually ::SDL_ALPHA_OPAQUE (255). - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b, - Uint8 * a); - -/** - * \brief Set the blend mode used for drawing operations (Fill and Line). - * - * \param blendMode ::SDL_BlendMode to use for blending. - * - * \return 0 on success, or -1 if there is no rendering context current. - * - * \note If the blend mode is not supported, the closest supported mode is - * chosen. - * - * \sa SDL_GetRenderDrawBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode); - -/** - * \brief Get the blend mode used for drawing operations. - * - * \param blendMode A pointer filled in with the current blend mode. - * - * \return 0 on success, or -1 if there is no rendering context current. - * - * \sa SDL_SetRenderDrawBlendMode() - */ -extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(SDL_BlendMode *blendMode); - -/** - * \brief Clear the current rendering target with the drawing color - */ -extern DECLSPEC int SDLCALL SDL_RenderClear(void); - -/** - * \brief Draw a point on the current rendering target. - * - * \param x The x coordinate of the point. - * \param y The y coordinate of the point. - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawPoint(int x, int y); - -/** - * \brief Draw multiple points on the current rendering target. - * - * \param points The points to draw - * \param count The number of points to draw - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawPoints(const SDL_Point * points, - int count); - -/** - * \brief Draw a line on the current rendering target. - * - * \param x1 The x coordinate of the start point. - * \param y1 The y coordinate of the start point. - * \param x2 The x coordinate of the end point. - * \param y2 The y coordinate of the end point. - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawLine(int x1, int y1, int x2, int y2); - -/** - * \brief Draw a series of connected lines on the current rendering target. - * - * \param points The points along the lines - * \param count The number of points, drawing count-1 lines - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawLines(const SDL_Point * points, - int count); - -/** - * \brief Draw a rectangle on the current rendering target. - * - * \param rect A pointer to the destination rectangle, or NULL to outline the entire rendering target. - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawRect(const SDL_Rect * rect); - -/** - * \brief Draw some number of rectangles on the current rendering target. - * - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDLCALL SDL_RenderDrawRects(const SDL_Rect ** rects, int count); - -/** - * \brief Fill a rectangle on the current rendering target with the drawing color. - * - * \param rect A pointer to the destination rectangle, or NULL for the entire - * rendering target. - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDLCALL SDL_RenderFillRect(const SDL_Rect * rect); - -/** - * \brief Fill some number of rectangles on the current rendering target with the drawing color. - * - * \param rects A pointer to an array of destination rectangles. - * \param count The number of rectangles. - * - * \return 0 on success, or -1 if there is no rendering context current. - */ -extern DECLSPEC int SDLCALL SDL_RenderFillRects(const SDL_Rect ** rect, int count); - -/** - * \brief Copy a portion of the texture to the current rendering target. - * - * \param texture The source texture. - * \param srcrect A pointer to the source rectangle, or NULL for the entire - * texture. - * \param dstrect A pointer to the destination rectangle, or NULL for the - * entire rendering target. - * - * \return 0 on success, or -1 if there is no rendering context current, or the - * driver doesn't support the requested operation. - */ -extern DECLSPEC int SDLCALL SDL_RenderCopy(SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_Rect * dstrect); - -/** - * \brief Read pixels from the current rendering target. - * - * \param rect A pointer to the rectangle to read, or NULL for the entire - * render target. - * \param format The desired format of the pixel data, or 0 to use the format - * of the rendering target - * \param pixels A pointer to be filled in with the pixel data - * \param pitch The pitch of the pixels parameter. - * - * \return 0 on success, or -1 if pixel reading is not supported. - * - * \warning This is a very slow operation, and should not be used frequently. - */ -extern DECLSPEC int SDLCALL SDL_RenderReadPixels(const SDL_Rect * rect, - Uint32 format, - void *pixels, int pitch); - -/** - * \brief Write pixels to the current rendering target. - * - * \param rect A pointer to the rectangle to write, or NULL for the entire - * render target. - * \param format The format of the pixel data, or 0 to use the format - * of the rendering target - * \param pixels A pointer to the pixel data to write. - * \param pitch The pitch of the pixels parameter. - * - * \return 0 on success, or -1 if pixel writing is not supported. - * - * \warning This is a very slow operation, and should not be used frequently. - */ -extern DECLSPEC int SDLCALL SDL_RenderWritePixels(const SDL_Rect * rect, - Uint32 format, - const void *pixels, - int pitch); - -/** - * \brief Update the screen with rendering performed. - */ -extern DECLSPEC void SDLCALL SDL_RenderPresent(void); - -/** - * \brief Destroy the specified texture. - * - * \sa SDL_CreateTexture() - * \sa SDL_CreateTextureFromSurface() - */ -extern DECLSPEC void SDLCALL SDL_DestroyTexture(SDL_Texture * texture); - -/** - * \brief Destroy the rendering context for a window and free associated - * textures. - * - * \sa SDL_CreateRenderer() - */ -extern DECLSPEC void SDLCALL SDL_DestroyRenderer(SDL_Window * window); /** * \brief Returns whether the screensaver is currently enabled (default on). diff --git a/project/jni/sdl-1.3/include/begin_code.h b/project/jni/sdl-1.3/include/begin_code.h index 395dc7c6a..851fd9203 100644 --- a/project/jni/sdl-1.3/include/begin_code.h +++ b/project/jni/sdl-1.3/include/begin_code.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/close_code.h b/project/jni/sdl-1.3/include/close_code.h index 4b4e8a49d..7ecf255fd 100644 --- a/project/jni/sdl-1.3/include/close_code.h +++ b/project/jni/sdl-1.3/include/close_code.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /** diff --git a/project/jni/sdl-1.3/include/doxyfile b/project/jni/sdl-1.3/include/doxyfile index e53097f4b..103475527 100644 --- a/project/jni/sdl-1.3/include/doxyfile +++ b/project/jni/sdl-1.3/include/doxyfile @@ -1,4 +1,4 @@ -# Doxyfile 1.4.4 +# Doxyfile 1.5.9 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project @@ -14,6 +14,14 @@ # Project related configuration options #--------------------------------------------------------------------------- +# This tag specifies the encoding used for all characters in the config file +# that follow. The default is UTF-8 which is also the encoding used for all +# text before the first occurrence of this tag. Doxygen uses libiconv (or the +# iconv built into libc) for the transcoding. See +# http://www.gnu.org/software/libiconv for the list of possible encodings. + +DOXYFILE_ENCODING = UTF-8 + # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. @@ -30,7 +38,7 @@ PROJECT_NUMBER = 1.3.0 # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. -OUTPUT_DIRECTORY = docs +OUTPUT_DIRECTORY = . # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output @@ -39,30 +47,21 @@ OUTPUT_DIRECTORY = docs # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. -CREATE_SUBDIRS = NO +CREATE_SUBDIRS = YES # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: -# Brazilian, Catalan, Chinese, Chinese-Traditional, Croatian, Czech, Danish, -# Dutch, Finnish, French, German, Greek, Hungarian, Italian, Japanese, -# Japanese-en (Japanese with English messages), Korean, Korean-en, Norwegian, -# Polish, Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, -# Swedish, and Ukrainian. +# Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, +# Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, +# Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English +# messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, +# Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrilic, Slovak, +# Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English -# This tag can be used to specify the encoding used in the generated output. -# The encoding is not always determined by the language that is chosen, -# but also whether or not the output is meant for Windows or non-Windows users. -# In case there is a difference, setting the USE_WINDOWS_ENCODING tag to YES -# forces the Windows encoding (this is the default for the Windows binary), -# whereas setting the tag to NO uses a Unix-style encoding (the default for -# all platforms other than Windows). - -USE_WINDOWS_ENCODING = NO - # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). @@ -87,13 +86,23 @@ REPEAT_BRIEF = YES # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" -ABBREVIATE_BRIEF = +ABBREVIATE_BRIEF = "The $name class" \ + "The $name widget" \ + "The $name file" \ + is \ + provides \ + specifies \ + contains \ + represents \ + a \ + an \ + the # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. -ALWAYS_DETAILED_SEC = NO +ALWAYS_DETAILED_SEC = YES # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those @@ -115,7 +124,7 @@ FULL_PATH_NAMES = YES # If left blank the directory from which doxygen is run is used as the # path to strip. -STRIP_FROM_PATH = +STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells @@ -135,11 +144,19 @@ SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc -# comments will behave just like the Qt-style comments (thus requiring an -# explicit @brief command for a brief description. +# comments will behave just like regular Qt-style comments +# (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO +# If the QT_AUTOBRIEF tag is set to YES then Doxygen will +# interpret the first line (until the first dot) of a Qt-style +# comment as the brief description. If set to NO, the comments +# will behave just like regular Qt-style comments (thus requiring +# an explicit \brief command for a brief description.) + +QT_AUTOBRIEF = NO + # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. @@ -148,26 +165,12 @@ JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO -# If the DETAILS_AT_TOP tag is set to YES then Doxygen -# will output the detailed description near the top, like JavaDoc. -# If set to NO, the detailed description appears after the member -# documentation. - -DETAILS_AT_TOP = NO - # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES -# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC -# tag is set to YES, then doxygen will reuse the documentation of the first -# member in the group (if any) for the other members of the group. By default -# all members of a group must be documented explicitly. - -DISTRIBUTE_GROUP_DOC = NO - # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. @@ -186,7 +189,8 @@ TAB_SIZE = 8 # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. -ALIASES = +ALIASES = "defined=\"\def\"" \ + "discussion=\"\par Discussion:\n\"" # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. @@ -195,13 +199,73 @@ ALIASES = OPTIMIZE_OUTPUT_FOR_C = YES -# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java sources -# only. Doxygen will then generate output that is more tailored for Java. -# For instance, namespaces will be presented as packages, qualified scopes -# will look different, etc. +# Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java +# sources only. Doxygen will then generate output that is more tailored for +# Java. For instance, namespaces will be presented as packages, qualified +# scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO +# Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran +# sources only. Doxygen will then generate output that is more tailored for +# Fortran. + +OPTIMIZE_FOR_FORTRAN = NO + +# Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL +# sources. Doxygen will then generate output that is tailored for +# VHDL. + +OPTIMIZE_OUTPUT_VHDL = NO + +# Doxygen selects the parser to use depending on the extension of the files it parses. +# With this tag you can assign which parser to use for a given extension. +# Doxygen has a built-in mapping, but you can override or extend it using this tag. +# The format is ext=language, where ext is a file extension, and language is one of +# the parsers supported by doxygen: IDL, Java, Javascript, C#, C, C++, D, PHP, +# Objective-C, Python, Fortran, VHDL, C, C++. For instance to make doxygen treat +# .inc files as Fortran files (default is PHP), and .f files as C (default is Fortran), +# use: inc=Fortran f=C. Note that for custom extensions you also need to set +# FILE_PATTERNS otherwise the files are not read by doxygen. + +EXTENSION_MAPPING = + +# If you use STL classes (i.e. std::string, std::vector, etc.) but do not want +# to include (a tag file for) the STL sources as input, then you should +# set this tag to YES in order to let doxygen match functions declarations and +# definitions whose arguments contain STL classes (e.g. func(std::string); v.s. +# func(std::string) {}). This also make the inheritance and collaboration +# diagrams that involve STL classes more complete and accurate. + +BUILTIN_STL_SUPPORT = YES + +# If you use Microsoft's C++/CLI language, you should set this option to YES to +# enable parsing support. + +CPP_CLI_SUPPORT = NO + +# Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. +# Doxygen will parse them like normal C++ but will assume all classes use public +# instead of private inheritance when no explicit protection keyword is present. + +SIP_SUPPORT = NO + +# For Microsoft's IDL there are propget and propput attributes to indicate getter +# and setter methods for a property. Setting this option to YES (the default) +# will make doxygen to replace the get and set methods by a property in the +# documentation. This will only work if the methods are indeed getting or +# setting a simple type. If this is not the case, or you want to show the +# methods anyway, you should set this option to NO. + +IDL_PROPERTY_SUPPORT = YES + +# If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC +# tag is set to YES, then doxygen will reuse the documentation of the first +# member in the group (if any) for the other members of the group. By default +# all members of a group must be documented explicitly. + +DISTRIBUTE_GROUP_DOC = NO + # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to @@ -210,6 +274,32 @@ OPTIMIZE_OUTPUT_JAVA = NO SUBGROUPING = YES +# When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum +# is documented as struct, union, or enum with the name of the typedef. So +# typedef struct TypeS {} TypeT, will appear in the documentation as a struct +# with name TypeT. When disabled the typedef will appear as a member of a file, +# namespace, or class. And the struct will be named TypeS. This can typically +# be useful for C code in case the coding convention dictates that all compound +# types are typedef'ed and only the typedef is referenced, never the tag name. + +TYPEDEF_HIDES_STRUCT = YES + +# The SYMBOL_CACHE_SIZE determines the size of the internal cache use to +# determine which symbols to keep in memory and which to flush to disk. +# When the cache is full, less often used symbols will be written to disk. +# For small to medium size projects (<1000 input files) the default value is +# probably good enough. For larger projects a too small cache size can cause +# doxygen to be busy swapping symbols to and from disk most of the time +# causing a significant performance penality. +# If the system has enough physical memory increasing the cache will improve the +# performance by keeping more symbols in memory. Note that the value works on +# a logarithmic scale so increasing the size by one will rougly double the +# memory usage. The cache size is given by this formula: +# 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, +# corresponding to a cache size of 2^16 = 65536 symbols + +SYMBOL_CACHE_SIZE = 0 + #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- @@ -219,17 +309,17 @@ SUBGROUPING = YES # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES -EXTRACT_ALL = NO +EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. -EXTRACT_PRIVATE = NO +EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. -EXTRACT_STATIC = NO +EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. @@ -242,7 +332,15 @@ EXTRACT_LOCAL_CLASSES = YES # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. -EXTRACT_LOCAL_METHODS = NO +EXTRACT_LOCAL_METHODS = YES + +# If this flag is set to YES, the members of anonymous namespaces will be +# extracted and appear in the documentation as a namespace called +# 'anonymous_namespace{file}', where file will be replaced with the base +# name of the file that contains the anonymous namespace. By default +# anonymous namespace are hidden. + +EXTRACT_ANON_NSPACES = YES # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. @@ -278,7 +376,7 @@ HIDE_IN_BODY_DOCS = NO # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. -INTERNAL_DOCS = NO +INTERNAL_DOCS = YES # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also @@ -286,7 +384,7 @@ INTERNAL_DOCS = NO # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. -CASE_SENSE_NAMES = YES +CASE_SENSE_NAMES = NO # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the @@ -319,11 +417,17 @@ SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO +# If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the +# hierarchy of group names into alphabetical order. If set to NO (the default) +# the group names will appear in their defined order. + +SORT_GROUP_NAMES = NO + # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. -# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. +# Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. @@ -368,28 +472,43 @@ ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 -# Set the SHOW_USED_FILES tag to NO to disable the list of files generated -# at the bottom of the documentation of classes and structs. If set to YES the -# list will mention the files that were used to generate the documentation. - -SHOW_USED_FILES = YES - # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy -# in the documentation. The default is YES. +# in the documentation. The default is NO. SHOW_DIRECTORIES = YES +# Set the SHOW_FILES tag to NO to disable the generation of the Files page. +# This will remove the Files entry from the Quick Index and from the +# Folder Tree View (if specified). The default is YES. + +SHOW_FILES = YES + +# Set the SHOW_NAMESPACES tag to NO to disable the generation of the +# Namespaces page. This will remove the Namespaces entry from the Quick Index +# and from the Folder Tree View (if specified). The default is YES. + +SHOW_NAMESPACES = YES + # The FILE_VERSION_FILTER tag can be used to specify a program or script that -# doxygen should invoke to get the current version for each file (typically from the -# version control system). Doxygen will invoke the program by executing (via +# doxygen should invoke to get the current version for each file (typically from +# the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file -# provided by doxygen. Whatever the progam writes to standard output +# provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = +# The LAYOUT_FILE tag can be used to specify a layout file which will be parsed by +# doxygen. The layout file controls the global structure of the generated output files +# in an output format independent way. The create the layout file that represents +# doxygen's defaults, run doxygen with the -l option. You can optionally specify a +# file name after the option, if omitted DoxygenLayout.xml will be used as the name +# of the layout file. + +LAYOUT_FILE = + #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- @@ -424,7 +543,7 @@ WARN_IF_DOC_ERROR = YES # wrong or incomplete parameter documentation, but not about the absence of # documentation. -WARN_NO_PARAMDOC = NO +WARN_NO_PARAMDOC = YES # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text @@ -439,7 +558,7 @@ WARN_FORMAT = "$file:$line: $text" # and error messages should be written. If left blank the output is written # to stderr. -WARN_LOGFILE = +WARN_LOGFILE = ./doxygen_warn.txt #--------------------------------------------------------------------------- # configuration options related to the input files @@ -450,28 +569,73 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = +INPUT = . + +# This tag can be used to specify the character encoding of the source files +# that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is +# also the default input encoding. Doxygen uses libiconv (or the iconv built +# into libc) for the transcoding. See http://www.gnu.org/software/libiconv for +# the list of possible encodings. + +INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx -# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm +# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 -FILE_PATTERNS = +FILE_PATTERNS = *.c \ + *.cc \ + *.cxx \ + *.cpp \ + *.c++ \ + *.d \ + *.java \ + *.ii \ + *.ixx \ + *.ipp \ + *.i++ \ + *.inl \ + *.h \ + *.hh \ + *.hxx \ + *.hpp \ + *.h++ \ + *.idl \ + *.odl \ + *.cs \ + *.php \ + *.php3 \ + *.inc \ + *.m \ + *.mm \ + *.dox \ + *.py \ + *.f90 \ + *.f \ + *.vhd \ + *.vhdl \ + *.h.in \ + *.h.default # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. -RECURSIVE = NO +RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE = +EXCLUDE = ../doxy \ + ../test \ + ../Xcode \ + ../VisualC \ + ../VisualCE \ + ../Xcode-iPhoneOS # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded @@ -485,27 +649,35 @@ EXCLUDE_SYMLINKS = NO # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = + +# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names +# (namespaces, classes, functions, etc.) that should be excluded from the +# output. The symbol name can be a fully qualified name, a word, or if the +# wildcard * is used, a substring. Examples: ANamespace, AClass, +# AClass::ANamespace, ANamespace::*Test + +EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). -EXAMPLE_PATH = +EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. -EXAMPLE_PATTERNS = +EXAMPLE_PATTERNS = * # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. -EXAMPLE_RECURSIVE = NO +EXAMPLE_RECURSIVE = YES # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see @@ -547,31 +719,38 @@ FILTER_SOURCE_FILES = NO # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. -SOURCE_BROWSER = NO +SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. -INLINE_SOURCES = NO +INLINE_SOURCES = YES # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. -STRIP_CODE_COMMENTS = YES +STRIP_CODE_COMMENTS = NO -# If the REFERENCED_BY_RELATION tag is set to YES (the default) +# If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES -# If the REFERENCES_RELATION tag is set to YES (the default) +# If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES +# If the REFERENCES_LINK_SOURCE tag is set to YES (the default) +# and SOURCE_BROWSER tag is set to YES, then the hyperlinks from +# functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will +# link to the source code. Otherwise they will link to the documentation. + +REFERENCES_LINK_SOURCE = YES + # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source @@ -594,7 +773,7 @@ VERBATIM_HEADERS = YES # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. -ALPHABETICAL_INDEX = NO +ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns @@ -607,7 +786,8 @@ COLS_IN_ALPHA_INDEX = 5 # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. -IGNORE_PREFIX = +IGNORE_PREFIX = SDL_ \ + SDL #--------------------------------------------------------------------------- # configuration options related to the HTML output @@ -657,9 +837,43 @@ HTML_STYLESHEET = HTML_ALIGN_MEMBERS = YES +# If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML +# documentation will contain sections that can be hidden and shown after the +# page has loaded. For this to work a browser that supports +# JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox +# Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). + +HTML_DYNAMIC_SECTIONS = YES + +# If the GENERATE_DOCSET tag is set to YES, additional index files +# will be generated that can be used as input for Apple's Xcode 3 +# integrated development environment, introduced with OSX 10.5 (Leopard). +# To create a documentation set, doxygen will generate a Makefile in the +# HTML output directory. Running make will produce the docset in that +# directory and running "make install" will install the docset in +# ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find +# it at startup. +# See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html for more information. + +GENERATE_DOCSET = NO + +# When GENERATE_DOCSET tag is set to YES, this tag determines the name of the +# feed. A documentation feed provides an umbrella under which multiple +# documentation sets from a single provider (such as a company or product suite) +# can be grouped. + +DOCSET_FEEDNAME = "SDL 1.2 Doxygen" + +# When GENERATE_DOCSET tag is set to YES, this tag specifies a string that +# should uniquely identify the documentation set bundle. This should be a +# reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen +# will append .docset to the name. + +DOCSET_BUNDLE_ID = org.libsdl.sdl12 + # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the -# Microsoft HTML help workshop to generate a compressed HTML help file (.chm) +# Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO @@ -669,7 +883,7 @@ GENERATE_HTMLHELP = NO # can add a path in front of the file if the result should not be # written to the html output directory. -CHM_FILE = +CHM_FILE = ./sdl12.chm # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of @@ -684,6 +898,12 @@ HHC_LOCATION = GENERATE_CHI = NO +# If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING +# is used to encode HtmlHelp index (hhk), content (hhc) and project file +# content. + +CHM_INDEX_ENCODING = + # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. @@ -693,7 +913,56 @@ BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. -TOC_EXPAND = NO +TOC_EXPAND = YES + +# If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and QHP_VIRTUAL_FOLDER +# are set, an additional index file will be generated that can be used as input for +# Qt's qhelpgenerator to generate a Qt Compressed Help (.qch) of the generated +# HTML documentation. + +GENERATE_QHP = NO + +# If the QHG_LOCATION tag is specified, the QCH_FILE tag can +# be used to specify the file name of the resulting .qch file. +# The path specified is relative to the HTML output folder. + +QCH_FILE = + +# The QHP_NAMESPACE tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#namespace + +QHP_NAMESPACE = + +# The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating +# Qt Help Project output. For more information please see +# http://doc.trolltech.com/qthelpproject.html#virtual-folders + +QHP_VIRTUAL_FOLDER = doc + +# If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to add. +# For more information please see +# http://doc.trolltech.com/qthelpproject.html#custom-filters + +QHP_CUST_FILTER_NAME = + +# The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the custom filter to add.For more information please see +# Qt Help Project / Custom Filters. + +QHP_CUST_FILTER_ATTRS = + +# The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this project's +# filter section matches. +# Qt Help Project / Filter Attributes. + +QHP_SECT_FILTER_ATTRS = + +# If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can +# be used to specify the location of Qt's qhelpgenerator. +# If non-empty doxygen will try to run qhelpgenerator on the generated +# .qhp file. + +QHG_LOCATION = # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and @@ -704,16 +973,24 @@ DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. -ENUM_VALUES_PER_LINE = 4 +ENUM_VALUES_PER_LINE = 1 -# If the GENERATE_TREEVIEW tag is set to YES, a side panel will be -# generated containing a tree-like index structure (just like the one that +# The GENERATE_TREEVIEW tag is used to specify whether a tree-like index +# structure should be generated to display hierarchical information. +# If the tag value is set to FRAME, a side panel will be generated +# containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are -# probably better off using the HTML help feature. +# probably better off using the HTML help feature. Other possible values +# for this tag are: HIERARCHIES, which will generate the Groups, Directories, +# and Class Hierarchy pages using a tree view instead of an ordered list; +# ALL, which combines the behavior of FRAME and HIERARCHIES; and NONE, which +# disables this behavior completely. For backwards compatibility with previous +# releases of Doxygen, the values YES and NO are equivalent to FRAME and NONE +# respectively. -GENERATE_TREEVIEW = NO +GENERATE_TREEVIEW = ALL # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree @@ -721,6 +998,14 @@ GENERATE_TREEVIEW = NO TREEVIEW_WIDTH = 250 +# Use this tag to change the font size of Latex formulas included +# as images in the HTML documentation. The default is 10. Note that +# when you change the font size after a successful doxygen run you need +# to manually remove any form_*.png images from the HTML output directory +# to force them to be regenerated. + +FORMULA_FONTSIZE = 10 + #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- @@ -728,7 +1013,7 @@ TREEVIEW_WIDTH = 250 # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. -GENERATE_LATEX = YES +GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be @@ -776,13 +1061,13 @@ LATEX_HEADER = # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. -PDF_HYPERLINKS = NO +PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. -USE_PDFLATEX = NO +USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep @@ -797,6 +1082,13 @@ LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO +# If LATEX_SOURCE_CODE is set to YES then doxygen will include +# source code with syntax highlighting in the LaTeX output. +# Note that which sources are shown also depends on other settings +# such as SOURCE_BROWSER. + +LATEX_SOURCE_CODE = NO + #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- @@ -846,7 +1138,7 @@ RTF_EXTENSIONS_FILE = # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages -GENERATE_MAN = YES +GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be @@ -966,7 +1258,7 @@ MACRO_EXPANSION = YES # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the -# PREDEFINED and EXPAND_AS_PREDEFINED tags. +# PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = YES @@ -997,7 +1289,9 @@ INCLUDE_FILE_PATTERNS = # instead of the = operator. PREDEFINED = DOXYGEN_SHOULD_IGNORE_THIS=1 \ - DECLSPEC= SDLCALL= + DECLSPEC= \ + SDLCALL= \ + _WIN32=1 # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. @@ -1027,9 +1321,9 @@ SKIP_FUNCTION_MACROS = YES # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool -# does not have to be run to correct the links. -# Note that each tag file must have a unique name -# (where the name does NOT include the path) +# does not have to be run to correct the links. +# Note that each tag file must have a unique name +# (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. @@ -1038,7 +1332,7 @@ TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. -GENERATE_TAGFILE = +GENERATE_TAGFILE = ./SDL.tag # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes @@ -1055,7 +1349,7 @@ EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). -PERL_PATH = /usr/bin/perl +PERL_PATH = c:\Perl\bin\perl.exe #--------------------------------------------------------------------------- # Configuration options related to the dot tool @@ -1068,7 +1362,16 @@ PERL_PATH = /usr/bin/perl # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. -CLASS_DIAGRAMS = NO +CLASS_DIAGRAMS = YES + +# You can define message sequence charts within doxygen comments using the \msc +# command. Doxygen will then run the mscgen tool (see +# http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the +# documentation. The MSCGEN_PATH tag allows you to specify the directory where +# the mscgen tool resides. If left empty the tool is assumed to be found in the +# default search path. + +MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented @@ -1081,7 +1384,30 @@ HIDE_UNDOC_RELATIONS = YES # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) -HAVE_DOT = NO +HAVE_DOT = YES + +# By default doxygen will write a font called FreeSans.ttf to the output +# directory and reference it in all dot files that doxygen generates. This +# font does not include all possible unicode characters however, so when you need +# these (or just want a differently looking font) you can specify the font name +# using DOT_FONTNAME. You need need to make sure dot is able to find the font, +# which can be done by putting it in a standard location or by setting the +# DOTFONTPATH environment variable or by setting DOT_FONTPATH to the directory +# containing the font. + +DOT_FONTNAME = FreeSans + +# The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. +# The default size is 10pt. + +DOT_FONTSIZE = 10 + +# By default doxygen will tell dot to use the output directory to look for the +# FreeSans.ttf font (which doxygen will put there itself). If you specify a +# different font using DOT_FONTNAME you can set the path where dot +# can find it using this tag. + +DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and @@ -1111,14 +1437,14 @@ UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. -TEMPLATE_RELATIONS = NO +TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. -INCLUDE_GRAPH = NO +INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each @@ -1127,14 +1453,22 @@ INCLUDE_GRAPH = NO INCLUDED_BY_GRAPH = YES -# If the CALL_GRAPH and HAVE_DOT tags are set to YES then doxygen will -# generate a call dependency graph for every global function or class method. -# Note that enabling this option will significantly increase the time of a run. -# So in most cases it will be better to enable call graphs for selected -# functions only using the \callgraph command. +# If the CALL_GRAPH and HAVE_DOT options are set to YES then +# doxygen will generate a call dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable call graphs +# for selected functions only using the \callgraph command. CALL_GRAPH = NO +# If the CALLER_GRAPH and HAVE_DOT tags are set to YES then +# doxygen will generate a caller dependency graph for every global function +# or class method. Note that enabling this option will significantly increase +# the time of a run. So in most cases it will be better to enable caller +# graphs for selected functions only using the \callergraph command. + +CALLER_GRAPH = NO + # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. @@ -1142,13 +1476,13 @@ GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories -# in a graphical way. The dependency relations are determined by the #include +# in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images -# generated by dot. Possible values are png, jpg, or gif +# generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png @@ -1164,39 +1498,31 @@ DOT_PATH = DOTFILE_DIRS = -# The MAX_DOT_GRAPH_WIDTH tag can be used to set the maximum allowed width -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. +# The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of +# nodes that will be shown in the graph. If the number of nodes in a graph +# becomes larger than this value, doxygen will truncate the graph, which is +# visualized by representing a node as a red box. Note that doxygen if the +# number of direct children of the root node in a graph is already larger than +# DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note +# that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. -MAX_DOT_GRAPH_WIDTH = 1024 - -# The MAX_DOT_GRAPH_HEIGHT tag can be used to set the maximum allows height -# (in pixels) of the graphs generated by dot. If a graph becomes larger than -# this value, doxygen will try to truncate the graph, so that it fits within -# the specified constraint. Beware that most browsers cannot cope with very -# large images. - -MAX_DOT_GRAPH_HEIGHT = 1024 +DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large -# code bases. Also note that a graph may be further truncated if the graph's -# image dimensions are not sufficient to fit the graph (see MAX_DOT_GRAPH_WIDTH -# and MAX_DOT_GRAPH_HEIGHT). If 0 is used for the depth value (the default), -# the graph is not depth-constrained. +# code bases. Also note that the size of a graph can be further restricted by +# DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. -MAX_DOT_GRAPH_DEPTH = 0 +MAX_DOT_GRAPH_DEPTH = 2 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent -# background. This is disabled by default, which results in a white background. -# Warning: Depending on the platform used, enabling this option may lead to -# badly anti-aliased labels on the edges of a graph (i.e. they become hard to -# read). +# background. This is disabled by default, because dot on Windows does not +# seem to support this out of the box. Warning: Depending on the platform used, +# enabling this option may lead to badly anti-aliased labels on the edges of +# a graph (i.e. they become hard to read). DOT_TRANSPARENT = NO @@ -1205,7 +1531,7 @@ DOT_TRANSPARENT = NO # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. -DOT_MULTI_TARGETS = NO +DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and @@ -1220,7 +1546,7 @@ GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- -# Configuration::additions related to the search engine +# Options related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be diff --git a/project/jni/sdl-1.3/src/SDL.c b/project/jni/sdl-1.3/src/SDL.c index 49620a8e1..58d6f365c 100644 --- a/project/jni/sdl-1.3/src/SDL.c +++ b/project/jni/sdl-1.3/src/SDL.c @@ -1,38 +1,34 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" /* Initialization code for SDL */ #include "SDL.h" +#include "SDL_revision.h" #include "SDL_fatal.h" #include "SDL_assert_c.h" #include "haptic/SDL_haptic_c.h" #include "joystick/SDL_joystick_c.h" -#if !SDL_VIDEO_DISABLED -#include "video/SDL_leaks.h" -#endif - /* Initialization/Cleanup routines */ #if !SDL_TIMERS_DISABLED extern void SDL_StartTicks(void); @@ -49,9 +45,6 @@ extern int SDL_HelperWindowDestroy(void); static Uint32 SDL_initialized = 0; static Uint32 ticks_started = 0; -#ifdef CHECK_LEAKS -int surfaces_allocated = 0; -#endif int SDL_InitSubSystem(Uint32 flags) @@ -59,7 +52,7 @@ SDL_InitSubSystem(Uint32 flags) #if !SDL_VIDEO_DISABLED /* Initialize the video/event subsystem */ if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) { - if (SDL_VideoInit(NULL, (flags & SDL_INIT_EVENTTHREAD)) < 0) { + if (SDL_VideoInit(NULL) < 0) { return (-1); } SDL_initialized |= SDL_INIT_VIDEO; @@ -215,44 +208,17 @@ void SDL_Quit(void) { /* Quit all subsystems */ -#ifdef DEBUG_BUILD - printf("[SDL_Quit] : Enter! Calling QuitSubSystem()\n"); - fflush(stdout); -#endif - #if defined(__WIN32__) SDL_HelperWindowDestroy(); #endif SDL_QuitSubSystem(SDL_INIT_EVERYTHING); -#ifdef CHECK_LEAKS -#ifdef DEBUG_BUILD - printf("[SDL_Quit] : CHECK_LEAKS\n"); - fflush(stdout); -#endif - - /* !!! FIXME: make this an assertion. */ - /* Print the number of surfaces not freed */ - if (surfaces_allocated != 0) { - fprintf(stderr, "SDL Warning: %d SDL surfaces extant\n", - surfaces_allocated); - } -#endif -#ifdef DEBUG_BUILD - printf("[SDL_Quit] : SDL_UninstallParachute()\n"); - fflush(stdout); -#endif - /* Uninstall any parachute signal handlers */ SDL_UninstallParachute(); + SDL_ClearHints(); SDL_AssertionsQuit(); - -#ifdef DEBUG_BUILD - printf("[SDL_Quit] : Returning!\n"); - fflush(stdout); -#endif - + SDL_LogResetPriorities(); } /* Get the library version number */ @@ -269,6 +235,13 @@ SDL_GetRevision(void) return SDL_REVISION; } +/* Get the library source revision number */ +int +SDL_GetRevisionNumber(void) +{ + return SDL_REVISION_NUMBER; +} + /* Get the name of the platform */ const char * SDL_GetPlatform() @@ -300,6 +273,8 @@ SDL_GetPlatform() return "Mac OS X"; #elif __NETBSD__ return "NetBSD"; +#elif __NDS__ + return "Nintendo DS"; #elif __OPENBSD__ return "OpenBSD"; #elif __OS2__ @@ -329,8 +304,7 @@ SDL_GetPlatform() #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL)) /* Need to include DllMain() on Watcom C for some reason.. */ -#define WIN32_LEAN_AND_MEAN -#include +#include "core/windows/SDL_windows.h" BOOL APIENTRY _DllMainCRTStartup(HANDLE hModule, diff --git a/project/jni/sdl-1.3/src/SDL_assert.c b/project/jni/sdl-1.3/src/SDL_assert.c index 0c433d80a..9d6416253 100644 --- a/project/jni/sdl-1.3/src/SDL_assert.c +++ b/project/jni/sdl-1.3/src/SDL_assert.c @@ -1,33 +1,36 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL.h" +#include "SDL_atomic.h" #include "SDL_assert.h" #include "SDL_assert_c.h" #include "video/SDL_sysvideo.h" -#ifdef _WINDOWS -#define WIN32_LEAN_AND_MEAN 1 -#include +#ifdef __WIN32__ +#include "core/windows/SDL_windows.h" + +#ifndef WS_OVERLAPPEDWINDOW +#define WS_OVERLAPPEDWINDOW 0 +#endif #else /* fprintf, _exit(), etc. */ #include #include @@ -41,8 +44,7 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata); * We keep all triggered assertions in a singly-linked list so we can * generate a report later. */ -static SDL_assert_data assertion_list_terminator = { 0, 0, 0, 0, 0, 0, 0 }; -static SDL_assert_data *triggered_assertions = &assertion_list_terminator; +static SDL_assert_data *triggered_assertions = NULL; static SDL_mutex *assertion_mutex = NULL; static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion; @@ -56,11 +58,12 @@ debug_print(const char *fmt, ...) __attribute__((format (printf, 1, 2))); static void debug_print(const char *fmt, ...) { -#ifdef _WINDOWS +#ifdef __WIN32__ /* Format into a buffer for OutputDebugStringA(). */ char buf[1024]; char *startptr; char *ptr; + LPTSTR tstr; int len; va_list ap; va_start(ap, fmt); @@ -77,15 +80,19 @@ debug_print(const char *fmt, ...) for (ptr = startptr; *ptr; ptr++) { if (*ptr == '\n') { *ptr = '\0'; - OutputDebugStringA(startptr); - OutputDebugStringA("\r\n"); + tstr = WIN_UTF8ToString(startptr); + OutputDebugString(tstr); + SDL_free(tstr); + OutputDebugString(TEXT("\r\n")); startptr = ptr+1; } } /* catch that last piece if it didn't have a newline... */ if (startptr != ptr) { - OutputDebugStringA(startptr); + tstr = WIN_UTF8ToString(startptr); + OutputDebugString(tstr); + SDL_free(tstr); } #else /* Unix has it easy. Just dump it to stderr. */ @@ -98,7 +105,7 @@ debug_print(const char *fmt, ...) } -#ifdef _WINDOWS +#ifdef __WIN32__ static SDL_assert_state SDL_Windows_AssertChoice = SDL_ASSERTION_ABORT; static const SDL_assert_data *SDL_Windows_AssertData = NULL; @@ -112,6 +119,7 @@ SDL_Assertion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) /* !!! FIXME: all this code stinks. */ const SDL_assert_data *data = SDL_Windows_AssertData; char buf[1024]; + LPTSTR tstr; const int w = 100; const int h = 25; const int gap = 10; @@ -120,14 +128,14 @@ SDL_Assertion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) int len; int i; static const struct { - const char *name; + LPCTSTR name; SDL_assert_state state; } buttons[] = { - {"Abort", SDL_ASSERTION_ABORT }, - {"Break", SDL_ASSERTION_BREAK }, - {"Retry", SDL_ASSERTION_RETRY }, - {"Ignore", SDL_ASSERTION_IGNORE }, - {"Always Ignore", SDL_ASSERTION_ALWAYS_IGNORE }, + {TEXT("Abort"), SDL_ASSERTION_ABORT }, + {TEXT("Break"), SDL_ASSERTION_BREAK }, + {TEXT("Retry"), SDL_ASSERTION_RETRY }, + {TEXT("Ignore"), SDL_ASSERTION_IGNORE }, + {TEXT("Always Ignore"), SDL_ASSERTION_ALWAYS_IGNORE }, }; len = (int) SDL_snprintf(buf, sizeof (buf), @@ -139,14 +147,16 @@ SDL_Assertion_WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) buf[sizeof (buf) - 1] = '\0'; } - CreateWindowA("STATIC", buf, + tstr = WIN_UTF8ToString(buf); + CreateWindow(TEXT("STATIC"), tstr, WS_VISIBLE | WS_CHILD | SS_LEFT, x, y, 550, 100, hwnd, (HMENU) 1, NULL, NULL); + SDL_free(tstr); y += 110; for (i = 0; i < (sizeof (buttons) / sizeof (buttons[0])); i++) { - CreateWindowA("BUTTON", buttons[i].name, + CreateWindow(TEXT("BUTTON"), buttons[i].name, WS_VISIBLE | WS_CHILD, x, y, w, h, hwnd, (HMENU) buttons[i].state, NULL, NULL); @@ -206,7 +216,8 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data) { /* (data) is always a static struct defined with the assert macros, so we don't have to worry about copying or allocating them. */ - if (data->next == NULL) { /* not yet added? */ + data->trigger_count++; + if (data->trigger_count == 1) { /* not yet added? */ data->next = triggered_assertions; triggered_assertions = data; } @@ -215,19 +226,14 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data) static void SDL_GenerateAssertionReport(void) { - const SDL_assert_data *item; + const SDL_assert_data *item = triggered_assertions; /* only do this if the app hasn't assigned an assertion handler. */ - if (assertion_handler != SDL_PromptAssertion) - return; - - item = SDL_GetAssertionReport(); - if (item->condition) - { + if ((item != NULL) && (assertion_handler != SDL_PromptAssertion)) { debug_print("\n\nSDL assertion report.\n"); debug_print("All SDL assertions between last init/quit:\n\n"); - while (item->condition) { + while (item != NULL) { debug_print( "'%s'\n" " * %s (%s:%d)\n" @@ -247,7 +253,7 @@ static void SDL_GenerateAssertionReport(void) static void SDL_ExitProcess(int exitcode) { -#ifdef _WINDOWS +#ifdef __WIN32__ ExitProcess(42); #else _exit(42); @@ -310,10 +316,10 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) /* platform-specific UI... */ -#ifdef _WINDOWS +#ifdef __WIN32__ state = SDL_PromptAssertion_windows(data); -#elif __MACOSX__ +#elif defined __MACOSX__ && defined SDL_VIDEO_DRIVER_COCOA /* This has to be done in an Objective-C (*.m) file, so we call out. */ extern SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *); state = SDL_PromptAssertion_cocoa(data); @@ -331,16 +337,16 @@ SDL_PromptAssertion(const SDL_assert_data *data, void *userdata) if (SDL_strcmp(buf, "a") == 0) { state = SDL_ASSERTION_ABORT; break; - } else if (SDL_strcmp(envr, "b") == 0) { + } else if (SDL_strcmp(buf, "b") == 0) { state = SDL_ASSERTION_BREAK; break; - } else if (SDL_strcmp(envr, "r") == 0) { + } else if (SDL_strcmp(buf, "r") == 0) { state = SDL_ASSERTION_RETRY; break; - } else if (SDL_strcmp(envr, "i") == 0) { + } else if (SDL_strcmp(buf, "i") == 0) { state = SDL_ASSERTION_IGNORE; break; - } else if (SDL_strcmp(envr, "A") == 0) { + } else if (SDL_strcmp(buf, "A") == 0) { state = SDL_ASSERTION_ALWAYS_IGNORE; break; } @@ -387,8 +393,6 @@ SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file, SDL_AddAssertionToReport(data); - data->trigger_count++; - assertion_running++; if (assertion_running > 1) { /* assert during assert! Abort. */ if (assertion_running == 2) { @@ -461,16 +465,16 @@ const SDL_assert_data *SDL_GetAssertionReport(void) void SDL_ResetAssertionReport(void) { - SDL_assert_data *item = triggered_assertions; SDL_assert_data *next = NULL; - for (item = triggered_assertions; item->condition; item = next) { + SDL_assert_data *item; + for (item = triggered_assertions; item != NULL; item = next) { next = (SDL_assert_data *) item->next; item->always_ignore = SDL_FALSE; item->trigger_count = 0; item->next = NULL; } - triggered_assertions = &assertion_list_terminator; + triggered_assertions = NULL; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/SDL_assert_c.h b/project/jni/sdl-1.3/src/SDL_assert_c.h index eb14cfbe0..0be500235 100644 --- a/project/jni/sdl-1.3/src/SDL_assert_c.h +++ b/project/jni/sdl-1.3/src/SDL_assert_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ extern int SDL_AssertionsInit(void); diff --git a/project/jni/sdl-1.3/src/SDL_compat.c b/project/jni/sdl-1.3/src/SDL_compat.c index 47f4eb68c..e8b7a0520 100644 --- a/project/jni/sdl-1.3/src/SDL_compat.c +++ b/project/jni/sdl-1.3/src/SDL_compat.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -28,51 +27,63 @@ #include "video/SDL_sysvideo.h" #include "video/SDL_pixels_c.h" -#include "video/SDL_yuv_sw_c.h" +#include "render/SDL_yuv_sw_c.h" +#include + static SDL_Window *SDL_VideoWindow = NULL; -static SDL_RendererInfo SDL_VideoRendererInfo; -static SDL_Texture *SDL_VideoTexture = NULL; +static SDL_Surface *SDL_WindowSurface = NULL; static SDL_Surface *SDL_VideoSurface = NULL; static SDL_Surface *SDL_ShadowSurface = NULL; static SDL_Surface *SDL_PublicSurface = NULL; static SDL_GLContext *SDL_VideoContext = NULL; static Uint32 SDL_VideoFlags = 0; +static SDL_Rect SDL_VideoViewport; static char *wm_title = NULL; static SDL_Surface *SDL_VideoIcon; static int SDL_enabled_UNICODE = 0; -char * +const char * SDL_AudioDriverName(char *namebuf, int maxlen) { const char *name = SDL_GetCurrentAudioDriver(); if (name) { - SDL_strlcpy(namebuf, name, maxlen); - return namebuf; + if (namebuf) { + SDL_strlcpy(namebuf, name, maxlen); + return namebuf; + } else { + return name; + } } return NULL; } -char * +const char * SDL_VideoDriverName(char *namebuf, int maxlen) { const char *name = SDL_GetCurrentVideoDriver(); if (name) { - SDL_strlcpy(namebuf, name, maxlen); - return namebuf; + if (namebuf) { + SDL_strlcpy(namebuf, name, maxlen); + return namebuf; + } else { + return name; + } } return NULL; } -static void -SelectVideoDisplay() +static int +GetVideoDisplay() { const char *variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_DISPLAY"); if ( !variable ) { variable = SDL_getenv("SDL_VIDEO_FULLSCREEN_HEAD"); } if ( variable ) { - SDL_SelectVideoDisplay(SDL_atoi(variable)); + return SDL_atoi(variable); + } else { + return 0; } } @@ -82,16 +93,9 @@ SDL_GetVideoInfo(void) static SDL_VideoInfo info; SDL_DisplayMode mode; - SelectVideoDisplay(); - /* Memory leak, compatibility code, who cares? */ - if (!info.vfmt && SDL_GetDesktopDisplayMode(&mode) == 0) { - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - SDL_PixelFormatEnumToMasks(mode.format, &bpp, &Rmask, &Gmask, &Bmask, - &Amask); - info.vfmt = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); + if (!info.vfmt && SDL_GetDesktopDisplayMode(GetVideoDisplay(), &mode) == 0) { + info.vfmt = SDL_AllocFormat(mode.format); info.current_w = mode.w; info.current_h = mode.h; } @@ -107,17 +111,15 @@ SDL_VideoModeOK(int width, int height, int bpp, Uint32 flags) return 0; } - SelectVideoDisplay(); - if (!(flags & SDL_FULLSCREEN)) { SDL_DisplayMode mode; - SDL_GetDesktopDisplayMode(&mode); + SDL_GetDesktopDisplayMode(GetVideoDisplay(), &mode); return SDL_BITSPERPIXEL(mode.format); } - for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { + for (i = 0; i < SDL_GetNumDisplayModes(GetVideoDisplay()); ++i) { SDL_DisplayMode mode; - SDL_GetDisplayMode(i, &mode); + SDL_GetDisplayMode(GetVideoDisplay(), i, &mode); if (!mode.w || !mode.h || (width == mode.w && height == mode.h)) { if (!mode.format) { return bpp; @@ -140,8 +142,6 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags) return NULL; } - SelectVideoDisplay(); - if (!(flags & SDL_FULLSCREEN)) { return (SDL_Rect **) (-1); } @@ -153,13 +153,23 @@ SDL_ListModes(const SDL_PixelFormat * format, Uint32 flags) /* Memory leak, but this is a compatibility function, who cares? */ nmodes = 0; modes = NULL; - for (i = 0; i < SDL_GetNumDisplayModes(); ++i) { + for (i = 0; i < SDL_GetNumDisplayModes(GetVideoDisplay()); ++i) { SDL_DisplayMode mode; - SDL_GetDisplayMode(i, &mode); + int bpp; + + SDL_GetDisplayMode(GetVideoDisplay(), i, &mode); if (!mode.w || !mode.h) { return (SDL_Rect **) (-1); } - if (SDL_BITSPERPIXEL(mode.format) != format->BitsPerPixel) { + + /* Copied from src/video/SDL_pixels.c:SDL_PixelFormatEnumToMasks */ + if (SDL_BYTESPERPIXEL(mode.format) <= 2) { + bpp = SDL_BITSPERPIXEL(mode.format); + } else { + bpp = SDL_BYTESPERPIXEL(mode.format) * 8; + } + + if (bpp != format->BitsPerPixel) { continue; } if (nmodes > 0 && modes[nmodes - 1]->w == mode.w @@ -203,10 +213,15 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event) break; case SDL_WINDOWEVENT_RESIZED: SDL_FlushEvent(SDL_VIDEORESIZE); - fake.type = SDL_VIDEORESIZE; - fake.resize.w = event->window.data1; - fake.resize.h = event->window.data2; - SDL_PushEvent(&fake); + /* We don't want to expose that the window width and height will + be different if we don't get the desired fullscreen mode. + */ + if (SDL_VideoWindow && !(SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN)) { + fake.type = SDL_VIDEORESIZE; + fake.resize.w = event->window.data1; + fake.resize.h = event->window.data2; + SDL_PushEvent(&fake); + } break; case SDL_WINDOWEVENT_MINIMIZED: fake.type = SDL_ACTIVEEVENT; @@ -274,6 +289,19 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event) //printf("TEXTINPUT: '%s'\n", event->text.text); break; } + case SDL_MOUSEMOTION: + { + event->motion.x -= SDL_VideoViewport.x; + event->motion.y -= SDL_VideoViewport.y; + break; + } + case SDL_MOUSEBUTTONDOWN: + case SDL_MOUSEBUTTONUP: + { + event->button.x -= SDL_VideoViewport.x; + event->button.y -= SDL_VideoViewport.y; + break; + } case SDL_MOUSEWHEEL: { Uint8 button; @@ -310,30 +338,10 @@ SDL_CompatEventFilter(void *userdata, SDL_Event * event) return 1; } -static int -SDL_VideoPaletteChanged(void *userdata, SDL_Palette * palette) -{ - if (userdata == SDL_ShadowSurface) { - /* If the shadow palette changed, make the changes visible */ - if (!SDL_VideoSurface->format->palette) { - SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0); - } - } - if (userdata == SDL_VideoSurface) { - /* The display may not have a palette, but always set texture palette */ - SDL_SetDisplayPalette(palette->colors, 0, palette->ncolors); - - if (SDL_SetTexturePalette - (SDL_VideoTexture, palette->colors, 0, palette->ncolors) < 0) { - return -1; - } - } - return 0; -} - static void GetEnvironmentWindowPosition(int w, int h, int *x, int *y) { + int display = GetVideoDisplay(); const char *window = SDL_getenv("SDL_VIDEO_WINDOW_POS"); const char *center = SDL_getenv("SDL_VIDEO_CENTERED"); if (window) { @@ -345,54 +353,20 @@ GetEnvironmentWindowPosition(int w, int h, int *x, int *y) } } if (center) { - SDL_DisplayMode mode; - SDL_GetDesktopDisplayMode(&mode); - *x = (mode.w - w) / 2; - *y = (mode.h - h) / 2; + *x = SDL_WINDOWPOS_CENTERED_DISPLAY(display); + *y = SDL_WINDOWPOS_CENTERED_DISPLAY(display); } } -static SDL_Surface * -CreateVideoSurface(SDL_Texture * texture) -{ - SDL_Surface *surface; - Uint32 format; - int w, h; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - void *pixels; - int pitch; - - if (SDL_QueryTexture(texture, &format, NULL, &w, &h) < 0) { - return NULL; - } - - if (!SDL_PixelFormatEnumToMasks - (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown texture format"); - return NULL; - } - - if (SDL_QueryTexturePixels(texture, &pixels, &pitch) == 0) { - surface = - SDL_CreateRGBSurfaceFrom(pixels, w, h, bpp, pitch, Rmask, Gmask, - Bmask, Amask); - } else { - surface = - SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); - } - return surface; -} - static void ClearVideoSurface() { - Uint32 black; - - /* Clear the surface for display */ - black = SDL_MapRGB(SDL_PublicSurface->format, 0, 0, 0); - SDL_FillRect(SDL_PublicSurface, NULL, black); - SDL_UpdateRect(SDL_PublicSurface, 0, 0, 0, 0); + if (SDL_ShadowSurface) { + SDL_FillRect(SDL_ShadowSurface, NULL, + SDL_MapRGB(SDL_ShadowSurface->format, 0, 0, 0)); + } + SDL_FillRect(SDL_WindowSurface, NULL, 0); + SDL_UpdateWindowSurface(SDL_VideoWindow); } static void @@ -421,13 +395,9 @@ static int SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags) { int w, h; - Uint32 format; - int access; - void *pixels; - int pitch; /* We can't resize something we don't have... */ - if (!SDL_VideoWindow) { + if (!SDL_VideoSurface) { return -1; } @@ -440,6 +410,9 @@ SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags) if (flags != SDL_VideoFlags) { return -1; } + if (bpp != SDL_VideoSurface->format->BitsPerPixel) { + return -1; + } /* Resize the window */ SDL_GetWindowSize(SDL_VideoWindow, &w, &h); @@ -454,27 +427,18 @@ SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags) return 0; } - /* Destroy the screen texture and recreate it */ - SDL_QueryTexture(SDL_VideoTexture, &format, &access, &w, &h); - SDL_DestroyTexture(SDL_VideoTexture); - SDL_VideoTexture = SDL_CreateTexture(format, access, width, height); - if (!SDL_VideoTexture) { + SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow); + if (!SDL_WindowSurface) { + return -1; + } + if (SDL_VideoSurface->format != SDL_WindowSurface->format) { return -1; } - SDL_VideoSurface->w = width; SDL_VideoSurface->h = height; - if (SDL_QueryTexturePixels(SDL_VideoTexture, &pixels, &pitch) == 0) { - SDL_VideoSurface->pixels = pixels; - SDL_VideoSurface->pitch = pitch; - } else { - SDL_CalculatePitch(SDL_VideoSurface); - SDL_VideoSurface->pixels = - SDL_realloc(SDL_VideoSurface->pixels, - SDL_VideoSurface->h * SDL_VideoSurface->pitch); - } + SDL_VideoSurface->pixels = SDL_WindowSurface->pixels; + SDL_VideoSurface->pitch = SDL_WindowSurface->pitch; SDL_SetClipRect(SDL_VideoSurface, NULL); - SDL_InvalidateMap(SDL_VideoSurface->map); if (SDL_ShadowSurface) { SDL_ShadowSurface->w = width; @@ -485,6 +449,8 @@ SDL_ResizeVideoMode(int width, int height, int bpp, Uint32 flags) SDL_ShadowSurface->h * SDL_ShadowSurface->pitch); SDL_SetClipRect(SDL_ShadowSurface, NULL); SDL_InvalidateMap(SDL_ShadowSurface->map); + } else { + SDL_PublicSurface = SDL_VideoSurface; } ClearVideoSurface(); @@ -496,22 +462,23 @@ SDL_Surface * SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) { SDL_DisplayMode desktop_mode; - int window_x = SDL_WINDOWPOS_UNDEFINED; - int window_y = SDL_WINDOWPOS_UNDEFINED; + int display = GetVideoDisplay(); + int window_x = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display); + int window_y = SDL_WINDOWPOS_UNDEFINED_DISPLAY(display); + int window_w; + int window_h; Uint32 window_flags; - Uint32 desktop_format; - Uint32 desired_format; Uint32 surface_flags; + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_SetVideoMode(%d, %d, %d, 0x%x)", width, height, bpp, flags); if (!SDL_GetVideoDevice()) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Init(SDL_INIT_VIDEO) failed"); return NULL; } } - SelectVideoDisplay(); - - SDL_GetDesktopDisplayMode(&desktop_mode); + SDL_GetDesktopDisplayMode(display, &desktop_mode); if (width == 0) { width = desktop_mode.w; @@ -519,21 +486,25 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) if (height == 0) { height = desktop_mode.h; } + if (bpp == 0) { + bpp = SDL_BITSPERPIXEL(desktop_mode.format); + } /* See if we can simply resize the existing window and surface */ if (SDL_ResizeVideoMode(width, height, bpp, flags) == 0) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_ResizeVideoMode(): SDL_PublicSurface %p", SDL_PublicSurface); return SDL_PublicSurface; } /* Destroy existing window */ SDL_PublicSurface = NULL; if (SDL_ShadowSurface) { + SDL_ShadowSurface->flags &= ~SDL_DONTFREE; SDL_FreeSurface(SDL_ShadowSurface); SDL_ShadowSurface = NULL; } if (SDL_VideoSurface) { - SDL_DelPaletteWatch(SDL_VideoSurface->format->palette, - SDL_VideoPaletteChanged, NULL); + SDL_VideoSurface->flags &= ~SDL_DONTFREE; SDL_FreeSurface(SDL_VideoSurface); SDL_VideoSurface = NULL; } @@ -571,16 +542,19 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) SDL_CreateWindow(wm_title, window_x, window_y, width, height, window_flags); if (!SDL_VideoWindow) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_CreateWindow() failed"); return NULL; } SDL_SetWindowIcon(SDL_VideoWindow, SDL_VideoIcon); + SetupScreenSaver(flags); + window_flags = SDL_GetWindowFlags(SDL_VideoWindow); surface_flags = 0; if (window_flags & SDL_WINDOW_FULLSCREEN) { surface_flags |= SDL_FULLSCREEN; } - if (window_flags & SDL_WINDOW_OPENGL) { + if ((window_flags & SDL_WINDOW_OPENGL) && (flags & SDL_OPENGL)) { surface_flags |= SDL_OPENGL; } if (window_flags & SDL_WINDOW_RESIZABLE) { @@ -590,52 +564,7 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) surface_flags |= SDL_NOFRAME; } - /* Set up the desired display mode */ - desktop_format = desktop_mode.format; - if (desktop_format && ((flags & SDL_ANYFORMAT) - || (bpp == SDL_BITSPERPIXEL(desktop_format)))) { - desired_format = desktop_format; - } else { - switch (bpp) { - case 0: - if (desktop_format) { - desired_format = desktop_format; - } else { - desired_format = SDL_PIXELFORMAT_RGB888; - } - bpp = SDL_BITSPERPIXEL(desired_format); - break; - case 8: - desired_format = SDL_PIXELFORMAT_INDEX8; - break; - case 15: - desired_format = SDL_PIXELFORMAT_RGB555; - break; - case 16: - desired_format = SDL_PIXELFORMAT_RGB565; - break; - case 24: - desired_format = SDL_PIXELFORMAT_RGB24; - break; - case 32: - desired_format = SDL_PIXELFORMAT_RGB888; - break; - default: - SDL_SetError("Unsupported bpp in SDL_SetVideoMode()"); - return NULL; - } - } - - /* Set up the desired display mode */ - if (flags & SDL_FULLSCREEN) { - SDL_DisplayMode mode; - - SDL_zero(mode); - mode.format = desired_format; - if (SDL_SetWindowDisplayMode(SDL_VideoWindow, &mode) < 0) { - return NULL; - } - } + SDL_VideoFlags = flags; /* If we're in OpenGL mode, just create a stub surface and we're done! */ if (flags & SDL_OPENGL) { @@ -656,46 +585,33 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) return SDL_PublicSurface; } - /* Create a renderer for the window */ - if (SDL_CreateRenderer - (SDL_VideoWindow, -1, - SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD) < 0) { - return NULL; - } - SDL_GetRendererInfo(&SDL_VideoRendererInfo); - - /* Create a texture for the screen surface */ - SDL_VideoTexture = - SDL_CreateTexture(desired_format, SDL_TEXTUREACCESS_STREAMING, width, - height); - - if (!SDL_VideoTexture) { - SDL_VideoTexture = - SDL_CreateTexture(desktop_format, - SDL_TEXTUREACCESS_STREAMING, width, height); - } - if (!SDL_VideoTexture) { - return NULL; - } - /* Create the screen surface */ - SDL_VideoSurface = CreateVideoSurface(SDL_VideoTexture); - if (!SDL_VideoSurface) { + SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow); + if (!SDL_WindowSurface) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_GetWindowSurface() failed"); return NULL; } - SDL_VideoSurface->flags |= surface_flags; - /* Set a default screen palette */ - if (SDL_VideoSurface->format->palette) { - SDL_VideoSurface->flags |= SDL_HWPALETTE; - SDL_DitherColors(SDL_VideoSurface->format->palette->colors, - SDL_VideoSurface->format->BitsPerPixel); - SDL_AddPaletteWatch(SDL_VideoSurface->format->palette, - SDL_VideoPaletteChanged, SDL_VideoSurface); - SDL_SetPaletteColors(SDL_VideoSurface->format->palette, - SDL_VideoSurface->format->palette->colors, 0, - SDL_VideoSurface->format->palette->ncolors); - } + /* Center the public surface in the window surface */ + SDL_GetWindowSize(SDL_VideoWindow, &window_w, &window_h); + SDL_VideoViewport.x = (window_w - width)/2; + SDL_VideoViewport.y = (window_h - height)/2; + SDL_VideoViewport.w = width; + SDL_VideoViewport.h = height; + + SDL_VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0); + SDL_VideoSurface->flags |= surface_flags; + SDL_VideoSurface->flags |= SDL_DONTFREE; + SDL_FreeFormat(SDL_VideoSurface->format); + SDL_VideoSurface->format = SDL_WindowSurface->format; + SDL_VideoSurface->format->refcount++; + SDL_VideoSurface->w = width; + SDL_VideoSurface->h = height; + SDL_VideoSurface->pitch = SDL_WindowSurface->pitch; + SDL_VideoSurface->pixels = (void *)((Uint8 *)SDL_WindowSurface->pixels + + SDL_VideoViewport.y * SDL_VideoSurface->pitch + + SDL_VideoViewport.x * SDL_VideoSurface->format->BytesPerPixel); + SDL_SetClipRect(SDL_VideoSurface, NULL); /* Create a shadow surface if necessary */ if ((bpp != SDL_VideoSurface->format->BitsPerPixel) @@ -703,34 +619,28 @@ SDL_SetVideoMode(int width, int height, int bpp, Uint32 flags) SDL_ShadowSurface = SDL_CreateRGBSurface(0, width, height, bpp, 0, 0, 0, 0); if (!SDL_ShadowSurface) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_ShadowSurface is NULL"); return NULL; } SDL_ShadowSurface->flags |= surface_flags; + SDL_ShadowSurface->flags |= SDL_DONTFREE; /* 8-bit SDL_ShadowSurface surfaces report that they have exclusive palette */ if (SDL_ShadowSurface->format->palette) { SDL_ShadowSurface->flags |= SDL_HWPALETTE; - if (SDL_VideoSurface->format->palette) { - SDL_SetSurfacePalette(SDL_ShadowSurface, - SDL_VideoSurface->format->palette); - } else { - SDL_DitherColors(SDL_ShadowSurface->format->palette->colors, - SDL_ShadowSurface->format->BitsPerPixel); - } - SDL_AddPaletteWatch(SDL_ShadowSurface->format->palette, - SDL_VideoPaletteChanged, SDL_ShadowSurface); + SDL_DitherColors(SDL_ShadowSurface->format->palette->colors, + SDL_ShadowSurface->format->BitsPerPixel); } + SDL_FillRect(SDL_ShadowSurface, NULL, + SDL_MapRGB(SDL_ShadowSurface->format, 0, 0, 0)); } SDL_PublicSurface = (SDL_ShadowSurface ? SDL_ShadowSurface : SDL_VideoSurface); - SDL_VideoFlags = flags; - ClearVideoSurface(); - SetupScreenSaver(flags); - /* We're finally done! */ + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_SetVideoMode(%d, %d, %d, 0x%x) done - SDL_PublicSurface %p", width, height, bpp, flags, SDL_PublicSurface); return SDL_PublicSurface; } @@ -819,7 +729,13 @@ SDL_DisplayFormatAlpha(SDL_Surface * surface) optimised alpha format is written, add the converter here */ break; } - format = SDL_AllocFormat(32, rmask, gmask, bmask, amask); + format = SDL_AllocFormat(SDL_MasksToPixelFormatEnum(32, rmask, + gmask, + bmask, + amask)); + if (!format) { + return NULL; + } converted = SDL_ConvertSurface(surface, format, SDL_RLEACCEL); SDL_FreeFormat(format); return converted; @@ -854,43 +770,37 @@ SDL_UpdateRects(SDL_Surface * screen, int numrects, SDL_Rect * rects) if (screen == SDL_ShadowSurface) { for (i = 0; i < numrects; ++i) { - SDL_LowerBlit(SDL_ShadowSurface, &rects[i], SDL_VideoSurface, - &rects[i]); + SDL_BlitSurface(SDL_ShadowSurface, &rects[i], SDL_VideoSurface, + &rects[i]); } /* Fall through to video surface update */ screen = SDL_VideoSurface; } if (screen == SDL_VideoSurface) { - if (screen->flags & SDL_PREALLOC) { - /* The surface memory is maintained by the renderer */ - SDL_DirtyTexture(SDL_VideoTexture, numrects, rects); - } else { - /* The surface memory needs to be copied to texture */ - int pitch = screen->pitch; - int psize = screen->format->BytesPerPixel; + if (SDL_VideoViewport.x || SDL_VideoViewport.y) { + SDL_Rect *stackrects = SDL_stack_alloc(SDL_Rect, numrects); + SDL_Rect *stackrect; + const SDL_Rect *rect; + + /* Offset all the rectangles before updating */ for (i = 0; i < numrects; ++i) { - const SDL_Rect *rect = &rects[i]; - void *pixels = - (Uint8 *) screen->pixels + rect->y * pitch + - rect->x * psize; - SDL_UpdateTexture(SDL_VideoTexture, rect, pixels, pitch); - } - } - if (SDL_VideoRendererInfo.flags & SDL_RENDERER_PRESENTCOPY) { - for (i = 0; i < numrects; ++i) { - SDL_RenderCopy(SDL_VideoTexture, &rects[i], &rects[i]); + rect = &rects[i]; + stackrect = &stackrects[i]; + stackrect->x = SDL_VideoViewport.x + rect->x; + stackrect->y = SDL_VideoViewport.y + rect->y; + stackrect->w = rect->w; + stackrect->h = rect->h; } + SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, stackrects, numrects); + SDL_stack_free(stackrects); } else { - SDL_Rect rect; - rect.x = 0; - rect.y = 0; - rect.w = screen->w; - rect.h = screen->h; - SDL_RenderCopy(SDL_VideoTexture, &rect, &rect); + SDL_UpdateWindowSurfaceRects(SDL_VideoWindow, rects, numrects); } - SDL_RenderPresent(); } +#ifdef ANDROID + +#endif } void @@ -922,6 +832,7 @@ void SDL_WM_SetIcon(SDL_Surface * icon, Uint8 * mask) { SDL_VideoIcon = icon; + ++SDL_VideoIcon->refcount; } int @@ -934,6 +845,32 @@ SDL_WM_IconifyWindow(void) int SDL_WM_ToggleFullScreen(SDL_Surface * surface) { + int length; + void *pixels; + Uint8 *src, *dst; + int row; + int window_w; + int window_h; + + if (!SDL_PublicSurface) { + SDL_SetError("SDL_SetVideoMode() hasn't been called"); + return 0; + } + + /* Copy the old bits out */ + length = SDL_PublicSurface->w * SDL_PublicSurface->format->BytesPerPixel; + pixels = SDL_malloc(SDL_PublicSurface->h * length); + if (pixels && SDL_PublicSurface->pixels) { + src = (Uint8*)SDL_PublicSurface->pixels; + dst = (Uint8*)pixels; + for (row = 0; row < SDL_PublicSurface->h; ++row) { + SDL_memcpy(dst, src, length); + src += SDL_PublicSurface->pitch; + dst += length; + } + } + + /* Do the physical mode switch */ if (SDL_GetWindowFlags(SDL_VideoWindow) & SDL_WINDOW_FULLSCREEN) { if (SDL_SetWindowFullscreen(SDL_VideoWindow, 0) < 0) { return 0; @@ -945,6 +882,83 @@ SDL_WM_ToggleFullScreen(SDL_Surface * surface) } SDL_PublicSurface->flags |= SDL_FULLSCREEN; } + + /* Recreate the screen surface */ + SDL_WindowSurface = SDL_GetWindowSurface(SDL_VideoWindow); + if (!SDL_WindowSurface) { + /* We're totally hosed... */ + return 0; + } + + /* Center the public surface in the window surface */ + SDL_GetWindowSize(SDL_VideoWindow, &window_w, &window_h); + SDL_VideoViewport.x = (window_w - SDL_VideoSurface->w)/2; + SDL_VideoViewport.y = (window_h - SDL_VideoSurface->h)/2; + SDL_VideoViewport.w = SDL_VideoSurface->w; + SDL_VideoViewport.h = SDL_VideoSurface->h; + + /* Do some shuffling behind the application's back if format changes */ + if (SDL_VideoSurface->format->format != SDL_WindowSurface->format->format) { + if (SDL_ShadowSurface) { + if (SDL_ShadowSurface->format->format == SDL_WindowSurface->format->format) { + /* Whee! We don't need a shadow surface anymore! */ + SDL_VideoSurface->flags &= ~SDL_DONTFREE; + SDL_FreeSurface(SDL_VideoSurface); + SDL_free(SDL_ShadowSurface->pixels); + SDL_VideoSurface = SDL_ShadowSurface; + SDL_VideoSurface->flags |= SDL_PREALLOC; + SDL_ShadowSurface = NULL; + } else { + /* No problem, just change the video surface format */ + SDL_FreeFormat(SDL_VideoSurface->format); + SDL_VideoSurface->format = SDL_WindowSurface->format; + SDL_VideoSurface->format->refcount++; + SDL_InvalidateMap(SDL_ShadowSurface->map); + } + } else { + /* We can make the video surface the shadow surface */ + SDL_ShadowSurface = SDL_VideoSurface; + SDL_ShadowSurface->pitch = SDL_CalculatePitch(SDL_ShadowSurface); + SDL_ShadowSurface->pixels = SDL_malloc(SDL_ShadowSurface->h * SDL_ShadowSurface->pitch); + if (!SDL_ShadowSurface->pixels) { + /* Uh oh, we're hosed */ + SDL_ShadowSurface = NULL; + return 0; + } + SDL_ShadowSurface->flags &= ~SDL_PREALLOC; + + SDL_VideoSurface = SDL_CreateRGBSurfaceFrom(NULL, 0, 0, 32, 0, 0, 0, 0, 0); + SDL_VideoSurface->flags = SDL_ShadowSurface->flags; + SDL_VideoSurface->flags |= SDL_PREALLOC; + SDL_FreeFormat(SDL_VideoSurface->format); + SDL_VideoSurface->format = SDL_WindowSurface->format; + SDL_VideoSurface->format->refcount++; + SDL_VideoSurface->w = SDL_ShadowSurface->w; + SDL_VideoSurface->h = SDL_ShadowSurface->h; + } + } + + /* Update the video surface */ + SDL_VideoSurface->pitch = SDL_WindowSurface->pitch; + SDL_VideoSurface->pixels = (void *)((Uint8 *)SDL_WindowSurface->pixels + + SDL_VideoViewport.y * SDL_VideoSurface->pitch + + SDL_VideoViewport.x * SDL_VideoSurface->format->BytesPerPixel); + SDL_SetClipRect(SDL_VideoSurface, NULL); + + /* Copy the old bits back */ + if (pixels) { + src = (Uint8*)pixels; + dst = (Uint8*)SDL_PublicSurface->pixels; + for (row = 0; row < SDL_PublicSurface->h; ++row) { + SDL_memcpy(dst, src, length); + src += length; + dst += SDL_PublicSurface->pitch; + } + SDL_Flip(SDL_PublicSurface); + SDL_free(pixels); + } + + /* We're done! */ return 1; } @@ -1495,13 +1509,9 @@ SDL_ResetCursor(void) struct private_yuvhwdata { - Uint16 pitches[3]; - Uint8 *planes[3]; - - SDL_SW_YUVTexture *sw; - - SDL_Texture *texture; - Uint32 texture_format; + SDL_SW_YUVTexture *texture; + SDL_Surface *display; + Uint32 display_format; }; SDL_Overlay * @@ -1509,6 +1519,7 @@ SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) { SDL_Overlay *overlay; Uint32 texture_format; + SDL_SW_YUVTexture *texture; if ((display->flags & SDL_OPENGL) == SDL_OPENGL) { SDL_SetError("YUV overlays are not supported in OpenGL mode"); @@ -1556,6 +1567,16 @@ SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) return NULL; } + texture = SDL_SW_CreateYUVTexture(texture_format, w, h); + if (!texture) { + SDL_free(overlay->hwdata); + SDL_free(overlay); + return NULL; + } + overlay->hwdata->texture = texture; + overlay->hwdata->display = NULL; + overlay->hwdata->display_format = SDL_PIXELFORMAT_UNKNOWN; + overlay->format = format; overlay->w = w; overlay->h = h; @@ -1564,48 +1585,8 @@ SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) } else { overlay->planes = 1; } - overlay->pitches = overlay->hwdata->pitches; - overlay->pixels = overlay->hwdata->planes; - - switch (format) { - case SDL_YV12_OVERLAY: - case SDL_IYUV_OVERLAY: - overlay->pitches[0] = overlay->w; - overlay->pitches[1] = overlay->w / 2; - overlay->pitches[2] = overlay->w / 2; - break; - case SDL_YUY2_OVERLAY: - case SDL_UYVY_OVERLAY: - case SDL_YVYU_OVERLAY: - overlay->pitches[0] = overlay->w * 2; - break; - } - - overlay->hwdata->texture = - SDL_CreateTexture(texture_format, SDL_TEXTUREACCESS_STREAMING, w, h); - if (overlay->hwdata->texture) { - overlay->hwdata->sw = NULL; - } else { - SDL_DisplayMode current_mode; - - overlay->hwdata->sw = SDL_SW_CreateYUVTexture(texture_format, w, h); - if (!overlay->hwdata->sw) { - SDL_FreeYUVOverlay(overlay); - return NULL; - } - - /* Create a supported RGB format texture for display */ - SDL_GetCurrentDisplayMode(¤t_mode); - texture_format = current_mode.format; - overlay->hwdata->texture = - SDL_CreateTexture(texture_format, - SDL_TEXTUREACCESS_STREAMING, w, h); - } - if (!overlay->hwdata->texture) { - SDL_FreeYUVOverlay(overlay); - return NULL; - } - overlay->hwdata->texture_format = texture_format; + overlay->pitches = texture->pitches; + overlay->pixels = texture->planes; return overlay; } @@ -1613,6 +1594,7 @@ SDL_CreateYUVOverlay(int w, int h, Uint32 format, SDL_Surface * display) int SDL_LockYUVOverlay(SDL_Overlay * overlay) { + SDL_Rect rect; void *pixels; int pitch; @@ -1620,18 +1602,16 @@ SDL_LockYUVOverlay(SDL_Overlay * overlay) SDL_SetError("Passed a NULL overlay"); return -1; } - if (overlay->hwdata->sw) { - if (SDL_SW_QueryYUVTexturePixels(overlay->hwdata->sw, &pixels, &pitch) - < 0) { - return -1; - } - } else { - if (SDL_LockTexture - (overlay->hwdata->texture, NULL, 1, &pixels, &pitch) - < 0) { - return -1; - } + + rect.x = 0; + rect.y = 0; + rect.w = overlay->w; + rect.h = overlay->h; + + if (SDL_SW_LockYUVTexture(overlay->hwdata->texture, &rect, &pixels, &pitch) < 0) { + return -1; } + overlay->pixels[0] = (Uint8 *) pixels; overlay->pitches[0] = pitch; switch (overlay->format) { @@ -1658,38 +1638,54 @@ SDL_UnlockYUVOverlay(SDL_Overlay * overlay) if (!overlay) { return; } - if (overlay->hwdata->sw) { - void *pixels; - int pitch; - if (SDL_LockTexture - (overlay->hwdata->texture, NULL, 1, &pixels, &pitch) == 0) { - SDL_Rect srcrect; - srcrect.x = 0; - srcrect.y = 0; - srcrect.w = overlay->w; - srcrect.h = overlay->h; - SDL_SW_CopyYUVToRGB(overlay->hwdata->sw, &srcrect, - overlay->hwdata->texture_format, - overlay->w, overlay->h, pixels, pitch); - SDL_UnlockTexture(overlay->hwdata->texture); - } - } else { - SDL_UnlockTexture(overlay->hwdata->texture); - } + SDL_SW_UnlockYUVTexture(overlay->hwdata->texture); } int SDL_DisplayYUVOverlay(SDL_Overlay * overlay, SDL_Rect * dstrect) { + SDL_Surface *display; + SDL_Rect src_rect; + SDL_Rect dst_rect; + void *pixels; + if (!overlay || !dstrect) { SDL_SetError("Passed a NULL overlay or dstrect"); return -1; } - if (SDL_RenderCopy(overlay->hwdata->texture, NULL, dstrect) < 0) { + + display = overlay->hwdata->display; + if (display != SDL_VideoSurface) { + overlay->hwdata->display = display = SDL_VideoSurface; + overlay->hwdata->display_format = SDL_MasksToPixelFormatEnum( + display->format->BitsPerPixel, + display->format->Rmask, + display->format->Gmask, + display->format->Bmask, + display->format->Amask); + } + + src_rect.x = 0; + src_rect.y = 0; + src_rect.w = overlay->w; + src_rect.h = overlay->h; + + if (!SDL_IntersectRect(&display->clip_rect, dstrect, &dst_rect)) { + return 0; + } + + pixels = (void *)((Uint8 *)display->pixels + + dst_rect.y * display->pitch + + dst_rect.x * display->format->BytesPerPixel); + + if (SDL_SW_CopyYUVToRGB(overlay->hwdata->texture, &src_rect, + overlay->hwdata->display_format, + dst_rect.w, dst_rect.h, + pixels, display->pitch) < 0) { return -1; } - SDL_RenderPresent(); + SDL_UpdateWindowSurface(SDL_VideoWindow); return 0; } @@ -1701,7 +1697,7 @@ SDL_FreeYUVOverlay(SDL_Overlay * overlay) } if (overlay->hwdata) { if (overlay->hwdata->texture) { - SDL_DestroyTexture(overlay->hwdata->texture); + SDL_SW_DestroyYUVTexture(overlay->hwdata->texture); } SDL_free(overlay->hwdata); } @@ -1714,6 +1710,38 @@ SDL_GL_SwapBuffers(void) SDL_GL_SwapWindow(SDL_VideoWindow); } +int +SDL_SetGamma(float red, float green, float blue) +{ + Uint16 red_ramp[256]; + Uint16 green_ramp[256]; + Uint16 blue_ramp[256]; + + SDL_CalculateGammaRamp(red, red_ramp); + if (green == red) { + SDL_memcpy(green_ramp, red_ramp, sizeof(red_ramp)); + } else { + SDL_CalculateGammaRamp(green, green_ramp); + } + if (blue == red) { + SDL_memcpy(blue_ramp, red_ramp, sizeof(red_ramp)); + } else { + SDL_CalculateGammaRamp(blue, blue_ramp); + } + return SDL_SetWindowGammaRamp(SDL_VideoWindow, red_ramp, green_ramp, blue_ramp); +} + +int +SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue) +{ + return SDL_SetWindowGammaRamp(SDL_VideoWindow, red, green, blue); +} + +int +SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue) +{ + return SDL_GetWindowGammaRamp(SDL_VideoWindow, red, green, blue); +} int SDL_EnableKeyRepeat(int delay, int interval) @@ -1750,6 +1778,31 @@ SDL_EnableUNICODE(int enable) return previous; } +static Uint32 +SDL_SetTimerCallback(Uint32 interval, void* param) +{ + return ((SDL_OldTimerCallback)param)(interval); +} + +int +SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback) +{ + static SDL_TimerID compat_timer; + + if (compat_timer) { + SDL_RemoveTimer(compat_timer); + compat_timer = 0; + } + + if (interval && callback) { + compat_timer = SDL_AddTimer(interval, SDL_SetTimerCallback, callback); + if (!compat_timer) { + return -1; + } + } + return 0; +} + int SDL_putenv(const char *_var) { diff --git a/project/jni/sdl-1.3/src/SDL_error.c b/project/jni/sdl-1.3/src/SDL_error.c index 88d36fdab..19a6507d1 100644 --- a/project/jni/sdl-1.3/src/SDL_error.c +++ b/project/jni/sdl-1.3/src/SDL_error.c @@ -1,36 +1,31 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" /* Simple error handling in SDL */ +#include "SDL_log.h" #include "SDL_error.h" #include "SDL_error_c.h" -#ifdef ANDROID -#include -#endif - -/*#define DEBUG_ERROR*/ /* Routine to get the thread-specific error variable */ #if SDL_THREADS_DISABLED @@ -60,6 +55,9 @@ SDL_SetError(const char *fmt, ...) va_list ap; SDL_error *error; + /* Ignore call if invalid format pointer was passed */ + if (fmt == NULL) return; + /* Copy in the key, mark error as valid */ error = SDL_GetErrBuf(); error->error = 1; @@ -113,12 +111,7 @@ SDL_SetError(const char *fmt, ...) va_end(ap); /* If we are in debug mode, print out an error message */ -#ifdef DEBUG_ERROR - fprintf(stderr, "SDL_SetError: %s\n", SDL_GetError()); -#endif -#ifdef ANDROID - __android_log_print(ANDROID_LOG_ERROR, "libSDL", "ERROR: %s", SDL_GetError()); -#endif + SDL_LogError(SDL_LOG_CATEGORY_ERROR, "%s", SDL_GetError()); } /* This function has a bit more overhead than most error functions @@ -264,4 +257,5 @@ main(int argc, char *argv[]) exit(0); } #endif + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/SDL_error_c.h b/project/jni/sdl-1.3/src/SDL_error_c.h index 54501f5fa..f346faa04 100644 --- a/project/jni/sdl-1.3/src/SDL_error_c.h +++ b/project/jni/sdl-1.3/src/SDL_error_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -57,6 +56,9 @@ typedef struct SDL_error } args[ERR_MAX_ARGS]; } SDL_error; +/* Defined in SDL_thread.c */ +extern SDL_error *SDL_GetErrBuf(void); + #endif /* _SDL_error_c_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/SDL_fatal.c b/project/jni/sdl-1.3/src/SDL_fatal.c index 31c1e1921..73a43f33d 100644 --- a/project/jni/sdl-1.3/src/SDL_fatal.c +++ b/project/jni/sdl-1.3/src/SDL_fatal.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/SDL_fatal.h b/project/jni/sdl-1.3/src/SDL_fatal.h index 261b1b4d6..7d1876167 100644 --- a/project/jni/sdl-1.3/src/SDL_fatal.h +++ b/project/jni/sdl-1.3/src/SDL_fatal.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/SDL_hints.c b/project/jni/sdl-1.3/src/SDL_hints.c new file mode 100644 index 000000000..8868c4e63 --- /dev/null +++ b/project/jni/sdl-1.3/src/SDL_hints.c @@ -0,0 +1,141 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#include "SDL_hints.h" +#include "SDL_hints_c.h" + + +/* Assuming there aren't many hints set and they aren't being queried in + critical performance paths, we'll just use a linked list here. + */ +typedef struct SDL_Hint { + char *name; + char *value; + SDL_HintPriority priority; + SDL_HintChangedCb callback; + struct SDL_Hint *next; +} SDL_Hint; + +static SDL_Hint *SDL_hints; + +SDL_bool +SDL_RegisterHintChangedCb(const char *name, SDL_HintChangedCb hintCb) +{ + SDL_Hint *hint; + + for (hint = SDL_hints; hint; hint = hint->next) { + if (SDL_strcmp(name, hint->name) == 0) { + hint->callback = hintCb; + return SDL_TRUE; + } + } + + return SDL_FALSE; +} + +SDL_bool +SDL_SetHintWithPriority(const char *name, const char *value, + SDL_HintPriority priority) +{ + const char *env; + SDL_Hint *prev, *hint; + + if (!name || !value) { + return SDL_FALSE; + } + + env = SDL_getenv(name); + if (env && priority < SDL_HINT_OVERRIDE) { + return SDL_FALSE; + } + + prev = NULL; + for (hint = SDL_hints; hint; prev = hint, hint = hint->next) { + if (SDL_strcmp(name, hint->name) == 0) { + if (priority < hint->priority) { + return SDL_FALSE; + } + if (SDL_strcmp(hint->value, value) != 0) { + if (hint->callback != NULL) { + (*hint->callback)(name, hint->value, value); + } + SDL_free(hint->value); + hint->value = SDL_strdup(value); + } + hint->priority = priority; + return SDL_TRUE; + } + } + + /* Couldn't find the hint, add a new one */ + hint = (SDL_Hint *)SDL_malloc(sizeof(*hint)); + if (!hint) { + return SDL_FALSE; + } + hint->name = SDL_strdup(name); + hint->value = SDL_strdup(value); + hint->priority = priority; + hint->callback = NULL; + hint->next = SDL_hints; + SDL_hints = hint; + return SDL_TRUE; +} + +SDL_bool +SDL_SetHint(const char *name, const char *value) +{ + return SDL_SetHintWithPriority(name, value, SDL_HINT_NORMAL); +} + +const char * +SDL_GetHint(const char *name) +{ + const char *env; + SDL_Hint *hint; + + env = SDL_getenv(name); + for (hint = SDL_hints; hint; hint = hint->next) { + if (SDL_strcmp(name, hint->name) == 0) { + if (!env || hint->priority == SDL_HINT_OVERRIDE) { + return hint->value; + } + break; + } + } + return env; +} + +void SDL_ClearHints(void) +{ + SDL_Hint *hint; + + while (SDL_hints) { + hint = SDL_hints; + SDL_hints = hint->next; + + SDL_free(hint->name); + SDL_free(hint->value); + SDL_free(hint); + } +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/SDL_hints_c.h b/project/jni/sdl-1.3/src/SDL_hints_c.h new file mode 100644 index 000000000..923bd3ee7 --- /dev/null +++ b/project/jni/sdl-1.3/src/SDL_hints_c.h @@ -0,0 +1,34 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + */ + +#ifndef _SDL_hints_c_h +#define _SDL_hints_c_h + +/** + * \brief A callback function that is optionally called when a hint changes + */ +typedef void (*SDL_HintChangedCb)(const char *name, const char *oldValue, const char *newValue); + +extern SDL_bool SDL_RegisterHintChangedCb(const char *name, SDL_HintChangedCb hintCb); + +#endif /* _SDL_hints_c_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/SDL_log.c b/project/jni/sdl-1.3/src/SDL_log.c new file mode 100644 index 000000000..b58b86386 --- /dev/null +++ b/project/jni/sdl-1.3/src/SDL_log.c @@ -0,0 +1,329 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* Simple log messages in SDL */ + +#include "SDL_log.h" + +#if HAVE_STDIO_H +#include +#endif + +#if defined(__WIN32__) +#include "core/windows/SDL_windows.h" +#elif defined(__ANDROID__) +#include +#endif + +#define DEFAULT_PRIORITY SDL_LOG_PRIORITY_ERROR +#define DEFAULT_APPLICATION_PRIORITY SDL_LOG_PRIORITY_INFO + +typedef struct SDL_LogLevel +{ + int category; + SDL_LogPriority priority; + struct SDL_LogLevel *next; +} SDL_LogLevel; + +/* The default log output function */ +static void SDL_LogOutput(void *userdata, + int category, SDL_LogPriority priority, + const char *message); + +static SDL_LogLevel *SDL_loglevels; +static SDL_LogPriority SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; +static SDL_LogPriority SDL_default_priority = DEFAULT_PRIORITY; +static SDL_LogOutputFunction SDL_log_function = SDL_LogOutput; +static void *SDL_log_userdata = NULL; + +static const char *SDL_priority_prefixes[SDL_NUM_LOG_PRIORITIES] = { + NULL, + "VERBOSE", + "DEBUG", + "INFO", + "WARN", + "ERROR", + "CRITICAL" +}; + +#ifdef __ANDROID__ +static const char *SDL_category_prefixes[SDL_LOG_CATEGORY_RESERVED1] = { + "APP", + "ERROR", + "SYSTEM", + "AUDIO", + "VIDEO", + "RENDER", + "INPUT" +}; + +static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = { + ANDROID_LOG_VERBOSE, + ANDROID_LOG_DEBUG, + ANDROID_LOG_INFO, + ANDROID_LOG_WARN, + ANDROID_LOG_ERROR, + ANDROID_LOG_FATAL +}; +#endif /* __ANDROID__ */ + + +void +SDL_LogSetAllPriority(SDL_LogPriority priority) +{ + SDL_LogLevel *entry; + + for (entry = SDL_loglevels; entry; entry = entry->next) { + entry->priority = priority; + } + SDL_application_priority = SDL_default_priority = priority; +} + +void +SDL_LogSetPriority(int category, SDL_LogPriority priority) +{ + SDL_LogLevel *entry; + + for (entry = SDL_loglevels; entry; entry = entry->next) { + if (entry->category == category) { + entry->priority = priority; + return; + } + } + + /* Create a new entry */ + entry = (SDL_LogLevel *)SDL_malloc(sizeof(*entry)); + if (entry) { + entry->category = category; + entry->priority = priority; + entry->next = SDL_loglevels; + SDL_loglevels = entry; + } +} + +SDL_LogPriority +SDL_LogGetPriority(int category) +{ + SDL_LogLevel *entry; + + for (entry = SDL_loglevels; entry; entry = entry->next) { + if (entry->category == category) { + return entry->priority; + } + } + + if (category == SDL_LOG_CATEGORY_APPLICATION) { + return SDL_application_priority; + } else { + return SDL_default_priority; + } +} + +void +SDL_LogResetPriorities(void) +{ + SDL_LogLevel *entry; + + while (SDL_loglevels) { + entry = SDL_loglevels; + SDL_loglevels = entry->next; + SDL_free(entry); + } + + SDL_application_priority = DEFAULT_APPLICATION_PRIORITY; + SDL_default_priority = DEFAULT_PRIORITY; +} + +void +SDL_Log(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, fmt, ap); + va_end(ap); +} + +void +SDL_LogVerbose(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_VERBOSE, fmt, ap); + va_end(ap); +} + +void +SDL_LogDebug(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_DEBUG, fmt, ap); + va_end(ap); +} + +void +SDL_LogInfo(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_INFO, fmt, ap); + va_end(ap); +} + +void +SDL_LogWarn(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_WARN, fmt, ap); + va_end(ap); +} + +void +SDL_LogError(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_ERROR, fmt, ap); + va_end(ap); +} + +void +SDL_LogCritical(int category, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, SDL_LOG_PRIORITY_CRITICAL, fmt, ap); + va_end(ap); +} + +void +SDL_LogMessage(int category, SDL_LogPriority priority, const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + SDL_LogMessageV(category, priority, fmt, ap); + va_end(ap); +} + +#ifdef __ANDROID__ +static const char * +GetCategoryPrefix(int category) +{ + if (category < SDL_LOG_CATEGORY_RESERVED1) { + return SDL_category_prefixes[category]; + } + if (category < SDL_LOG_CATEGORY_CUSTOM) { + return "RESERVED"; + } + return "CUSTOM"; +} +#endif /* __ANDROID__ */ + +void +SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap) +{ + char *message; + + /* Nothing to do if we don't have an output function */ + if (!SDL_log_function) { + return; + } + + /* Make sure we don't exceed array bounds */ + if ((int)priority < 0 || priority >= SDL_NUM_LOG_PRIORITIES) { + return; + } + + /* See if we want to do anything with this message */ + if (priority < SDL_LogGetPriority(category)) { + return; + } + + message = SDL_stack_alloc(char, SDL_MAX_LOG_MESSAGE); + if (!message) { + return; + } + SDL_vsnprintf(message, SDL_MAX_LOG_MESSAGE, fmt, ap); + SDL_log_function(SDL_log_userdata, category, priority, message); + SDL_stack_free(message); +} + +static void +SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority, + const char *message) +{ +#if defined(__WIN32__) + /* Way too many allocations here, urgh */ + { + char *output; + size_t length; + LPTSTR tstr; + + length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1; + output = SDL_stack_alloc(char, length); + SDL_snprintf(output, length, "%s: %s", SDL_priority_prefixes[priority], message); + tstr = WIN_UTF8ToString(output); + OutputDebugString(tstr); + SDL_free(tstr); + SDL_stack_free(output); + } +#elif defined(__ANDROID__) + { + char tag[32]; + + SDL_snprintf(tag, SDL_arraysize(tag), "SDL/%s", GetCategoryPrefix(category)); + __android_log_write(SDL_android_priority[priority], tag, message); + } +#endif +#if HAVE_STDIO_H + fprintf(stderr, "%s: %s\n", SDL_priority_prefixes[priority], message); +#endif +} + +void +SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata) +{ + if (callback) { + *callback = SDL_log_function; + } + if (userdata) { + *userdata = SDL_log_userdata; + } +} + +void +SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata) +{ + SDL_log_function = callback; + SDL_log_userdata = userdata; +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/SDL_renderer_gles.c.diff b/project/jni/sdl-1.3/src/SDL_renderer_gles.c.diff new file mode 100644 index 000000000..b9cdcd51d --- /dev/null +++ b/project/jni/sdl-1.3/src/SDL_renderer_gles.c.diff @@ -0,0 +1,207 @@ +These are changes of my Android SDL port over the official SDL port, at the last point where I've synced them +TODO: merge this + +--- SDL_renderer_gles.c 2011-12-05 14:18:19.517975982 +0200 ++++ /home/pelya/src/endless_space/SDL-android/video/SDL_renderer_gles.c 2011-12-05 13:57:25.000000000 +0200 +@@ -20,15 +20,29 @@ + slouken@libsdl.org + */ + #include "SDL_config.h" ++#include "SDL_version.h" + + #if SDL_VIDEO_RENDER_OGL_ES + ++#if SDL_VERSION_ATLEAST(1,3,0) + #include "SDL_video.h" + #include "SDL_opengles.h" + #include "SDL_sysvideo.h" ++#else ++#include "SDL_video-1.3.h" ++#include "SDL_sysvideo-1.3.h" ++#endif ++#include "SDL_opengles.h" + #include "SDL_pixels_c.h" + #include "SDL_rect_c.h" ++#if SDL_VERSION_ATLEAST(1,3,0) + #include "SDL_yuv_sw_c.h" ++#endif ++#ifdef ANDROID ++#include ++#else ++#define __android_log_print(...) ++#endif + + #if defined(__QNXNTO__) + /* Include QNX system header to check QNX version later */ +@@ -112,15 +126,14 @@ + SDL_TEXTUREMODULATE_ALPHA), + (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | + SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), +- (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), 6, ++ (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), 5, + { + /* OpenGL ES 1.x supported formats list */ + SDL_PIXELFORMAT_RGBA4444, + SDL_PIXELFORMAT_RGBA5551, + SDL_PIXELFORMAT_RGB565, + SDL_PIXELFORMAT_RGB24, +- SDL_PIXELFORMAT_BGR888, +- SDL_PIXELFORMAT_ABGR8888}, ++ SDL_PIXELFORMAT_RGBA8888}, + 0, + 0} + }; +@@ -213,11 +226,13 @@ + GLint value; + int doublebuffer; + ++#if SDL_VERSION_ATLEAST(1,3,0) + if (!(window->flags & SDL_WINDOW_OPENGL)) { + if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) { + return NULL; + } + } ++#endif + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { +@@ -295,11 +310,15 @@ + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + ++#if SDL_VERSION_ATLEAST(1,3,0) ++ // Always double-buffered ++#else + if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) { + if (!doublebuffer) { + renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER; + } + } ++#endif + #if SDL_VIDEO_DRIVER_PANDORA + data->GL_OES_draw_texture_supported = SDL_FALSE; + data->useDrawTexture = SDL_FALSE; +@@ -311,6 +330,10 @@ + data->GL_OES_draw_texture_supported = SDL_FALSE; + data->useDrawTexture = SDL_FALSE; + } ++#ifdef ANDROID ++ data->GL_OES_draw_texture_supported = SDL_TRUE; ++ data->useDrawTexture = SDL_TRUE; ++#endif + #endif + + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); +@@ -337,14 +360,27 @@ + if (SDL_GL_MakeCurrent(window, data->context) < 0) { + return -1; + } ++ ++ /* Set up parameters for rendering */ ++ data->blendMode = -1; ++ data->glDisable(GL_DEPTH_TEST); ++ data->glDisable(GL_CULL_FACE); ++ data->updateSize = SDL_TRUE; ++ + if (data->updateSize) { + data->glMatrixMode(GL_PROJECTION); + data->glLoadIdentity(); + data->glMatrixMode(GL_MODELVIEW); + data->glLoadIdentity(); ++#if SDL_VIDEO_RENDER_RESIZE ++ data->glViewport(0, 0, window->display->desktop_mode.w, window->display->desktop_mode.h); ++ data->glOrthof(0.0, (GLfloat) window->display->desktop_mode.w, (GLfloat) window->display->desktop_mode.h, ++ 0.0, 0.0, 1.0); ++#else + data->glViewport(0, 0, window->w, window->h); +- data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, 0.0, +- 0.0, 1.0); ++ data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, ++ 0.0, 0.0, 1.0); ++#endif + data->updateSize = SDL_FALSE; + } + return 0; +@@ -388,6 +424,7 @@ + break; + case SDL_PIXELFORMAT_BGR888: + case SDL_PIXELFORMAT_ABGR8888: ++ case SDL_PIXELFORMAT_RGBA8888: + internalFormat = GL_RGBA; + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; +@@ -419,7 +456,8 @@ + return -1; + } + +- if (texture->access == SDL_TEXTUREACCESS_STREAMING) { ++ if (texture->access == SDL_TEXTUREACCESS_STREAMING) ++ { + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + data->pixels = SDL_malloc(texture->h * data->pitch); + if (!data->pixels) { +@@ -441,6 +479,11 @@ + texture_h = power_of_2(texture->h); + data->texw = (GLfloat) texture->w / texture_w; + data->texh = (GLfloat) texture->h / texture_h; ++ if( renderer->info.max_texture_width < texture_w || renderer->info.max_texture_height < texture_h ) ++ __android_log_print(ANDROID_LOG_WARN, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than largest possible device texture %dx%d", ++ texture_w, texture_h, renderer->info.max_texture_width, renderer->info.max_texture_height ); ++ else if( texture_w > 1024 || texture_h > 1024 ) ++ __android_log_print(ANDROID_LOG_WARN, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than 1024x1024 - this code will not work on HTC G1", texture_w, texture_h ); + + data->format = format; + data->formattype = type; +@@ -557,13 +600,36 @@ + GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + GLenum result; ++ int bpp = SDL_BYTESPERPIXEL(texture->format); ++ void * temp_buffer; ++ void * temp_ptr; ++ int i; + + renderdata->glGetError(); + renderdata->glEnable(data->type); + SetupTextureUpdate(renderdata, texture, pitch); ++ ++ if( rect->w * bpp == pitch ) { ++ temp_buffer = (void *)pixels; /* No need to reformat */ ++ } else { ++ /* Reformatting of mem area required */ ++ temp_buffer = SDL_malloc(rect->w * rect->h * bpp); ++ temp_ptr = temp_buffer; ++ for (i = 0; i < rect->h; i++) { ++ SDL_memcpy(temp_ptr, pixels, rect->w * bpp); ++ temp_ptr += rect->w * bpp; ++ pixels += pitch; ++ } ++ } ++ + renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, + rect->h, data->format, data->formattype, +- pixels); ++ temp_buffer); ++ ++ if( temp_buffer != pixels ) { ++ SDL_free(temp_buffer); ++ } ++ + renderdata->glDisable(data->type); + result = renderdata->glGetError(); + if (result != GL_NO_ERROR) { +@@ -887,7 +953,13 @@ + cropRect[3] = -srcrect->h; + data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, + cropRect); +- data->glDrawTexiOES(dstrect->x, window->h - dstrect->y - dstrect->h, ++ //__android_log_print(ANDROID_LOG_INFO, "libSDL", "GLES_RenderCopy glDrawTexiOES(%d, %d, %d, %d) cropRect %d:%d:%d:%d", dstrect->x, window->display->desktop_mode.h - dstrect->y - dstrect->h, dstrect->w, dstrect->h, cropRect[0], cropRect[1], cropRect[2], cropRect[3]); ++ data->glDrawTexiOES(dstrect->x, ++#if SDL_VIDEO_RENDER_RESIZE ++ window->display->desktop_mode.h - dstrect->y - dstrect->h, ++#else ++ window->h - dstrect->y - dstrect->h, ++#endif + 0, dstrect->w, dstrect->h); + } else { + diff --git a/project/jni/sdl-1.3/src/SDL_video.c.diff b/project/jni/sdl-1.3/src/SDL_video.c.diff new file mode 100644 index 000000000..b7e6cfc01 --- /dev/null +++ b/project/jni/sdl-1.3/src/SDL_video.c.diff @@ -0,0 +1,330 @@ +These are changes of my Android SDL port over the official SDL port, at the last point where I've synced them +TODO: merge this + +--- SDL_video.c 2011-12-05 14:18:19.537975981 +0200 ++++ /home/pelya/src/endless_space/SDL-android/project/jni/sdl-1.3/src/video/SDL_video.c 2011-12-05 14:20:10.817974963 +0200 +@@ -33,6 +33,9 @@ + #include "SDL_renderer_sw.h" + #include "../events/SDL_sysevents.h" + #include "../events/SDL_events_c.h" ++#ifdef ANDROID ++#include ++#endif + + #if SDL_VIDEO_DRIVER_WIN32 + #include "win32/SDL_win32video.h" +@@ -98,15 +101,15 @@ + #if SDL_VIDEO_DRIVER_UIKIT + &UIKIT_bootstrap, + #endif ++#if SDL_VIDEO_DRIVER_ANDROID ++ &ANDROID_bootstrap, ++#endif + #if SDL_VIDEO_DRIVER_DUMMY + &DUMMY_bootstrap, + #endif + #if SDL_VIDEO_DRIVER_PANDORA + &PND_bootstrap, + #endif +-#if SDL_VIDEO_DRIVER_ANDROID +- &Android_bootstrap, +-#endif + NULL + }; + +@@ -2396,6 +2399,36 @@ + return renderer->RenderClear(renderer); + } + ++#if SDL_VIDEO_RENDER_RESIZE ++ ++static inline void ++SDL_RESIZE_resizePoints(int realW, int fakeW, int realH, int fakeH, ++ const SDL_Point * src, SDL_Point * dest, int count ) ++{ ++ int i; ++ for( i = 0; i < count; i++ ) { ++ dest[i].x = src[i].x * realW / fakeW; ++ dest[i].y = src[i].y * realH / fakeH; ++ } ++} ++ ++static inline void ++SDL_RESIZE_resizeRects(int realW, int fakeW, int realH, int fakeH, ++ const SDL_Rect ** src, SDL_Rect * dest, int count ) ++{ ++ int i; ++ for( i = 0; i < count; i++ ) { ++ // Calculate bottom-right corner instead of width/height, and substract upper-left corner, ++ // otherwise we'll have rounding errors and holes between textures ++ dest[i].x = src[i]->x * realW / fakeW; ++ dest[i].y = src[i]->y * realH / fakeH; ++ dest[i].w = (src[i]->w + src[i]->x) * realW / fakeW - dest[i].x; ++ dest[i].h = (src[i]->h + src[i]->y) * realH / fakeH - dest[i].y; ++ } ++} ++ ++#endif ++ + int + SDL_RenderDrawPoint(int x, int y) + { +@@ -2403,6 +2436,7 @@ + + point.x = x; + point.y = y; ++ + return SDL_RenderDrawPoints(&point, 1); + } + +@@ -2410,6 +2444,9 @@ + SDL_RenderDrawPoints(const SDL_Point * points, int count) + { + SDL_Renderer *renderer; ++#if SDL_VIDEO_RENDER_RESIZE ++ int realW, realH, fakeW, fakeH, ret; ++#endif + + if (!points) { + SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points"); +@@ -2427,6 +2464,26 @@ + if (count < 1) { + return 0; + } ++ ++#if SDL_VIDEO_RENDER_RESIZE ++ realW = renderer->window->display->desktop_mode.w; ++ realH = renderer->window->display->desktop_mode.h; ++ fakeW = renderer->window->w; ++ fakeH = renderer->window->h; ++ //if( fakeW > realW || fakeH > realH ) ++ { ++ SDL_Point * resized = SDL_stack_alloc( SDL_Point, count ); ++ if( ! resized ) { ++ SDL_OutOfMemory(); ++ return -1; ++ } ++ SDL_RESIZE_resizePoints( realW, fakeW, realH, fakeH, points, resized, count ); ++ ret = renderer->RenderDrawPoints(renderer, resized, count); ++ SDL_stack_free(resized); ++ return ret; ++ } ++#endif ++ + return renderer->RenderDrawPoints(renderer, points, count); + } + +@@ -2446,6 +2503,9 @@ + SDL_RenderDrawLines(const SDL_Point * points, int count) + { + SDL_Renderer *renderer; ++#if SDL_VIDEO_RENDER_RESIZE ++ int realW, realH, fakeW, fakeH, ret; ++#endif + + if (!points) { + SDL_SetError("SDL_RenderDrawLines(): Passed NULL points"); +@@ -2463,6 +2523,26 @@ + if (count < 2) { + return 0; + } ++ ++#if SDL_VIDEO_RENDER_RESIZE ++ realW = renderer->window->display->desktop_mode.w; ++ realH = renderer->window->display->desktop_mode.h; ++ fakeW = renderer->window->w; ++ fakeH = renderer->window->h; ++ //if( fakeW > realW || fakeH > realH ) ++ { ++ SDL_Point * resized = SDL_stack_alloc( SDL_Point, count ); ++ if( ! resized ) { ++ SDL_OutOfMemory(); ++ return -1; ++ } ++ SDL_RESIZE_resizePoints( realW, fakeW, realH, fakeH, points, resized, count ); ++ ret = renderer->RenderDrawLines(renderer, resized, count); ++ SDL_stack_free(resized); ++ return ret; ++ } ++#endif ++ + return renderer->RenderDrawLines(renderer, points, count); + } + +@@ -2477,6 +2557,9 @@ + { + SDL_Renderer *renderer; + int i; ++#if SDL_VIDEO_RENDER_RESIZE ++ int realW, realH, fakeW, fakeH, ret; ++#endif + + if (!rects) { + SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects"); +@@ -2509,6 +2592,37 @@ + return renderer->RenderDrawRects(renderer, &rect, 1); + } + } ++ ++#if SDL_VIDEO_RENDER_RESIZE ++ realW = renderer->window->display->desktop_mode.w; ++ realH = renderer->window->display->desktop_mode.h; ++ fakeW = renderer->window->w; ++ fakeH = renderer->window->h; ++ //if( fakeW > realW || fakeH > realH ) ++ { ++ SDL_Rect * resized = SDL_stack_alloc( SDL_Rect, count ); ++ if( ! resized ) { ++ SDL_OutOfMemory(); ++ return -1; ++ } ++ ++ const SDL_Rect ** resizedPtrs = SDL_stack_alloc( const SDL_Rect *, count ); ++ if( ! resizedPtrs ) { ++ SDL_OutOfMemory(); ++ return -1; ++ } ++ ++ for( i = 0; i < count; i++ ) { ++ resizedPtrs[i] = &(resized[i]); ++ } ++ SDL_RESIZE_resizeRects( realW, fakeW, realH, fakeH, rects, resized, count ); ++ ret = renderer->RenderDrawRects(renderer, resizedPtrs, count); ++ SDL_stack_free(resizedPtrs); ++ SDL_stack_free(resized); ++ return ret; ++ } ++#endif ++ + return renderer->RenderDrawRects(renderer, rects, count); + } + +@@ -2523,6 +2637,9 @@ + { + SDL_Renderer *renderer; + int i; ++#if SDL_VIDEO_RENDER_RESIZE ++ int realW, realH, fakeW, fakeH, ret; ++#endif + + if (!rects) { + SDL_SetError("SDL_RenderFillRects(): Passed NULL rects"); +@@ -2555,6 +2672,37 @@ + return renderer->RenderFillRects(renderer, &rect, 1); + } + } ++ ++#if SDL_VIDEO_RENDER_RESIZE ++ realW = renderer->window->display->desktop_mode.w; ++ realH = renderer->window->display->desktop_mode.h; ++ fakeW = renderer->window->w; ++ fakeH = renderer->window->h; ++ //if( fakeW > realW || fakeH > realH ) ++ { ++ SDL_Rect * resized = SDL_stack_alloc( SDL_Rect, count ); ++ if( ! resized ) { ++ SDL_OutOfMemory(); ++ return -1; ++ } ++ ++ const SDL_Rect ** resizedPtrs = SDL_stack_alloc( const SDL_Rect *, count ); ++ if( ! resizedPtrs ) { ++ SDL_OutOfMemory(); ++ return -1; ++ } ++ ++ for( i = 0; i < count; i++ ) { ++ resizedPtrs[i] = &(resized[i]); ++ } ++ SDL_RESIZE_resizeRects( realW, fakeW, realH, fakeH, rects, resized, count ); ++ ret = renderer->RenderFillRects(renderer, resizedPtrs, count); ++ SDL_stack_free(resizedPtrs); ++ SDL_stack_free(resized); ++ return ret; ++ } ++#endif ++ + return renderer->RenderFillRects(renderer, rects, count); + } + +@@ -2566,6 +2714,12 @@ + SDL_Window *window; + SDL_Rect real_srcrect; + SDL_Rect real_dstrect; ++#if SDL_VIDEO_RENDER_RESIZE ++ int realW; ++ int realH; ++ int fakeW; ++ int fakeH; ++#endif + + CHECK_TEXTURE_MAGIC(texture, -1); + +@@ -2616,6 +2770,25 @@ + } + } + ++#if SDL_VIDEO_RENDER_RESIZE ++ realW = window->display->desktop_mode.w; ++ realH = window->display->desktop_mode.h; ++ fakeW = window->w; ++ fakeH = window->h; ++ //if( fakeW > realW || fakeH > realH ) ++ { ++ // Calculate bottom-right corner instead of width/height, and substract upper-left corner, ++ // otherwise we'll have rounding errors and holes between textures ++ real_dstrect.w = (real_dstrect.w + real_dstrect.x) * realW / fakeW; ++ real_dstrect.h = (real_dstrect.h + real_dstrect.y) * realH / fakeH; ++ real_dstrect.x = real_dstrect.x * realW / fakeW; ++ real_dstrect.y = real_dstrect.y * realH / fakeH; ++ real_dstrect.w -= real_dstrect.x; ++ real_dstrect.h -= real_dstrect.y; ++ //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_RenderCopy dest %d:%d+%d+%d desktop_mode %d:%d", (int)real_dstrect.x, (int)real_dstrect.y, (int)real_dstrect.w, (int)real_dstrect.h, (int)realW, (int)realH); ++ } ++#endif ++ + return renderer->RenderCopy(renderer, texture, &real_srcrect, + &real_dstrect); + } +@@ -3458,4 +3631,41 @@ + } + } + ++#ifdef ANDROID ++void SDL_ANDROID_VideoContextLost() ++{ ++ SDL_Texture * tex; ++ if( ! SDL_CurrentDisplay || ! SDL_CurrentRenderer || ! SDL_CurrentRenderer->window || ! SDL_CurrentRenderer->textures || SDL_GetWindowFlags(SDL_CurrentRenderer->window) & SDL_WINDOW_OPENGL ) ++ return; ++ ++ tex = SDL_CurrentRenderer->textures; ++ while( tex ) ++ { ++ SDL_CurrentRenderer->DestroyTexture( SDL_CurrentRenderer, tex ); ++ tex = tex->next; ++ } ++} ++ ++void SDL_ANDROID_VideoContextRecreated() ++{ ++ int numTextures = 0; ++ SDL_Texture * tex; ++ __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_VideoContextRecreated(): SDL_CurrentRenderer %p", SDL_CurrentRenderer); ++ if( ! SDL_CurrentRenderer ) ++ return; ++ ++ if( SDL_CurrentRenderer->ActivateRenderer ) /* Re-apply glOrtho() and blend modes */ ++ SDL_CurrentRenderer->ActivateRenderer(SDL_CurrentRenderer); ++ ++ tex = SDL_CurrentRenderer->textures; ++ while( tex ) ++ { ++ SDL_CurrentRenderer->CreateTexture( SDL_CurrentRenderer, tex ); ++ tex = tex->next; ++ numTextures++; ++ } ++ __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_VideoContextRecreated(): re-created %d textures", numTextures); ++} ++#endif ++ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/atomic/SDL_atomic.c b/project/jni/sdl-1.3/src/atomic/SDL_atomic.c new file mode 100644 index 000000000..ed9bca47d --- /dev/null +++ b/project/jni/sdl-1.3/src/atomic/SDL_atomic.c @@ -0,0 +1,102 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_stdinc.h" + +#include "SDL_atomic.h" + +/* Note that we undefine the atomic operations here, in case they are + defined as compiler intrinsics while building SDL but the library user + doesn't have that compiler. That way we always have a working set of + atomic operations built into the library. +*/ + +/* + If any of the operations are not provided then we must emulate some + of them. That means we need a nice implementation of spin locks + that avoids the "one big lock" problem. We use a vector of spin + locks and pick which one to use based on the address of the operand + of the function. + + To generate the index of the lock we first shift by 3 bits to get + rid on the zero bits that result from 32 and 64 bit allignment of + data. We then mask off all but 5 bits and use those 5 bits as an + index into the table. + + Picking the lock this way insures that accesses to the same data at + the same time will go to the same lock. OTOH, accesses to different + data have only a 1/32 chance of hitting the same lock. That should + pretty much eliminate the chances of several atomic operations on + different data from waiting on the same "big lock". If it isn't + then the table of locks can be expanded to a new size so long as + the new size is a power of two. + + Contributed by Bob Pendleton, bob@pendleton.com +*/ + +static SDL_SpinLock locks[32]; + +static __inline__ void +enterLock(void *a) +{ + uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); + + SDL_AtomicLock(&locks[index]); +} + +static __inline__ void +leaveLock(void *a) +{ + uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f); + + SDL_AtomicUnlock(&locks[index]); +} + +SDL_bool +SDL_AtomicCAS_(SDL_atomic_t *a, int oldval, int newval) +{ + SDL_bool retval = SDL_FALSE; + + enterLock(a); + if (a->value == oldval) { + a->value = newval; + retval = SDL_TRUE; + } + leaveLock(a); + + return retval; +} + +SDL_bool +SDL_AtomicCASPtr_(void **a, void *oldval, void *newval) +{ + SDL_bool retval = SDL_FALSE; + + enterLock(a); + if (*a == oldval) { + *a = newval; + retval = SDL_TRUE; + } + leaveLock(a); + + return retval; +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/atomic/SDL_spinlock.c b/project/jni/sdl-1.3/src/atomic/SDL_spinlock.c new file mode 100644 index 000000000..805afcdaa --- /dev/null +++ b/project/jni/sdl-1.3/src/atomic/SDL_spinlock.c @@ -0,0 +1,126 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_stdinc.h" + +#include "SDL_atomic.h" +#include "SDL_mutex.h" +#include "SDL_timer.h" + +/* Don't do the check for Visual Studio 2005, it's safe here */ +#ifdef __WIN32__ +#include "../core/windows/SDL_windows.h" +#endif + +/* This function is where all the magic happens... */ +SDL_bool +SDL_AtomicTryLock(SDL_SpinLock *lock) +{ +#if SDL_ATOMIC_DISABLED + /* Terrible terrible damage */ + static SDL_mutex *_spinlock_mutex; + + if (!_spinlock_mutex) { + /* Race condition on first lock... */ + _spinlock_mutex = SDL_CreateMutex(); + } + SDL_mutexP(_spinlock_mutex); + if (*lock == 0) { + *lock = 1; + SDL_mutexV(_spinlock_mutex); + return SDL_TRUE; + } else { + SDL_mutexV(_spinlock_mutex); + return SDL_FALSE; + } + +#elif defined(_MSC_VER) + SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long)); + return (InterlockedExchange((long*)lock, 1) == 0); + +#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET + return (__sync_lock_test_and_set(lock, 1) == 0); + +#elif defined(__GNUC__) && defined(__arm__) && \ + (defined(__ARM_ARCH_4__) || defined(__ARM_ARCH_4T__) || \ + defined(__ARM_ARCH_5__) || defined(__ARM_ARCH_5TE__) || \ + defined(__ARM_ARCH_5TEJ__)) + int result; + __asm__ __volatile__ ( + "swp %0, %1, [%2]\n" + : "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory"); + return (result == 0); + +#elif defined(__GNUC__) && defined(__arm__) + int result; + __asm__ __volatile__ ( + "ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]" + : "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory"); + return (result == 0); + +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) + int result; + __asm__ __volatile__( + "lock ; xchgl %0, (%1)\n" + : "=r" (result) : "r" (lock), "0" (1) : "cc", "memory"); + return (result == 0); + +#elif defined(__MACOSX__) || defined(__IPHONEOS__) + /* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */ + return OSAtomicCompareAndSwap32Barrier(0, 1, lock); + +#elif HAVE_PTHREAD_SPINLOCK + /* pthread instructions */ + return (pthread_spin_trylock(lock) == 0); + +#else +#error Please implement for your platform. + return SDL_FALSE; +#endif +} + +void +SDL_AtomicLock(SDL_SpinLock *lock) +{ + /* FIXME: Should we have an eventual timeout? */ + while (!SDL_AtomicTryLock(lock)) { + SDL_Delay(0); + } +} + +void +SDL_AtomicUnlock(SDL_SpinLock *lock) +{ +#if defined(_MSC_VER) + _ReadWriteBarrier(); + *lock = 0; + +#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET + __sync_lock_release(lock); + +#elif HAVE_PTHREAD_SPINLOCK + pthread_spin_unlock(lock); + +#else + *lock = 0; +#endif +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/atomic/dummy/SDL_atomic.c b/project/jni/sdl-1.3/src/atomic/dummy/SDL_atomic.c deleted file mode 100644 index c4ee7701b..000000000 --- a/project/jni/sdl-1.3/src/atomic/dummy/SDL_atomic.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Contributed by Bob Pendleton, bob@pendleton.com -*/ - -#include "SDL_stdinc.h" -#include "SDL_atomic.h" - -#include "SDL_error.h" - -/* - This file provides 32, and 64 bit atomic operations. If the - operations are provided by the native hardware and operating system - they are used. If they are not then the operations are emulated - using the SDL spin lock operations. If spin lock can not be - implemented then these functions must fail. -*/ - -/* - DUMMY VERSION. - - This version of the code assumes there is no support for atomic - operations. Therefore, every function sets the SDL error - message. Oddly enough, if you only have one thread then this - version actuallys works. -*/ - -/* - Native spinlock routines. Because this is the dummy implementation - these will always call SDL_SetError() and do nothing. -*/ - -void -SDL_AtomicLock(SDL_SpinLock *lock) -{ - SDL_SetError("SDL_atomic.c: is not implemented on this platform"); -} - -void -SDL_AtomicUnlock(SDL_SpinLock *lock) -{ - SDL_SetError("SDL_atomic.c: is not implemented on this platform"); -} - -/* - Note that platform specific versions can be built from this version - by changing the #undefs to #defines and adding platform specific - code. -*/ - -#undef nativeTestThenSet32 -#undef nativeClear32 -#undef nativeFetchThenIncrement32 -#undef nativeFetchThenDecrement32 -#undef nativeFetchThenAdd32 -#undef nativeFetchThenSubtract32 -#undef nativeIncrementThenFetch32 -#undef nativeDecrementThenFetch32 -#undef nativeAddThenFetch32 -#undef nativeSubtractThenFetch32 - -#undef nativeTestThenSet64 -#undef nativeClear64 -#undef nativeFetchThenIncrement64 -#undef nativeFetchThenDecrement64 -#undef nativeFetchThenAdd64 -#undef nativeFetchThenSubtract64 -#undef nativeIncrementThenFetch64 -#undef nativeDecrementThenFetch64 -#undef nativeAddThenFetch64 -#undef nativeSubtractThenFetch64 - -/* - If any of the operations are not provided then we must emulate some - of them. That means we need a nice implementation of spin locks - that avoids the "one big lock" problem. We use a vector of spin - locks and pick which one to use based on the address of the operand - of the function. - - To generate the index of the lock we first shift by 3 bits to get - rid on the zero bits that result from 32 and 64 bit allignment of - data. We then mask off all but 5 bits and use those 5 bits as an - index into the table. - - Picking the lock this way insures that accesses to the same data at - the same time will go to the same lock. OTOH, accesses to different - data have only a 1/32 chance of hitting the same lock. That should - pretty much eliminate the chances of several atomic operations on - different data from waiting on the same "big lock". If it isn't - then the table of locks can be expanded to a new size so long as - the new size is a power of two. -*/ - -static SDL_SpinLock locks[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static __inline__ void -privateWaitLock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif - - SDL_AtomicLock(&locks[index]); -} - -static __inline__ void -privateUnlock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif - - SDL_AtomicUnlock(&locks[index]); -} - -/* 32 bit atomic operations */ - -SDL_bool -SDL_AtomicTestThenSet32(volatile Uint32 * ptr) -{ -#ifdef nativeTestThenSet32 -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif -} - -void -SDL_AtomicClear32(volatile Uint32 * ptr) -{ -#ifdef nativeClear32 -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif -} - -Uint32 -SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenIncrement32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenDecrement32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenAdd32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenSubtract32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeIncrementThenFetch32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeDecrementThenFetch32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeAddThenFetch32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeSubtractThenFetch32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -/* 64 bit atomic operations */ -#ifdef SDL_HAS_64BIT_TYPE - -SDL_bool -SDL_AtomicTestThenSet64(volatile Uint64 * ptr) -{ -#ifdef nativeTestThenSet64 -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif -} - -void -SDL_AtomicClear64(volatile Uint64 * ptr) -{ -#ifdef nativeClear64 -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif -} - -Uint64 -SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenIncrement64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenDecrement64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenAdd64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenSubtract64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeIncrementThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeDecrementThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeAddThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeSubtractThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} -#endif - diff --git a/project/jni/sdl-1.3/src/atomic/linux/SDL_atomic.c b/project/jni/sdl-1.3/src/atomic/linux/SDL_atomic.c deleted file mode 100644 index 7b74a962d..000000000 --- a/project/jni/sdl-1.3/src/atomic/linux/SDL_atomic.c +++ /dev/null @@ -1,510 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Contributed by Bob Pendleton, bob@pendleton.com -*/ - -#include "SDL_stdinc.h" -#include "SDL_atomic.h" - -#include "SDL_error.h" - -/* - This file provides 32, and 64 bit atomic operations. If the - operations are provided by the native hardware and operating system - they are used. If they are not then the operations are emulated - using the SDL spin lock operations. If spin lock can not be - implemented then these functions must fail. -*/ - -/* - LINUX/GCC VERSION. - - This version of the code assumes support of the atomic builtins as - documented at gcc.gnu.org/onlinedocs/gcc/Atomic-Builtins.html This - code should work on any modern x86 or other processor supported by - GCC. - - Some processors will only support some of these operations so - #ifdefs will have to be added as incompatibilities are discovered -*/ - -/* - Native spinlock routines. -*/ - -void -SDL_AtomicLock(SDL_SpinLock *lock) -{ - while (0 != __sync_lock_test_and_set(lock, 1)) - { - } -} - -void -SDL_AtomicUnlock(SDL_SpinLock *lock) -{ - __sync_lock_test_and_set(lock, 0); -} - -/* - Note that platform specific versions can be built from this version - by changing the #undefs to #defines and adding platform specific - code. -*/ - -#define nativeTestThenSet32 -#define nativeClear32 -#define nativeFetchThenIncrement32 -#define nativeFetchThenDecrement32 -#define nativeFetchThenAdd32 -#define nativeFetchThenSubtract32 -#define nativeIncrementThenFetch32 -#define nativeDecrementThenFetch32 -#define nativeAddThenFetch32 -#define nativeSubtractThenFetch32 - -#ifdef SDL_HAS_64BIT_TYPE - #ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 - #define nativeTestThenSet64 - #define nativeClear64 - #define nativeFetchThenIncrement64 - #define nativeFetchThenDecrement64 - #define nativeFetchThenAdd64 - #define nativeFetchThenSubtract64 - #define nativeIncrementThenFetch64 - #define nativeDecrementThenFetch64 - #define nativeAddThenFetch64 - #define nativeSubtractThenFetch64 - #else - #undef nativeTestThenSet64 - #undef nativeClear64 - #undef nativeFetchThenIncrement64 - #undef nativeFetchThenDecrement64 - #undef nativeFetchThenAdd64 - #undef nativeFetchThenSubtract64 - #undef nativeIncrementThenFetch64 - #undef nativeDecrementThenFetch64 - #undef nativeAddThenFetch64 - #undef nativeSubtractThenFetch64 - #endif /* __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 */ -#endif /* SDL_HAS_64BIT_TYPE */ - -/* - If any of the operations are not provided then we must emulate some - of them. That means we need a nice implementation of spin locks - that avoids the "one big lock" problem. We use a vector of spin - locks and pick which one to use based on the address of the operand - of the function. - - To generate the index of the lock we first shift by 3 bits to get - rid on the zero bits that result from 32 and 64 bit allignment of - data. We then mask off all but 5 bits and use those 5 bits as an - index into the table. - - Picking the lock this way insures that accesses to the same data at - the same time will go to the same lock. OTOH, accesses to different - data have only a 1/32 chance of hitting the same lock. That should - pretty much eliminate the chances of several atomic operations on - different data from waiting on the same "big lock". If it isn't - then the table of locks can be expanded to a new size so long as - the new size is a power of two. -*/ - -static SDL_SpinLock locks[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static __inline__ void -privateWaitLock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif - - SDL_AtomicLock(&locks[index]); -} - -static __inline__ void -privateUnlock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif - - SDL_AtomicUnlock(&locks[index]); -} - -/* 32 bit atomic operations */ - -SDL_bool -SDL_AtomicTestThenSet32(volatile Uint32 * ptr) -{ -#ifdef nativeTestThenSet32 - return 0 == __sync_lock_test_and_set(ptr, 1); -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif -} - -void -SDL_AtomicClear32(volatile Uint32 * ptr) -{ -#ifdef nativeClear32 - __sync_lock_test_and_set(ptr, 0); - return; -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif -} - -Uint32 -SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenIncrement32 - return __sync_fetch_and_add(ptr, 1); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenDecrement32 - return __sync_fetch_and_sub(ptr, 1); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenAdd32 - return __sync_fetch_and_add(ptr, value); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenSubtract32 - return __sync_fetch_and_sub(ptr, value); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeIncrementThenFetch32 - return __sync_add_and_fetch(ptr, 1); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeDecrementThenFetch32 - return __sync_sub_and_fetch(ptr, 1); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeAddThenFetch32 - return __sync_add_and_fetch(ptr, value); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeSubtractThenFetch32 - return __sync_sub_and_fetch(ptr, value); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -/* 64 bit atomic operations */ -#ifdef SDL_HAS_64BIT_TYPE - -SDL_bool -SDL_AtomicTestThenSet64(volatile Uint64 * ptr) -{ -#ifdef nativeTestThenSet64 - return 0 == __sync_lock_test_and_set(ptr, 1); -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif -} - -void -SDL_AtomicClear64(volatile Uint64 * ptr) -{ -#ifdef nativeClear64 - __sync_lock_test_and_set(ptr, 0); - return; -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif -} - -Uint64 -SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenIncrement64 - return __sync_fetch_and_add(ptr, 1); -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenDecrement64 - return __sync_fetch_and_sub(ptr, 1); -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenAdd64 - return __sync_fetch_and_add(ptr, value); -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenSubtract64 - return __sync_fetch_and_sub(ptr, value); -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeIncrementThenFetch64 - return __sync_add_and_fetch(ptr, 1); -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeDecrementThenFetch64 - return __sync_sub_and_fetch(ptr, 1); -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeAddThenFetch64 - return __sync_add_and_fetch(ptr, value); -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeSubtractThenFetch64 - return __sync_sub_and_fetch(ptr, value); -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -#endif /* SDL_HAS_64BIT_TYPE */ diff --git a/project/jni/sdl-1.3/src/atomic/macosx/SDL_atomic.c b/project/jni/sdl-1.3/src/atomic/macosx/SDL_atomic.c deleted file mode 100644 index c4ee7701b..000000000 --- a/project/jni/sdl-1.3/src/atomic/macosx/SDL_atomic.c +++ /dev/null @@ -1,469 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Contributed by Bob Pendleton, bob@pendleton.com -*/ - -#include "SDL_stdinc.h" -#include "SDL_atomic.h" - -#include "SDL_error.h" - -/* - This file provides 32, and 64 bit atomic operations. If the - operations are provided by the native hardware and operating system - they are used. If they are not then the operations are emulated - using the SDL spin lock operations. If spin lock can not be - implemented then these functions must fail. -*/ - -/* - DUMMY VERSION. - - This version of the code assumes there is no support for atomic - operations. Therefore, every function sets the SDL error - message. Oddly enough, if you only have one thread then this - version actuallys works. -*/ - -/* - Native spinlock routines. Because this is the dummy implementation - these will always call SDL_SetError() and do nothing. -*/ - -void -SDL_AtomicLock(SDL_SpinLock *lock) -{ - SDL_SetError("SDL_atomic.c: is not implemented on this platform"); -} - -void -SDL_AtomicUnlock(SDL_SpinLock *lock) -{ - SDL_SetError("SDL_atomic.c: is not implemented on this platform"); -} - -/* - Note that platform specific versions can be built from this version - by changing the #undefs to #defines and adding platform specific - code. -*/ - -#undef nativeTestThenSet32 -#undef nativeClear32 -#undef nativeFetchThenIncrement32 -#undef nativeFetchThenDecrement32 -#undef nativeFetchThenAdd32 -#undef nativeFetchThenSubtract32 -#undef nativeIncrementThenFetch32 -#undef nativeDecrementThenFetch32 -#undef nativeAddThenFetch32 -#undef nativeSubtractThenFetch32 - -#undef nativeTestThenSet64 -#undef nativeClear64 -#undef nativeFetchThenIncrement64 -#undef nativeFetchThenDecrement64 -#undef nativeFetchThenAdd64 -#undef nativeFetchThenSubtract64 -#undef nativeIncrementThenFetch64 -#undef nativeDecrementThenFetch64 -#undef nativeAddThenFetch64 -#undef nativeSubtractThenFetch64 - -/* - If any of the operations are not provided then we must emulate some - of them. That means we need a nice implementation of spin locks - that avoids the "one big lock" problem. We use a vector of spin - locks and pick which one to use based on the address of the operand - of the function. - - To generate the index of the lock we first shift by 3 bits to get - rid on the zero bits that result from 32 and 64 bit allignment of - data. We then mask off all but 5 bits and use those 5 bits as an - index into the table. - - Picking the lock this way insures that accesses to the same data at - the same time will go to the same lock. OTOH, accesses to different - data have only a 1/32 chance of hitting the same lock. That should - pretty much eliminate the chances of several atomic operations on - different data from waiting on the same "big lock". If it isn't - then the table of locks can be expanded to a new size so long as - the new size is a power of two. -*/ - -static SDL_SpinLock locks[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static __inline__ void -privateWaitLock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif - - SDL_AtomicLock(&locks[index]); -} - -static __inline__ void -privateUnlock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif - - SDL_AtomicUnlock(&locks[index]); -} - -/* 32 bit atomic operations */ - -SDL_bool -SDL_AtomicTestThenSet32(volatile Uint32 * ptr) -{ -#ifdef nativeTestThenSet32 -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif -} - -void -SDL_AtomicClear32(volatile Uint32 * ptr) -{ -#ifdef nativeClear32 -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif -} - -Uint32 -SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenIncrement32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenDecrement32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenAdd32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenSubtract32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeIncrementThenFetch32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeDecrementThenFetch32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeAddThenFetch32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeSubtractThenFetch32 -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -/* 64 bit atomic operations */ -#ifdef SDL_HAS_64BIT_TYPE - -SDL_bool -SDL_AtomicTestThenSet64(volatile Uint64 * ptr) -{ -#ifdef nativeTestThenSet64 -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif -} - -void -SDL_AtomicClear64(volatile Uint64 * ptr) -{ -#ifdef nativeClear64 -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif -} - -Uint64 -SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenIncrement64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenDecrement64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenAdd64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenSubtract64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeIncrementThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeDecrementThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeAddThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeSubtractThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} -#endif - diff --git a/project/jni/sdl-1.3/src/atomic/qnx/SDL_atomic.c b/project/jni/sdl-1.3/src/atomic/qnx/SDL_atomic.c deleted file mode 100644 index d9f51df9a..000000000 --- a/project/jni/sdl-1.3/src/atomic/qnx/SDL_atomic.c +++ /dev/null @@ -1,505 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX native atomic operations - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_stdinc.h" -#include "SDL_atomic.h" -#include "SDL_error.h" - -#include - -/* SMP Exchange for PPC platform */ -#ifdef __PPC__ -#include -#endif /* __PPC__ */ - -/* SMP Exchange for ARM platform */ -#ifdef __ARM__ -#include -#endif /* __ARM__ */ - -/* SMP Exchange for MIPS platform */ -#if defined (__MIPSEB__) || defined(__MIPSEL__) -#include -#endif /* __MIPSEB__ || __MIPSEL__ */ - -/* SMP Exchange for SH platform */ -#ifdef __SH__ -#include -#endif /* __SH__ */ - -/* SMP Exchange for x86 platform */ -#ifdef __X86__ -#include -#endif /* __X86__ */ - -/* - This file provides 32, and 64 bit atomic operations. If the - operations are provided by the native hardware and operating system - they are used. If they are not then the operations are emulated - using the SDL spin lock operations. If spin lock can not be - implemented then these functions must fail. -*/ - -void -SDL_AtomicLock(SDL_SpinLock *lock) -{ - unsigned volatile* l = (unsigned volatile*)lock; - Uint32 oldval = 0; - Uint32 newval = 1; - - oldval = _smp_xchg(l, newval); - while(1 == oldval) - { - oldval = _smp_xchg(l, newval); - } -} - -void -SDL_AtomicUnlock(SDL_SpinLock *lock) -{ - unsigned volatile* l = (unsigned volatile*)lock; - Uint32 newval = 0; - - _smp_xchg(l, newval); -} - -/* - QNX 6.4.1 supports only 32 bit atomic access -*/ - -#undef nativeTestThenSet32 -#define nativeClear32 -#define nativeFetchThenIncrement32 -#define nativeFetchThenDecrement32 -#define nativeFetchThenAdd32 -#define nativeFetchThenSubtract32 -#define nativeIncrementThenFetch32 -#define nativeDecrementThenFetch32 -#define nativeAddThenFetch32 -#define nativeSubtractThenFetch32 - -#undef nativeTestThenSet64 -#undef nativeClear64 -#undef nativeFetchThenIncrement64 -#undef nativeFetchThenDecrement64 -#undef nativeFetchThenAdd64 -#undef nativeFetchThenSubtract64 -#undef nativeIncrementThenFetch64 -#undef nativeDecrementThenFetch64 -#undef nativeAddThenFetch64 -#undef nativeSubtractThenFetch64 - -/* - If any of the operations are not provided then we must emulate some - of them. That means we need a nice implementation of spin locks - that avoids the "one big lock" problem. We use a vector of spin - locks and pick which one to use based on the address of the operand - of the function. - - To generate the index of the lock we first shift by 3 bits to get - rid on the zero bits that result from 32 and 64 bit allignment of - data. We then mask off all but 5 bits and use those 5 bits as an - index into the table. - - Picking the lock this way insures that accesses to the same data at - the same time will go to the same lock. OTOH, accesses to different - data have only a 1/32 chance of hitting the same lock. That should - pretty much eliminate the chances of several atomic operations on - different data from waiting on the same "big lock". If it isn't - then the table of locks can be expanded to a new size so long as - the new size is a power of two. -*/ - -static SDL_SpinLock locks[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static __inline__ void -privateWaitLock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif /* SIZEOF_VOIDP */ - - SDL_AtomicLock(&locks[index]); -} - -static __inline__ void -privateUnlock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif /* SIZEOF_VOIDP */ - - SDL_AtomicUnlock(&locks[index]); -} - -/* 32 bit atomic operations */ - -SDL_bool -SDL_AtomicTestThenSet32(volatile Uint32 * ptr) -{ -#ifdef nativeTestThenSet32 -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif /* nativeTestThenSet32 */ -} - -void -SDL_AtomicClear32(volatile Uint32 * ptr) -{ -#ifdef nativeClear32 - atomic_clr(ptr, 0xFFFFFFFF); -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif /* nativeClear32 */ -} - -Uint32 -SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenIncrement32 - return atomic_add_value(ptr, 0x00000001); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif /* nativeFetchThenIncrement32 */ -} - -Uint32 -SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenDecrement32 - return atomic_sub_value(ptr, 0x00000001); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif /* nativeFetchThenDecrement32 */ -} - -Uint32 -SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenAdd32 - return atomic_add_value(ptr, value); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif /* nativeFetchThenAdd32 */ -} - -Uint32 -SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenSubtract32 - return atomic_sub_value(ptr, value); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif /* nativeFetchThenSubtract32 */ -} - -Uint32 -SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeIncrementThenFetch32 - atomic_add(ptr, 0x00000001); - return atomic_add_value(ptr, 0x00000000); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif /* nativeIncrementThenFetch32 */ -} - -Uint32 -SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeDecrementThenFetch32 - atomic_sub(ptr, 0x00000001); - return atomic_sub_value(ptr, 0x00000000); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif /* nativeDecrementThenFetch32 */ -} - -Uint32 -SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeAddThenFetch32 - atomic_add(ptr, value); - return atomic_add_value(ptr, 0x00000000); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif /* nativeAddThenFetch32 */ -} - -Uint32 -SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeSubtractThenFetch32 - atomic_sub(ptr, value); - return atomic_sub_value(ptr, 0x00000000); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif /* nativeSubtractThenFetch32 */ -} - -/* 64 bit atomic operations */ -#ifdef SDL_HAS_64BIT_TYPE - -SDL_bool -SDL_AtomicTestThenSet64(volatile Uint64 * ptr) -{ -#ifdef nativeTestThenSet64 -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif /* nativeTestThenSet64 */ -} - -void -SDL_AtomicClear64(volatile Uint64 * ptr) -{ -#ifdef nativeClear64 -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif /* nativeClear64 */ -} - -Uint64 -SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenIncrement64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif /* nativeFetchThenIncrement64 */ -} - -Uint64 -SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenDecrement64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif /* nativeFetchThenDecrement64 */ -} - -Uint64 -SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenAdd64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif /* nativeFetchThenAdd64 */ -} - -Uint64 -SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenSubtract64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif /* nativeFetchThenSubtract64 */ -} - -Uint64 -SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeIncrementThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif /* nativeIncrementThenFetch64 */ -} - -Uint64 -SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeDecrementThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif /* nativeDecrementThenFetch64 */ -} - -Uint64 -SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeAddThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif /* nativeAddThenFetch64 */ -} - -Uint64 -SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeSubtractThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif /* nativeSubtractThenFetch64 */ -} - -#endif /* SDL_HAS_64BIT_TYPE */ diff --git a/project/jni/sdl-1.3/src/atomic/win32/SDL_atomic.c b/project/jni/sdl-1.3/src/atomic/win32/SDL_atomic.c deleted file mode 100644 index e009fd0d2..000000000 --- a/project/jni/sdl-1.3/src/atomic/win32/SDL_atomic.c +++ /dev/null @@ -1,512 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Contributed by Bob Pendleton, bob@pendleton.com -*/ - -#include "SDL_stdinc.h" -#include "SDL_atomic.h" - -#define WIN32_LEAN_AND_MEAN -#include - -#include "SDL_error.h" - -/* - This file provides 32, and 64 bit atomic operations. If the - operations are provided by the native hardware and operating system - they are used. If they are not then the operations are emulated - using the SDL spin lock operations. If spin lock can not be - implemented then these functions must fail. -*/ - -/* - WIN32 VERSION. - - This makes use of native Windows atomic operations. -*/ - -/* - Native spinlock routines. Because this is the dummy implementation - these will always call SDL_SetError() and do nothing. -*/ - -void -SDL_AtomicLock(SDL_SpinLock *lock) -{ - long volatile * l = (long volatile *)lock; - Uint32 old = 0; - Uint32 new = 1; - - old = InterlockedExchange(l, new); - while(1 == old) - { - old = InterlockedExchange(l, new); - } -} - -void -SDL_AtomicUnlock(SDL_SpinLock *lock) -{ - long volatile * l = (long volatile *)lock; - Uint32 new = 0; - - InterlockedExchange(l, new); -} - -/* - Note that platform specific versions can be built from this version - by changing the #undefs to #defines and adding platform specific - code. -*/ - -#define nativeTestThenSet32 -#define nativeClear32 -#define nativeFetchThenIncrement32 -#define nativeFetchThenDecrement32 -#define nativeFetchThenAdd32 -#define nativeFetchThenSubtract32 -#define nativeIncrementThenFetch32 -#define nativeDecrementThenFetch32 -#define nativeAddThenFetch32 -#define nativeSubtractThenFetch32 - -#undef nativeTestThenSet64 -#undef nativeClear64 -#undef nativeFetchThenIncrement64 -#undef nativeFetchThenDecrement64 -#undef nativeFetchThenAdd64 -#undef nativeFetchThenSubtract64 -#undef nativeIncrementThenFetch64 -#undef nativeDecrementThenFetch64 -#undef nativeAddThenFetch64 -#undef nativeSubtractThenFetch64 - -/* - If any of the operations are not provided then we must emulate some - of them. That means we need a nice implementation of spin locks - that avoids the "one big lock" problem. We use a vector of spin - locks and pick which one to use based on the address of the operand - of the function. - - To generate the index of the lock we first shift by 3 bits to get - rid on the zero bits that result from 32 and 64 bit allignment of - data. We then mask off all but 5 bits and use those 5 bits as an - index into the table. - - Picking the lock this way insures that accesses to the same data at - the same time will go to the same lock. OTOH, accesses to different - data have only a 1/32 chance of hitting the same lock. That should - pretty much eliminate the chances of several atomic operations on - different data from waiting on the same "big lock". If it isn't - then the table of locks can be expanded to a new size so long as - the new size is a power of two. -*/ - -static SDL_SpinLock locks[32] = { - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, -}; - -static __inline__ void -privateWaitLock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif - - SDL_AtomicLock(&locks[index]); -} - -static __inline__ void -privateUnlock(volatile void *ptr) -{ -#if SIZEOF_VOIDP == 4 - Uint32 index = ((((Uint32)ptr) >> 3) & 0x1f); -#elif SIZEOF_VOIDP == 8 - Uint64 index = ((((Uint64)ptr) >> 3) & 0x1f); -#endif - - SDL_AtomicUnlock(&locks[index]); -} - -/* 32 bit atomic operations */ - -SDL_bool -SDL_AtomicTestThenSet32(volatile Uint32 * ptr) -{ -#ifdef nativeTestThenSet32 - long volatile * p = (long volatile *)ptr; - Uint32 new = 1; - - return 0 == InterlockedExchange(p, new); -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif -} - -void -SDL_AtomicClear32(volatile Uint32 * ptr) -{ -#ifdef nativeClear32 - long volatile * p = (long volatile *)ptr; - Uint32 new = 0; - - InterlockedExchange(p, new); -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif -} - -Uint32 -SDL_AtomicFetchThenIncrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenIncrement32 - long volatile * p = (long volatile *)ptr; - - return InterlockedExchangeAdd(p, 1); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenDecrement32(volatile Uint32 * ptr) -{ -#ifdef nativeFetchThenDecrement32 - long volatile * p = (long volatile *)ptr; - - return InterlockedExchangeAdd(p, -1); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenAdd32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenAdd32 - long volatile * p = (long volatile *)ptr; - - return InterlockedExchangeAdd(p, value); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicFetchThenSubtract32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeFetchThenSubtract32 - long volatile * p = (long volatile *)ptr; - - return InterlockedExchangeAdd(p, (0 - value)); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicIncrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeIncrementThenFetch32 - long volatile * p = (LONG volatile *)ptr; - - return InterlockedIncrement(p); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicDecrementThenFetch32(volatile Uint32 * ptr) -{ -#ifdef nativeDecrementThenFetch32 - long volatile * p = (LONG volatile *)ptr; - - return InterlockedDecrement(p); -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicAddThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeAddThenFetch32 - long volatile * p = (long volatile *)ptr; - - return InterlockedExchangeAdd(p, value) + value; -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint32 -SDL_AtomicSubtractThenFetch32(volatile Uint32 * ptr, Uint32 value) -{ -#ifdef nativeSubtractThenFetch32 - long volatile * p = (long volatile *)ptr; - - return InterlockedExchangeAdd(p, (0 - value)) - value; -#else - Uint32 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -/* 64 bit atomic operations */ -#ifdef SDL_HAS_64BIT_TYPE - -SDL_bool -SDL_AtomicTestThenSet64(volatile Uint64 * ptr) -{ -#ifdef nativeTestThenSet64 -#else - SDL_bool result = SDL_FALSE; - - privateWaitLock(ptr); - result = (*ptr == 0); - if (result) - { - *ptr = 1; - } - privateUnlock(ptr); - - return result; -#endif -} - -void -SDL_AtomicClear64(volatile Uint64 * ptr) -{ -#ifdef nativeClear64 -#else - privateWaitLock(ptr); - *ptr = 0; - privateUnlock(ptr); - - return; -#endif -} - -Uint64 -SDL_AtomicFetchThenIncrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenIncrement64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenDecrement64(volatile Uint64 * ptr) -{ -#ifdef nativeFetchThenDecrement64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr) -= 1; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenAdd64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenAdd64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)+= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicFetchThenSubtract64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeFetchThenSubtract64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - tmp = *ptr; - (*ptr)-= value; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicIncrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeIncrementThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicDecrementThenFetch64(volatile Uint64 * ptr) -{ -#ifdef nativeDecrementThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= 1; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicAddThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeAddThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)+= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} - -Uint64 -SDL_AtomicSubtractThenFetch64(volatile Uint64 * ptr, Uint64 value) -{ -#ifdef nativeSubtractThenFetch64 -#else - Uint64 tmp = 0; - - privateWaitLock(ptr); - (*ptr)-= value; - tmp = *ptr; - privateUnlock(ptr); - - return tmp; -#endif -} -#endif - diff --git a/project/jni/sdl-1.3/src/audio/SDL_audio.c b/project/jni/sdl-1.3/src/audio/SDL_audio.c index 77aaeeaf2..a50f3937b 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_audio.c +++ b/project/jni/sdl-1.3/src/audio/SDL_audio.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -46,26 +45,23 @@ static SDL_AudioDevice *open_devices[16]; */ extern AudioBootStrap BSD_AUDIO_bootstrap; extern AudioBootStrap DSP_bootstrap; -extern AudioBootStrap DMA_bootstrap; extern AudioBootStrap ALSA_bootstrap; extern AudioBootStrap PULSEAUDIO_bootstrap; extern AudioBootStrap QSAAUDIO_bootstrap; extern AudioBootStrap SUNAUDIO_bootstrap; -extern AudioBootStrap DMEDIA_bootstrap; extern AudioBootStrap ARTS_bootstrap; extern AudioBootStrap ESD_bootstrap; extern AudioBootStrap NAS_bootstrap; +extern AudioBootStrap XAUDIO2_bootstrap; extern AudioBootStrap DSOUND_bootstrap; -extern AudioBootStrap WINWAVEOUT_bootstrap; +extern AudioBootStrap WINMM_bootstrap; extern AudioBootStrap PAUDIO_bootstrap; extern AudioBootStrap BEOSAUDIO_bootstrap; extern AudioBootStrap COREAUDIO_bootstrap; -extern AudioBootStrap COREAUDIOIPHONE_bootstrap; extern AudioBootStrap SNDMGR_bootstrap; extern AudioBootStrap DISKAUD_bootstrap; extern AudioBootStrap DUMMYAUD_bootstrap; extern AudioBootStrap DCAUD_bootstrap; -extern AudioBootStrap MMEAUDIO_bootstrap; extern AudioBootStrap DART_bootstrap; extern AudioBootStrap NDSAUD_bootstrap; extern AudioBootStrap FUSIONSOUND_bootstrap; @@ -85,7 +81,6 @@ static const AudioBootStrap *const bootstrap[] = { #endif #if SDL_AUDIO_DRIVER_OSS &DSP_bootstrap, - &DMA_bootstrap, #endif #if SDL_AUDIO_DRIVER_QSA &QSAAUDIO_bootstrap, @@ -93,9 +88,6 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_SUNAUDIO &SUNAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_DMEDIA - &DMEDIA_bootstrap, -#endif #if SDL_AUDIO_DRIVER_ARTS &ARTS_bootstrap, #endif @@ -105,11 +97,14 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_NAS &NAS_bootstrap, #endif +#if SDL_AUDIO_DRIVER_XAUDIO2 + &XAUDIO2_bootstrap, +#endif #if SDL_AUDIO_DRIVER_DSOUND &DSOUND_bootstrap, #endif -#if SDL_AUDIO_DRIVER_WINWAVEOUT - &WINWAVEOUT_bootstrap, +#if SDL_AUDIO_DRIVER_WINMM + &WINMM_bootstrap, #endif #if SDL_AUDIO_DRIVER_PAUDIO &PAUDIO_bootstrap, @@ -120,18 +115,12 @@ static const AudioBootStrap *const bootstrap[] = { #if SDL_AUDIO_DRIVER_COREAUDIO &COREAUDIO_bootstrap, #endif -#if SDL_AUDIO_DRIVER_COREAUDIOIPHONE - &COREAUDIOIPHONE_bootstrap, -#endif #if SDL_AUDIO_DRIVER_DISK &DISKAUD_bootstrap, #endif #if SDL_AUDIO_DRIVER_DUMMY &DUMMYAUD_bootstrap, #endif -#if SDL_AUDIO_DRIVER_MMEAUDIO - &MMEAUDIO_bootstrap, -#endif #if SDL_AUDIO_DRIVER_NDS &NDSAUD_bootstrap, #endif @@ -139,7 +128,7 @@ static const AudioBootStrap *const bootstrap[] = { &FUSIONSOUND_bootstrap, #endif #if SDL_AUDIO_DRIVER_ANDROID - &ANDROIDAUD_bootstrap, + &ANDROIDAUD_bootstrap, #endif NULL }; @@ -158,10 +147,9 @@ get_audio_device(SDL_AudioDeviceID id) /* stubs for audio drivers that don't need a specific entry point... */ -static int -SDL_AudioDetectDevices_Default(int iscapture) -{ - return -1; +static void +SDL_AudioDetectDevices_Default(int iscapture, SDL_AddAudioDevice addfn) +{ /* no-op. */ } static void @@ -206,13 +194,6 @@ SDL_AudioOpenDevice_Default(_THIS, const char *devname, int iscapture) return 0; } -static const char * -SDL_AudioGetDeviceName_Default(int index, int iscapture) -{ - SDL_SetError("No such device"); - return NULL; -} - static void SDL_AudioLockDevice_Default(SDL_AudioDevice * device) { @@ -245,7 +226,6 @@ finalize_audio_entry_points(void) current_audio.impl.x = SDL_Audio##x##_Default; \ } FILL_STUB(DetectDevices); - FILL_STUB(GetDeviceName); FILL_STUB(OpenDevice); FILL_STUB(ThreadInit); FILL_STUB(WaitDevice); @@ -336,11 +316,13 @@ SDL_RunAudio(void *devicep) void (SDLCALL * fill) (void *userdata, Uint8 * stream, int len); int silence; Uint32 delay; - /* For streaming when the buffer sizes don't match up */ Uint8 *istream; int istream_len = 0; + /* The audio mixing is always a high priority thread */ + SDL_SetThreadPriority(SDL_THREAD_PRIORITY_HIGH); + /* Perform any thread setup */ device->threadid = SDL_ThreadID(); current_audio.impl.ThreadInit(device); @@ -646,13 +628,64 @@ SDL_GetCurrentAudioDriver() return current_audio.name; } +static void +free_device_list(char ***devices, int *devCount) +{ + int i = *devCount; + if ((i > 0) && (*devices != NULL)) { + while (i--) { + SDL_free((*devices)[i]); + } + } + + if (*devices != NULL) { + SDL_free(*devices); + } + + *devices = NULL; + *devCount = 0; +} + +static +void SDL_AddCaptureAudioDevice(const char *_name) +{ + char *name = NULL; + void *ptr = SDL_realloc(current_audio.inputDevices, + (current_audio.inputDeviceCount+1) * sizeof(char*)); + if (ptr == NULL) { + return; /* oh well. */ + } + + current_audio.inputDevices = (char **) ptr; + name = SDL_strdup(_name); /* if this returns NULL, that's okay. */ + current_audio.inputDevices[current_audio.inputDeviceCount++] = name; +} + +static +void SDL_AddOutputAudioDevice(const char *_name) +{ + char *name = NULL; + void *ptr = SDL_realloc(current_audio.outputDevices, + (current_audio.outputDeviceCount+1) * sizeof(char*)); + if (ptr == NULL) { + return; /* oh well. */ + } + + current_audio.outputDevices = (char **) ptr; + name = SDL_strdup(_name); /* if this returns NULL, that's okay. */ + current_audio.outputDevices[current_audio.outputDeviceCount++] = name; +} + int SDL_GetNumAudioDevices(int iscapture) { + int retval = 0; + if (!SDL_WasInit(SDL_INIT_AUDIO)) { return -1; } + if ((iscapture) && (!current_audio.impl.HasCaptureSupport)) { return 0; } @@ -665,7 +698,19 @@ SDL_GetNumAudioDevices(int iscapture) return 1; } - return current_audio.impl.DetectDevices(iscapture); + if (iscapture) { + free_device_list(¤t_audio.inputDevices, + ¤t_audio.inputDeviceCount); + current_audio.impl.DetectDevices(iscapture, SDL_AddCaptureAudioDevice); + retval = current_audio.inputDeviceCount; + } else { + free_device_list(¤t_audio.outputDevices, + ¤t_audio.outputDeviceCount); + current_audio.impl.DetectDevices(iscapture, SDL_AddOutputAudioDevice); + retval = current_audio.outputDeviceCount; + } + + return retval; } @@ -683,8 +728,7 @@ SDL_GetAudioDeviceName(int index, int iscapture) } if (index < 0) { - SDL_SetError("No such device"); - return NULL; + goto no_such_device; } if ((iscapture) && (current_audio.impl.OnlyHasDefaultInputDevice)) { @@ -695,7 +739,21 @@ SDL_GetAudioDeviceName(int index, int iscapture) return DEFAULT_OUTPUT_DEVNAME; } - return current_audio.impl.GetDeviceName(index, iscapture); + if (iscapture) { + if (index >= current_audio.inputDeviceCount) { + goto no_such_device; + } + return current_audio.inputDevices[index]; + } else { + if (index >= current_audio.outputDeviceCount) { + goto no_such_device; + } + return current_audio.outputDevices[index]; + } + +no_such_device: + SDL_SetError("No such device"); + return NULL; } @@ -885,6 +943,11 @@ open_audio_device(const char *devname, int iscapture, } } + /* force a device detection if we haven't done one yet. */ + if ( ((iscapture) && (current_audio.inputDevices == NULL)) || + ((!iscapture) && (current_audio.outputDevices == NULL)) ) + SDL_GetNumAudioDevices(iscapture); + if (!current_audio.impl.OpenDevice(device, devname, iscapture)) { close_audio_device(device); return 0; @@ -970,12 +1033,14 @@ open_audio_device(const char *devname, int iscapture, /* Start the audio thread if necessary */ if (!current_audio.impl.ProvidesOwnCallbackThread) { /* Start the audio thread */ + char name[64]; + SDL_snprintf(name, sizeof (name), "SDLAudioDev%d", (int) (id + 1)); /* !!! FIXME: this is nasty. */ #if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) #undef SDL_CreateThread - device->thread = SDL_CreateThread(SDL_RunAudio, device, NULL, NULL); + device->thread = SDL_CreateThread(SDL_RunAudio, name, device, NULL, NULL); #else - device->thread = SDL_CreateThread(SDL_RunAudio, device); + device->thread = SDL_CreateThread(SDL_RunAudio, name, device); #endif if (device->thread == NULL) { SDL_CloseAudioDevice(id + 1); @@ -1012,12 +1077,8 @@ SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained) } else { id = open_audio_device(NULL, 0, desired, desired, 0, 1); } - if (id > 1) { /* this should never happen in theory... */ - SDL_CloseAudioDevice(id); - SDL_SetError("Internal error"); /* MUST be Device ID #1! */ - return (-1); - } + SDL_assert((id == 0) || (id == 1)); return ((id == 0) ? -1 : 0); } @@ -1126,6 +1187,10 @@ SDL_AudioQuit(void) /* Free the driver data */ current_audio.impl.Deinitialize(); + free_device_list(¤t_audio.outputDevices, + ¤t_audio.outputDeviceCount); + free_device_list(¤t_audio.inputDevices, + ¤t_audio.inputDeviceCount); SDL_memset(¤t_audio, '\0', sizeof(current_audio)); SDL_memset(open_devices, '\0', sizeof(open_devices)); } diff --git a/project/jni/sdl-1.3/src/audio/SDL_audio_c.h b/project/jni/sdl-1.3/src/audio/SDL_audio_c.h index df88025fa..90a97c42e 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_audio_c.h +++ b/project/jni/sdl-1.3/src/audio/SDL_audio_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/SDL_audiocvt.c b/project/jni/sdl-1.3/src/audio/SDL_audiocvt.c index 3af35f13a..fffab7617 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_audiocvt.c +++ b/project/jni/sdl-1.3/src/audio/SDL_audiocvt.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/SDL_audiodev.c b/project/jni/sdl-1.3/src/audio/SDL_audiodev.c index 67b704f9e..2d8e3936a 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_audiodev.c +++ b/project/jni/sdl-1.3/src/audio/SDL_audiodev.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -49,46 +48,20 @@ static inline void test_device(const char *fname, int flags, int (*test) (int fd), - char ***devices, int *devCount) + SDL_AddAudioDevice addfn) { struct stat sb; if ((stat(fname, &sb) == 0) && (S_ISCHR(sb.st_mode))) { - int audio_fd = open(fname, flags, 0); - if ((audio_fd >= 0) && (test(audio_fd))) { - void *p = - SDL_realloc(*devices, ((*devCount) + 1) * sizeof(char *)); - if (p != NULL) { - size_t len = strlen(fname) + 1; - char *str = (char *) SDL_malloc(len); - *devices = (char **) p; - if (str != NULL) { - SDL_strlcpy(str, fname, len); - (*devices)[(*devCount)++] = str; - } + const int audio_fd = open(fname, flags, 0); + if (audio_fd >= 0) { + if (test(audio_fd)) { + addfn(fname); } close(audio_fd); } } } -void -SDL_FreeUnixAudioDevices(char ***devices, int *devCount) -{ - int i = *devCount; - if ((i > 0) && (*devices != NULL)) { - while (i--) { - SDL_free((*devices)[i]); - } - } - - if (*devices != NULL) { - SDL_free(*devices); - } - - *devices = NULL; - *devCount = 0; -} - static int test_stub(int fd) { @@ -96,9 +69,10 @@ test_stub(int fd) } void -SDL_EnumUnixAudioDevices(int flags, int classic, int (*test) (int fd), - char ***devices, int *devCount) +SDL_EnumUnixAudioDevices(int iscapture, int classic, int (*test)(int fd), + SDL_AddAudioDevice addfn) { + const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); const char *audiodev; char audiopath[1024]; @@ -123,14 +97,14 @@ SDL_EnumUnixAudioDevices(int flags, int classic, int (*test) (int fd), } } } - test_device(audiodev, flags, test, devices, devCount); + test_device(audiodev, flags, test, addfn); if (SDL_strlen(audiodev) < (sizeof(audiopath) - 3)) { int instance = 0; while (instance++ <= 64) { SDL_snprintf(audiopath, SDL_arraysize(audiopath), "%s%d", audiodev, instance); - test_device(audiopath, flags, test, devices, devCount); + test_device(audiopath, flags, test, addfn); } } } diff --git a/project/jni/sdl-1.3/src/audio/SDL_audiodev_c.h b/project/jni/sdl-1.3/src/audio/SDL_audiodev_c.h index 7b0143f71..919b3a855 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_audiodev_c.h +++ b/project/jni/sdl-1.3/src/audio/SDL_audiodev_c.h @@ -1,28 +1,39 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL.h" #include "SDL_config.h" +#include "SDL_sysaudio.h" -void SDL_EnumUnixAudioDevices(int flags, int classic, int (*test) (int fd), - char ***devs, int *count); -void SDL_FreeUnixAudioDevices(char ***devices, int *devCount); +/* Open the audio device for playback, and don't block if busy */ +/* #define USE_BLOCKING_WRITES */ + +#ifdef USE_BLOCKING_WRITES +#define OPEN_FLAGS_OUTPUT O_WRONLY +#define OPEN_FLAGS_INPUT O_RDONLY +#else +#define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK) +#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK) +#endif + +void SDL_EnumUnixAudioDevices(int iscapture, int classic, + int (*test) (int fd), SDL_AddAudioDevice addfn); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/SDL_audiomem.h b/project/jni/sdl-1.3/src/audio/SDL_audiomem.h index a539259e5..a678d2e3d 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_audiomem.h +++ b/project/jni/sdl-1.3/src/audio/SDL_audiomem.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/SDL_audiotypecvt.c b/project/jni/sdl-1.3/src/audio/SDL_audiotypecvt.c index 154bcbd44..1bf4143c2 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_audiotypecvt.c +++ b/project/jni/sdl-1.3/src/audio/SDL_audiotypecvt.c @@ -1,24 +1,23 @@ /* DO NOT EDIT! This file is generated by sdlgenaudiocvt.pl */ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -7103,7 +7102,6 @@ SDL_Upsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U8, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -7131,7 +7129,6 @@ SDL_Downsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U8, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7158,7 +7155,6 @@ SDL_Upsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U8, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -7188,7 +7184,6 @@ SDL_Downsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U8, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7215,7 +7210,6 @@ SDL_Upsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U8, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -7248,7 +7242,6 @@ SDL_Downsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U8, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7279,7 +7272,6 @@ SDL_Upsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U8, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -7316,7 +7308,6 @@ SDL_Downsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U8, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7347,7 +7338,6 @@ SDL_Upsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U8, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -7390,7 +7380,6 @@ SDL_Downsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U8, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7429,7 +7418,6 @@ SDL_Upsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U8, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -7480,7 +7468,6 @@ SDL_Downsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U8, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7519,7 +7506,6 @@ SDL_Upsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U8, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -7572,7 +7558,6 @@ SDL_Downsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U8, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7619,7 +7604,6 @@ SDL_Upsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U8, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -7684,7 +7668,6 @@ SDL_Downsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U8, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7731,7 +7714,6 @@ SDL_Upsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U8, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -7794,7 +7776,6 @@ SDL_Downsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U8, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7849,7 +7830,6 @@ SDL_Upsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U8, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8; const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -7928,7 +7908,6 @@ SDL_Downsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U8, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint8 *dst = (Uint8 *) cvt->buf; const Uint8 *src = (Uint8 *) cvt->buf; @@ -7983,7 +7962,6 @@ SDL_Upsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S8, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -8011,7 +7989,6 @@ SDL_Downsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S8, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8038,7 +8015,6 @@ SDL_Upsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S8, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -8068,7 +8044,6 @@ SDL_Downsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S8, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8095,7 +8070,6 @@ SDL_Upsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S8, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -8128,7 +8102,6 @@ SDL_Downsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S8, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8159,7 +8132,6 @@ SDL_Upsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S8, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -8196,7 +8168,6 @@ SDL_Downsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S8, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8227,7 +8198,6 @@ SDL_Upsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S8, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -8270,7 +8240,6 @@ SDL_Downsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S8, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8309,7 +8278,6 @@ SDL_Upsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S8, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -8360,7 +8328,6 @@ SDL_Downsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S8, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8399,7 +8366,6 @@ SDL_Upsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S8, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -8452,7 +8418,6 @@ SDL_Downsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S8, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8499,7 +8464,6 @@ SDL_Upsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S8, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -8564,7 +8528,6 @@ SDL_Downsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S8, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8611,7 +8574,6 @@ SDL_Upsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S8, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -8674,7 +8636,6 @@ SDL_Downsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S8, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8729,7 +8690,6 @@ SDL_Upsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S8, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8; const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -8808,7 +8768,6 @@ SDL_Downsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S8, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint8 *dst = (Sint8 *) cvt->buf; const Sint8 *src = (Sint8 *) cvt->buf; @@ -8863,7 +8822,6 @@ SDL_Upsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -8891,7 +8849,6 @@ SDL_Downsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -8918,7 +8875,6 @@ SDL_Upsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -8948,7 +8904,6 @@ SDL_Downsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -8975,7 +8930,6 @@ SDL_Upsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -9008,7 +8962,6 @@ SDL_Downsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -9039,7 +8992,6 @@ SDL_Upsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -9076,7 +9028,6 @@ SDL_Downsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -9107,7 +9058,6 @@ SDL_Upsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -9150,7 +9100,6 @@ SDL_Downsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -9189,7 +9138,6 @@ SDL_Upsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -9240,7 +9188,6 @@ SDL_Downsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -9279,7 +9226,6 @@ SDL_Upsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -9332,7 +9278,6 @@ SDL_Downsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -9379,7 +9324,6 @@ SDL_Upsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -9444,7 +9388,6 @@ SDL_Downsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -9491,7 +9434,6 @@ SDL_Upsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -9554,7 +9496,6 @@ SDL_Downsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -9609,7 +9550,6 @@ SDL_Upsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -9688,7 +9628,6 @@ SDL_Downsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -9743,7 +9682,6 @@ SDL_Upsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -9771,7 +9709,6 @@ SDL_Downsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -9798,7 +9735,6 @@ SDL_Upsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -9828,7 +9764,6 @@ SDL_Downsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -9855,7 +9790,6 @@ SDL_Upsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -9888,7 +9822,6 @@ SDL_Downsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -9919,7 +9852,6 @@ SDL_Upsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -9956,7 +9888,6 @@ SDL_Downsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -9987,7 +9918,6 @@ SDL_Upsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -10030,7 +9960,6 @@ SDL_Downsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -10069,7 +9998,6 @@ SDL_Upsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -10120,7 +10048,6 @@ SDL_Downsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -10159,7 +10086,6 @@ SDL_Upsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -10212,7 +10138,6 @@ SDL_Downsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -10259,7 +10184,6 @@ SDL_Upsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -10324,7 +10248,6 @@ SDL_Downsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -10371,7 +10294,6 @@ SDL_Upsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -10434,7 +10356,6 @@ SDL_Downsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -10489,7 +10410,6 @@ SDL_Upsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -10568,7 +10488,6 @@ SDL_Downsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -10623,7 +10542,6 @@ SDL_Upsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -10651,7 +10569,6 @@ SDL_Downsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -10678,7 +10595,6 @@ SDL_Upsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -10708,7 +10624,6 @@ SDL_Downsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -10735,7 +10650,6 @@ SDL_Upsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -10768,7 +10682,6 @@ SDL_Downsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -10799,7 +10712,6 @@ SDL_Upsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -10836,7 +10748,6 @@ SDL_Downsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -10867,7 +10778,6 @@ SDL_Upsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -10910,7 +10820,6 @@ SDL_Downsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -10949,7 +10858,6 @@ SDL_Upsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -11000,7 +10908,6 @@ SDL_Downsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -11039,7 +10946,6 @@ SDL_Upsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -11092,7 +10998,6 @@ SDL_Downsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -11139,7 +11044,6 @@ SDL_Upsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -11204,7 +11108,6 @@ SDL_Downsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -11251,7 +11154,6 @@ SDL_Upsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -11314,7 +11216,6 @@ SDL_Downsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -11369,7 +11270,6 @@ SDL_Upsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8; const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -11448,7 +11348,6 @@ SDL_Downsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Uint16 *dst = (Uint16 *) cvt->buf; const Uint16 *src = (Uint16 *) cvt->buf; @@ -11503,7 +11402,6 @@ SDL_Upsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -11531,7 +11429,6 @@ SDL_Downsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -11558,7 +11455,6 @@ SDL_Upsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -11588,7 +11484,6 @@ SDL_Downsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -11615,7 +11510,6 @@ SDL_Upsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -11648,7 +11542,6 @@ SDL_Downsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -11679,7 +11572,6 @@ SDL_Upsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -11716,7 +11608,6 @@ SDL_Downsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -11747,7 +11638,6 @@ SDL_Upsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -11790,7 +11680,6 @@ SDL_Downsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -11829,7 +11718,6 @@ SDL_Upsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -11880,7 +11768,6 @@ SDL_Downsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -11919,7 +11806,6 @@ SDL_Upsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -11972,7 +11858,6 @@ SDL_Downsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -12019,7 +11904,6 @@ SDL_Upsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -12084,7 +11968,6 @@ SDL_Downsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -12131,7 +12014,6 @@ SDL_Upsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -12194,7 +12076,6 @@ SDL_Downsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -12249,7 +12130,6 @@ SDL_Upsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8; const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -12328,7 +12208,6 @@ SDL_Downsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint16 *dst = (Sint16 *) cvt->buf; const Sint16 *src = (Sint16 *) cvt->buf; @@ -12383,7 +12262,6 @@ SDL_Upsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -12411,7 +12289,6 @@ SDL_Downsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -12438,7 +12315,6 @@ SDL_Upsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -12468,7 +12344,6 @@ SDL_Downsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -12495,7 +12370,6 @@ SDL_Upsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -12528,7 +12402,6 @@ SDL_Downsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -12559,7 +12432,6 @@ SDL_Upsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -12596,7 +12468,6 @@ SDL_Downsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -12627,7 +12498,6 @@ SDL_Upsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -12670,7 +12540,6 @@ SDL_Downsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -12709,7 +12578,6 @@ SDL_Upsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -12760,7 +12628,6 @@ SDL_Downsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -12799,7 +12666,6 @@ SDL_Upsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -12852,7 +12718,6 @@ SDL_Downsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -12899,7 +12764,6 @@ SDL_Upsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -12964,7 +12828,6 @@ SDL_Downsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13011,7 +12874,6 @@ SDL_Upsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -13074,7 +12936,6 @@ SDL_Downsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13129,7 +12990,6 @@ SDL_Upsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -13208,7 +13068,6 @@ SDL_Downsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13263,7 +13122,6 @@ SDL_Upsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -13291,7 +13149,6 @@ SDL_Downsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13318,7 +13175,6 @@ SDL_Upsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1; @@ -13348,7 +13204,6 @@ SDL_Downsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13375,7 +13230,6 @@ SDL_Upsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -13408,7 +13262,6 @@ SDL_Downsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13439,7 +13292,6 @@ SDL_Upsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2; @@ -13476,7 +13328,6 @@ SDL_Downsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13507,7 +13358,6 @@ SDL_Upsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -13550,7 +13400,6 @@ SDL_Downsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13589,7 +13438,6 @@ SDL_Upsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4; @@ -13640,7 +13488,6 @@ SDL_Downsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13679,7 +13526,6 @@ SDL_Upsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -13732,7 +13578,6 @@ SDL_Downsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13779,7 +13624,6 @@ SDL_Upsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6; @@ -13844,7 +13688,6 @@ SDL_Downsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -13891,7 +13734,6 @@ SDL_Upsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -13954,7 +13796,6 @@ SDL_Downsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -14009,7 +13850,6 @@ SDL_Upsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8; const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8; @@ -14088,7 +13928,6 @@ SDL_Downsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; Sint32 *dst = (Sint32 *) cvt->buf; const Sint32 *src = (Sint32 *) cvt->buf; @@ -14143,7 +13982,6 @@ SDL_Upsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 1; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1; @@ -14171,7 +14009,6 @@ SDL_Downsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14198,7 +14035,6 @@ SDL_Upsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 1; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1; @@ -14228,7 +14064,6 @@ SDL_Downsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14255,7 +14090,6 @@ SDL_Upsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 2; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2; @@ -14288,7 +14122,6 @@ SDL_Downsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14319,7 +14152,6 @@ SDL_Upsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 2; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2; @@ -14356,7 +14188,6 @@ SDL_Downsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14387,7 +14218,6 @@ SDL_Upsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 4; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4; @@ -14430,7 +14260,6 @@ SDL_Downsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14469,7 +14298,6 @@ SDL_Upsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 4; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4; @@ -14520,7 +14348,6 @@ SDL_Downsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14559,7 +14386,6 @@ SDL_Upsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 6; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6; @@ -14612,7 +14438,6 @@ SDL_Downsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14659,7 +14484,6 @@ SDL_Upsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 6; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6; @@ -14724,7 +14548,6 @@ SDL_Downsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14771,7 +14594,6 @@ SDL_Upsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 8; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8; @@ -14834,7 +14656,6 @@ SDL_Downsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -14889,7 +14710,6 @@ SDL_Upsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 8; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8; @@ -14968,7 +14788,6 @@ SDL_Downsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15023,7 +14842,6 @@ SDL_Upsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 1; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1; @@ -15051,7 +14869,6 @@ SDL_Downsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15078,7 +14895,6 @@ SDL_Upsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 1; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1; @@ -15108,7 +14924,6 @@ SDL_Downsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 1 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15135,7 +14950,6 @@ SDL_Upsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 2; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2; @@ -15168,7 +14982,6 @@ SDL_Downsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15199,7 +15012,6 @@ SDL_Upsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 2; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2; @@ -15236,7 +15048,6 @@ SDL_Downsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 2 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15267,7 +15078,6 @@ SDL_Upsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 4; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4; @@ -15310,7 +15120,6 @@ SDL_Downsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15349,7 +15158,6 @@ SDL_Upsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 4; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4; @@ -15400,7 +15208,6 @@ SDL_Downsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 4 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15439,7 +15246,6 @@ SDL_Upsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 6; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6; @@ -15492,7 +15298,6 @@ SDL_Downsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15539,7 +15344,6 @@ SDL_Upsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 6; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6; @@ -15604,7 +15408,6 @@ SDL_Downsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 6 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15651,7 +15454,6 @@ SDL_Upsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 2; float *dst = ((float *) (cvt->buf + dstsize)) - 8; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8; @@ -15714,7 +15516,6 @@ SDL_Downsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 2; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; @@ -15769,7 +15570,6 @@ SDL_Upsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt * 4; float *dst = ((float *) (cvt->buf + dstsize)) - 8; const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8; @@ -15848,7 +15648,6 @@ SDL_Downsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 8 channels.\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt / 4; float *dst = (float *) cvt->buf; const float *src = (float *) cvt->buf; diff --git a/project/jni/sdl-1.3/src/audio/SDL_mixer.c b/project/jni/sdl-1.3/src/audio/SDL_mixer.c index 2cc7a8771..5b122bf97 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_mixer.c +++ b/project/jni/sdl-1.3/src/audio/SDL_mixer.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -27,9 +26,6 @@ #include "SDL_timer.h" #include "SDL_audio.h" #include "SDL_sysaudio.h" -#include "SDL_mixer_MMX.h" -#include "SDL_mixer_MMX_VC.h" -#include "SDL_mixer_m68k.h" /* This table is used to add two sound values together and pin * the value to avoid overflow. (used with permission from ARDI) @@ -122,95 +118,55 @@ SDL_MixAudioFormat(Uint8 * dst, const Uint8 * src, SDL_AudioFormat format, case AUDIO_S8: { -#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */ -#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) - if (SDL_HasMMX()) { - SDL_MixAudio_MMX_S8((char *) dst, (char *) src, - (unsigned int) len, (int) volume); - } else -#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES) - if (SDL_HasMMX()) { - SDL_MixAudio_MMX_S8_VC((char *) dst, (char *) src, - (unsigned int) len, (int) volume); - } else -#endif -#endif -#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES) - SDL_MixAudio_m68k_S8((char *) dst, (char *) src, - (unsigned long) len, (long) volume); -#else - { - Sint8 *dst8, *src8; - Sint8 src_sample; - int dst_sample; - const int max_audioval = ((1 << (8 - 1)) - 1); - const int min_audioval = -(1 << (8 - 1)); + Sint8 *dst8, *src8; + Sint8 src_sample; + int dst_sample; + const int max_audioval = ((1 << (8 - 1)) - 1); + const int min_audioval = -(1 << (8 - 1)); - src8 = (Sint8 *) src; - dst8 = (Sint8 *) dst; - while (len--) { - src_sample = *src8; - ADJUST_VOLUME(src_sample, volume); - dst_sample = *dst8 + src_sample; - if (dst_sample > max_audioval) { - *dst8 = max_audioval; - } else if (dst_sample < min_audioval) { - *dst8 = min_audioval; - } else { - *dst8 = dst_sample; - } - ++dst8; - ++src8; + src8 = (Sint8 *) src; + dst8 = (Sint8 *) dst; + while (len--) { + src_sample = *src8; + ADJUST_VOLUME(src_sample, volume); + dst_sample = *dst8 + src_sample; + if (dst_sample > max_audioval) { + *dst8 = max_audioval; + } else if (dst_sample < min_audioval) { + *dst8 = min_audioval; + } else { + *dst8 = dst_sample; } + ++dst8; + ++src8; } -#endif } break; case AUDIO_S16LSB: { -#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */ -#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) - if (SDL_HasMMX()) { - SDL_MixAudio_MMX_S16((char *) dst, (char *) src, - (unsigned int) len, (int) volume); - } else -#elif ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES) - if (SDL_HasMMX()) { - SDL_MixAudio_MMX_S16_VC((char *) dst, (char *) src, - (unsigned int) len, (int) volume); - } else -#endif -#endif -#if defined(__GNUC__) && defined(__M68000__) && !defined(__mcoldfire__) && defined(SDL_ASSEMBLY_ROUTINES) - SDL_MixAudio_m68k_S16LSB((short *) dst, (short *) src, - (unsigned long) len, (long) volume); -#else - { - Sint16 src1, src2; - int dst_sample; - const int max_audioval = ((1 << (16 - 1)) - 1); - const int min_audioval = -(1 << (16 - 1)); + Sint16 src1, src2; + int dst_sample; + const int max_audioval = ((1 << (16 - 1)) - 1); + const int min_audioval = -(1 << (16 - 1)); - len /= 2; - while (len--) { - src1 = ((src[1]) << 8 | src[0]); - ADJUST_VOLUME(src1, volume); - src2 = ((dst[1]) << 8 | dst[0]); - src += 2; - dst_sample = src1 + src2; - if (dst_sample > max_audioval) { - dst_sample = max_audioval; - } else if (dst_sample < min_audioval) { - dst_sample = min_audioval; - } - dst[0] = dst_sample & 0xFF; - dst_sample >>= 8; - dst[1] = dst_sample & 0xFF; - dst += 2; + len /= 2; + while (len--) { + src1 = ((src[1]) << 8 | src[0]); + ADJUST_VOLUME(src1, volume); + src2 = ((dst[1]) << 8 | dst[0]); + src += 2; + dst_sample = src1 + src2; + if (dst_sample > max_audioval) { + dst_sample = max_audioval; + } else if (dst_sample < min_audioval) { + dst_sample = min_audioval; } + dst[0] = dst_sample & 0xFF; + dst_sample >>= 8; + dst[1] = dst_sample & 0xFF; + dst += 2; } -#endif } break; diff --git a/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX.c b/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX.c deleted file mode 100644 index 40b880585..000000000 --- a/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX.c +++ /dev/null @@ -1,124 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples - Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) - This code is licensed under the LGPL (see COPYING for details) - - Assumes buffer size in bytes is a multiple of 16 - Assumes SDL_MIX_MAXVOLUME = 128 -*/ - - -/*********************************************** -* Mixing for 16 bit signed buffers -***********************************************/ - -#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */ -#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) -void -SDL_MixAudio_MMX_S16(char *dst, char *src, unsigned int size, int volume) -{ - __asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */ - " movl %2,%%edx\n" /* edx = size */ - " shrl $4,%%edx\n" /* process 16 bytes per iteration = 8 samples */ - " jz .endS16\n" " pxor %%mm0,%%mm0\n" " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" /* mm0 = vol|vol|vol|vol */ - ".align 8\n" " .mixloopS16:\n" " movq (%1),%%mm1\n" /* mm1 = a|b|c|d */ - " movq %%mm1,%%mm2\n" /* mm2 = a|b|c|d */ - " movq 8(%1),%%mm4\n" /* mm4 = e|f|g|h */ - /* pré charger le buffer dst dans mm7 */ - " movq (%0),%%mm7\n" /* mm7 = dst[0] */ - /* multiplier par le volume */ - " pmullw %%mm0,%%mm1\n" /* mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */ - " pmulhw %%mm0,%%mm2\n" /* mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) */ - " movq %%mm4,%%mm5\n" /* mm5 = e|f|g|h */ - " pmullw %%mm0,%%mm4\n" /* mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */ - " pmulhw %%mm0,%%mm5\n" /* mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) */ - " movq %%mm1,%%mm3\n" /* mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) */ - " punpckhwd %%mm2,%%mm1\n" /* mm1 = a*v|b*v */ - " movq %%mm4,%%mm6\n" /* mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) */ - " punpcklwd %%mm2,%%mm3\n" /* mm3 = c*v|d*v */ - " punpckhwd %%mm5,%%mm4\n" /* mm4 = e*f|f*v */ - " punpcklwd %%mm5,%%mm6\n" /* mm6 = g*v|h*v */ - /* pré charger le buffer dst dans mm5 */ - " movq 8(%0),%%mm5\n" /* mm5 = dst[1] */ - /* diviser par 128 */ - " psrad $7,%%mm1\n" /* mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME */ - " add $16,%1\n" " psrad $7,%%mm3\n" /* mm3 = c*v/128|d*v/128 */ - " psrad $7,%%mm4\n" /* mm4 = e*v/128|f*v/128 */ - /* mm1 = le sample avec le volume modifié */ - " packssdw %%mm1,%%mm3\n" /* mm3 = s(a*v|b*v|c*v|d*v) */ - " psrad $7,%%mm6\n" /* mm6= g*v/128|h*v/128 */ - " paddsw %%mm7,%%mm3\n" /* mm3 = adjust_volume(src)+dst */ - /* mm4 = le sample avec le volume modifié */ - " packssdw %%mm4,%%mm6\n" /* mm6 = s(e*v|f*v|g*v|h*v) */ - " movq %%mm3,(%0)\n" " paddsw %%mm5,%%mm6\n" /* mm6 = adjust_volume(src)+dst */ - " movq %%mm6,8(%0)\n" - " add $16,%0\n" - " dec %%edx\n" - " jnz .mixloopS16\n" - " emms\n" - ".endS16:\n"::"r"(dst), "r"(src), - "m"(size), "m"(volume):"eax", "edx", "memory"); -} - - - -/*////////////////////////////////////////////// */ -/* Mixing for 8 bit signed buffers */ -/*////////////////////////////////////////////// */ - -void -SDL_MixAudio_MMX_S8(char *dst, char *src, unsigned int size, int volume) -{ - __asm__ __volatile__(" movl %3,%%eax\n" /* eax = volume */ - " movd %%eax,%%mm0\n" " movq %%mm0,%%mm1\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " psllq $16,%%mm0\n" " por %%mm1,%%mm0\n" " movl %2,%%edx\n" /* edx = size */ - " shr $3,%%edx\n" /* process 8 bytes per iteration = 8 samples */ - " cmp $0,%%edx\n" " je .endS8\n" ".align 8\n" " .mixloopS8:\n" " pxor %%mm2,%%mm2\n" /* mm2 = 0 */ - " movq (%1),%%mm1\n" /* mm1 = a|b|c|d|e|f|g|h */ - " movq %%mm1,%%mm3\n" /* mm3 = a|b|c|d|e|f|g|h */ - /* on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 */ - " pcmpgtb %%mm1,%%mm2\n" /* mm2 = 11111111|00000000|00000000.... */ - " punpckhbw %%mm2,%%mm1\n" /* mm1 = 0|a|0|b|0|c|0|d */ - " punpcklbw %%mm2,%%mm3\n" /* mm3 = 0|e|0|f|0|g|0|h */ - " movq (%0),%%mm2\n" /* mm2 = destination */ - " pmullw %%mm0,%%mm1\n" /* mm1 = v*a|v*b|v*c|v*d */ - " add $8,%1\n" " pmullw %%mm0,%%mm3\n" /* mm3 = v*e|v*f|v*g|v*h */ - " psraw $7,%%mm1\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128 */ - " psraw $7,%%mm3\n" /* mm3 = v*e/128|v*f/128|v*g/128|v*h/128 */ - " packsswb %%mm1,%%mm3\n" /* mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 */ - " paddsb %%mm2,%%mm3\n" /* add to destination buffer */ - " movq %%mm3,(%0)\n" /* store back to ram */ - " add $8,%0\n" - " dec %%edx\n" - " jnz .mixloopS8\n" - ".endS8:\n" - " emms\n"::"r"(dst), "r"(src), "m"(size), - "m"(volume):"eax", "edx", "memory"); -} -#endif - -#endif /* SDL_BUGGY_MMX_MIXERS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX.h b/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX.h deleted file mode 100644 index c45b5731a..000000000 --- a/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX.h +++ /dev/null @@ -1,17 +0,0 @@ -/* - headers for MMX assembler version of SDL_MixAudio - Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) - This code is licensed under the LGPL (see COPYING for details) - - Assumes buffer size in bytes is a multiple of 16 - Assumes SDL_MIX_MAXVOLUME = 128 -*/ -#include "SDL_config.h" - -#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */ -#if defined(__GNUC__) && defined(__i386__) && defined(SDL_ASSEMBLY_ROUTINES) -void SDL_MixAudio_MMX_S16(char *, char *, unsigned int, int); -void SDL_MixAudio_MMX_S8(char *, char *, unsigned int, int); -#endif -#endif /* SDL_BUGGY_MMX_MIXERS */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX_VC.c b/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX_VC.c deleted file mode 100644 index 94e710635..000000000 --- a/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX_VC.c +++ /dev/null @@ -1,190 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_mixer_MMX_VC.h" - -#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */ -#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES) -// MMX assembler version of SDL_MixAudio for signed little endian 16 bit samples and signed 8 bit samples -// Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) -// Converted to Intel ASM notation by Cth -// This code is licensed under the LGPL (see COPYING for details) -// -// Assumes buffer size in bytes is a multiple of 16 -// Assumes SDL_MIX_MAXVOLUME = 128 - - -//////////////////////////////////////////////// -// Mixing for 16 bit signed buffers -//////////////////////////////////////////////// - -void -SDL_MixAudio_MMX_S16_VC(char *dst, char *src, unsigned int nSize, int volume) -{ - /* *INDENT-OFF* */ - __asm - { - - push edi - push esi - push ebx - - mov edi, dst // edi = dst - mov esi, src // esi = src - mov eax, volume // eax = volume - mov ebx, nSize // ebx = size - shr ebx, 4 // process 16 bytes per iteration = 8 samples - jz endS16 - - pxor mm0, mm0 - movd mm0, eax //%%eax,%%mm0 - movq mm1, mm0 //%%mm0,%%mm1 - psllq mm0, 16 //$16,%%mm0 - por mm0, mm1 //%%mm1,%%mm0 - psllq mm0, 16 //$16,%%mm0 - por mm0, mm1 //%%mm1,%%mm0 - psllq mm0, 16 //$16,%%mm0 - por mm0, mm1 //%%mm1,%%mm0 // mm0 = vol|vol|vol|vol - - #ifndef __WATCOMC__ - align 16 - #endif -mixloopS16: - movq mm1, [esi] //(%%esi),%%mm1\n" // mm1 = a|b|c|d - movq mm2, mm1 //%%mm1,%%mm2\n" // mm2 = a|b|c|d - movq mm4, [esi + 8] //8(%%esi),%%mm4\n" // mm4 = e|f|g|h - // pre charger le buffer dst dans mm7 - movq mm7, [edi] //(%%edi),%%mm7\n" // mm7 = dst[0]" - // multiplier par le volume - pmullw mm1, mm0 //%%mm0,%%mm1\n" // mm1 = l(a*v)|l(b*v)|l(c*v)|l(d*v) - pmulhw mm2, mm0 //%%mm0,%%mm2\n" // mm2 = h(a*v)|h(b*v)|h(c*v)|h(d*v) - movq mm5, mm4 //%%mm4,%%mm5\n" // mm5 = e|f|g|h - pmullw mm4, mm0 //%%mm0,%%mm4\n" // mm4 = l(e*v)|l(f*v)|l(g*v)|l(h*v) - pmulhw mm5, mm0 //%%mm0,%%mm5\n" // mm5 = h(e*v)|h(f*v)|h(g*v)|h(h*v) - movq mm3, mm1 //%%mm1,%%mm3\n" // mm3 = l(a*v)|l(b*v)|l(c*v)|l(d*v) - punpckhwd mm1, mm2 //%%mm2,%%mm1\n" // mm1 = a*v|b*v - movq mm6, mm4 //%%mm4,%%mm6\n" // mm6 = l(e*v)|l(f*v)|l(g*v)|l(h*v) - punpcklwd mm3, mm2 //%%mm2,%%mm3\n" // mm3 = c*v|d*v - punpckhwd mm4, mm5 //%%mm5,%%mm4\n" // mm4 = e*f|f*v - punpcklwd mm6, mm5 //%%mm5,%%mm6\n" // mm6 = g*v|h*v - // pre charger le buffer dst dans mm5 - movq mm5, [edi + 8] //8(%%edi),%%mm5\n" // mm5 = dst[1] - // diviser par 128 - psrad mm1, 7 //$7,%%mm1\n" // mm1 = a*v/128|b*v/128 , 128 = SDL_MIX_MAXVOLUME - add esi, 16 //$16,%%esi\n" - psrad mm3, 7 //$7,%%mm3\n" // mm3 = c*v/128|d*v/128 - psrad mm4, 7 //$7,%%mm4\n" // mm4 = e*v/128|f*v/128 - // mm1 = le sample avec le volume modifie - packssdw mm3, mm1 //%%mm1,%%mm3\n" // mm3 = s(a*v|b*v|c*v|d*v) - psrad mm6, 7 //$7,%%mm6\n" // mm6= g*v/128|h*v/128 - paddsw mm3, mm7 //%%mm7,%%mm3\n" // mm3 = adjust_volume(src)+dst - // mm4 = le sample avec le volume modifie - packssdw mm6, mm4 //%%mm4,%%mm6\n" // mm6 = s(e*v|f*v|g*v|h*v) - movq [edi], mm3 //%%mm3,(%%edi)\n" - paddsw mm6, mm5 //%%mm5,%%mm6\n" // mm6 = adjust_volume(src)+dst - movq [edi + 8], mm6 //%%mm6,8(%%edi)\n" - add edi, 16 //$16,%%edi\n" - dec ebx //%%ebx\n" - jnz mixloopS16 - -endS16: - emms - - pop ebx - pop esi - pop edi - } - /* *INDENT-ON* */ -} - -//////////////////////////////////////////////// -// Mixing for 8 bit signed buffers -//////////////////////////////////////////////// - -void -SDL_MixAudio_MMX_S8_VC(char *dst, char *src, unsigned int nSize, int volume) -{ - /* *INDENT-OFF* */ - _asm - { - - push edi - push esi - push ebx - - mov edi, dst //movl %0,%%edi // edi = dst - mov esi, src //%1,%%esi // esi = src - mov eax, volume //%3,%%eax // eax = volume - - movd mm0, eax //%%eax,%%mm0 - movq mm1, mm0 //%%mm0,%%mm1 - psllq mm0, 16 //$16,%%mm0 - por mm0, mm1 //%%mm1,%%mm0 - psllq mm0, 16 //$16,%%mm0 - por mm0, mm1 //%%mm1,%%mm0 - psllq mm0, 16 //$16,%%mm0 - por mm0, mm1 //%%mm1,%%mm0 - - mov ebx, nSize //%2,%%ebx // ebx = size - shr ebx, 3 //$3,%%ebx // process 8 bytes per iteration = 8 samples - cmp ebx, 0 //$0,%%ebx - je endS8 - - #ifndef __WATCOMC__ - align 16 - #endif -mixloopS8: - pxor mm2, mm2 //%%mm2,%%mm2 // mm2 = 0 - movq mm1, [esi] //(%%esi),%%mm1 // mm1 = a|b|c|d|e|f|g|h - movq mm3, mm1 //%%mm1,%%mm3 // mm3 = a|b|c|d|e|f|g|h - // on va faire le "sign extension" en faisant un cmp avec 0 qui retourne 1 si <0, 0 si >0 - pcmpgtb mm2, mm1 //%%mm1,%%mm2 // mm2 = 11111111|00000000|00000000.... - punpckhbw mm1, mm2 //%%mm2,%%mm1 // mm1 = 0|a|0|b|0|c|0|d - punpcklbw mm3, mm2 //%%mm2,%%mm3 // mm3 = 0|e|0|f|0|g|0|h - movq mm2, [edi] //(%%edi),%%mm2 // mm2 = destination - pmullw mm1, mm0 //%%mm0,%%mm1 // mm1 = v*a|v*b|v*c|v*d - add esi, 8 //$8,%%esi - pmullw mm3, mm0 //%%mm0,%%mm3 // mm3 = v*e|v*f|v*g|v*h - psraw mm1, 7 //$7,%%mm1 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128 - psraw mm3, 7 //$7,%%mm3 // mm3 = v*e/128|v*f/128|v*g/128|v*h/128 - packsswb mm3, mm1 //%%mm1,%%mm3 // mm1 = v*a/128|v*b/128|v*c/128|v*d/128|v*e/128|v*f/128|v*g/128|v*h/128 - paddsb mm3, mm2 //%%mm2,%%mm3 // add to destination buffer - movq [edi], mm3 //%%mm3,(%%edi) // store back to ram - add edi, 8 //$8,%%edi - dec ebx //%%ebx - jnz mixloopS8 - -endS8: - emms - - pop ebx - pop esi - pop edi - } - /* *INDENT-ON* */ -} - -#endif /* SDL_ASSEMBLY_ROUTINES */ -#endif /* SDL_BUGGY_MMX_MIXERS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX_VC.h b/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX_VC.h deleted file mode 100644 index 45f95b617..000000000 --- a/project/jni/sdl-1.3/src/audio/SDL_mixer_MMX_VC.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#if defined(SDL_BUGGY_MMX_MIXERS) /* buggy, so we're disabling them. --ryan. */ -#if ((defined(_MSC_VER) && defined(_M_IX86)) || defined(__WATCOMC__)) && defined(SDL_ASSEMBLY_ROUTINES) -/* headers for MMX assembler version of SDL_MixAudio - Copyright 2002 Stephane Marchesin (stephane.marchesin@wanadoo.fr) - Converted to Intel ASM notation by Cth - This code is licensed under the LGPL (see COPYING for details) - - Assumes buffer size in bytes is a multiple of 16 - Assumes SDL_MIX_MAXVOLUME = 128 -*/ -void SDL_MixAudio_MMX_S16_VC(char *, char *, unsigned int, int); -void SDL_MixAudio_MMX_S8_VC(char *, char *, unsigned int, int); -#endif -#endif /* SDL_BUGGY_MMX_MIXERS */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/SDL_mixer_m68k.c b/project/jni/sdl-1.3/src/audio/SDL_mixer_m68k.c deleted file mode 100644 index 72f7c96e5..000000000 --- a/project/jni/sdl-1.3/src/audio/SDL_mixer_m68k.c +++ /dev/null @@ -1,140 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - m68k assembly mix routines - - Patrice Mandin -*/ - -#if defined(__M68000__) && !defined(__mcoldfire__) && defined(__GNUC__) -void -SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume, char *mix8) -{ - __asm__ __volatile__("tstl %2\n" " beqs stoploop_u8\n" "mixloop_u8:\n" - /* Mix a sample */ - " moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */ - " sub #128,%%d0\n" /* d0 -= 128 */ - " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ - " moveb %0@,%%d1\n" /* d1 = *dst */ - " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ - " add #128,%%d0\n" /* d0 += 128 */ - " add %%d1,%%d0\n" - " moveb %4@(%%d0:w),%0@+\n" - /* Loop till done */ - " subql #1,%2\n" " bhis mixloop_u8\n" "stoploop_u8:\n": /* no return value */ - : /* input */ - "a"(dst), "a"(src), "d"(len), "d"(volume), "a"(mix8): /* clobbered registers */ - "d0", "d1", "cc", "memory"); -} - -void -SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume) -{ - __asm__ __volatile__("tstl %2\n" - " beqs stoploop_s8\n" - " moveq #-128,%%d2\n" - " moveq #127,%%d3\n" "mixloop_s8:\n" - /* Mix a sample */ - " moveq #0,%%d0\n" " moveq #0,%%d1\n" " moveb %1@+,%%d0\n" /* d0 = *src++ */ - " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ - " moveb %0@,%%d1\n" /* d1 = *dst */ - " asr #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ - " add %%d1,%%d0\n" - " cmp %%d2,%%d0\n" - " bges lower_limit_s8\n" - " move %%d2,%%d0\n" - "lower_limit_s8:\n" - " cmp %%d3,%%d0\n" - " bles upper_limit_s8\n" - " move %%d3,%%d0\n" - "upper_limit_s8:\n" " moveb %%d0,%0@+\n" - /* Loop till done */ - " subql #1,%2\n" " bhis mixloop_s8\n" "stoploop_s8:\n": /* no return value */ - : /* input */ - "a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */ - "d0", "d1", "d2", "d3", "cc", "memory"); -} - -void -SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume) -{ - __asm__ __volatile__("tstl %2\n" - " beqs stoploop_s16msb\n" - " movel #-32768,%%d2\n" - " movel #32767,%%d3\n" - " lsrl #1,%2\n" "mixloop_s16msb:\n" - /* Mix a sample */ - " move %1@+,%%d0\n" /* d0 = *src++ */ - " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ - " move %0@,%%d1\n" /* d1 = *dst */ - " extl %%d1\n" /* extend d1 to 32 bits */ - " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ - " addl %%d1,%%d0\n" - " cmpl %%d2,%%d0\n" - " bges lower_limit_s16msb\n" - " move %%d2,%%d0\n" - "lower_limit_s16msb:\n" - " cmpl %%d3,%%d0\n" - " bles upper_limit_s16msb\n" - " move %%d3,%%d0\n" - "upper_limit_s16msb:\n" " move %%d0,%0@+\n" - /* Loop till done */ - " subql #1,%2\n" " bhis mixloop_s16msb\n" "stoploop_s16msb:\n": /* no return value */ - : /* input */ - "a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */ - "d0", "d1", "d2", "d3", "cc", "memory"); -} - -void -SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume) -{ - __asm__ __volatile__("tstl %2\n" - " beqs stoploop_s16lsb\n" - " movel #-32768,%%d2\n" - " movel #32767,%%d3\n" - " lsrl #1,%2\n" "mixloop_s16lsb:\n" - /* Mix a sample */ - " move %1@+,%%d0\n" /* d0 = *src++ */ - " rorw #8,%%d0\n" " muls %3,%%d0\n" /* d0 *= volume (0<=volume<=128) */ - " move %0@,%%d1\n" /* d1 = *dst */ - " rorw #8,%%d1\n" " extl %%d1\n" /* extend d1 to 32 bits */ - " asrl #7,%%d0\n" /* d0 /= 128 (SDL_MIX_MAXVOLUME) */ - " addl %%d1,%%d0\n" - " cmpl %%d2,%%d0\n" - " bges lower_limit_s16lsb\n" - " move %%d2,%%d0\n" - "lower_limit_s16lsb:\n" - " cmpl %%d3,%%d0\n" - " bles upper_limit_s16lsb\n" - " move %%d3,%%d0\n" - "upper_limit_s16lsb:\n" - " rorw #8,%%d0\n" " move %%d0,%0@+\n" - /* Loop till done */ - " subql #1,%2\n" " bhis mixloop_s16lsb\n" "stoploop_s16lsb:\n": /* no return value */ - : /* input */ - "a"(dst), "a"(src), "d"(len), "d"(volume): /* clobbered registers */ - "d0", "d1", "d2", "d3", "cc", "memory"); -} -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/SDL_mixer_m68k.h b/project/jni/sdl-1.3/src/audio/SDL_mixer_m68k.h deleted file mode 100644 index c0b4754c6..000000000 --- a/project/jni/sdl-1.3/src/audio/SDL_mixer_m68k.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - m68k assembly mix routines - - Patrice Mandin -*/ - -#if defined(__M68000__) && defined(__GNUC__) -void SDL_MixAudio_m68k_U8(char *dst, char *src, long len, long volume, - char *mix8); -void SDL_MixAudio_m68k_S8(char *dst, char *src, long len, long volume); - -void SDL_MixAudio_m68k_S16MSB(short *dst, short *src, long len, long volume); -void SDL_MixAudio_m68k_S16LSB(short *dst, short *src, long len, long volume); -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/SDL_sysaudio.h b/project/jni/sdl-1.3/src/audio/SDL_sysaudio.h index 329e417bf..14e22a8c1 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_sysaudio.h +++ b/project/jni/sdl-1.3/src/audio/SDL_sysaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is SDL_free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -31,10 +30,12 @@ typedef struct SDL_AudioDevice SDL_AudioDevice; #define _THIS SDL_AudioDevice *_this +/* Used by audio targets during DetectDevices() */ +typedef void (*SDL_AddAudioDevice)(const char *name); + typedef struct SDL_AudioDriverImpl { - int (*DetectDevices) (int iscapture); - const char *(*GetDeviceName) (int index, int iscapture); + void (*DetectDevices) (int iscapture, SDL_AddAudioDevice addfn); int (*OpenDevice) (_THIS, const char *devname, int iscapture); void (*ThreadInit) (_THIS); /* Called by audio thread at start */ void (*WaitDevice) (_THIS); @@ -46,12 +47,14 @@ typedef struct SDL_AudioDriverImpl void (*UnlockDevice) (_THIS); void (*Deinitialize) (void); + /* !!! FIXME: add pause(), so we can optimize instead of mixing silence. */ + /* Some flags to push duplicate code into the core and reduce #ifdefs. */ - int ProvidesOwnCallbackThread:1; - int SkipMixerLock:1; - int HasCaptureSupport:1; - int OnlyHasDefaultOutputDevice:1; - int OnlyHasDefaultInputDevice:1; + int ProvidesOwnCallbackThread; + int SkipMixerLock; /* !!! FIXME: do we need this anymore? */ + int HasCaptureSupport; + int OnlyHasDefaultOutputDevice; + int OnlyHasDefaultInputDevice; } SDL_AudioDriverImpl; @@ -66,6 +69,12 @@ typedef struct SDL_AudioDriver const char *desc; SDL_AudioDriverImpl impl; + + char **outputDevices; + int outputDeviceCount; + + char **inputDevices; + int inputDeviceCount; } SDL_AudioDriver; @@ -121,7 +130,7 @@ typedef struct AudioBootStrap const char *name; const char *desc; int (*init) (SDL_AudioDriverImpl * impl); - int demand_only:1; /* 1==request explicitly, or it won't be available. */ + int demand_only; /* 1==request explicitly, or it won't be available. */ } AudioBootStrap; #endif /* _SDL_sysaudio_h */ diff --git a/project/jni/sdl-1.3/src/audio/SDL_wave.c b/project/jni/sdl-1.3/src/audio/SDL_wave.c index d770e6ff4..9918eb400 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_wave.c +++ b/project/jni/sdl-1.3/src/audio/SDL_wave.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/SDL_wave.h b/project/jni/sdl-1.3/src/audio/SDL_wave.h index 3c1f12343..7775a29a5 100644 --- a/project/jni/sdl-1.3/src/audio/SDL_wave.h +++ b/project/jni/sdl-1.3/src/audio/SDL_wave.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is SDL_free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/alsa/SDL_alsa_audio.c b/project/jni/sdl-1.3/src/audio/alsa/SDL_alsa_audio.c index f98290502..f3e4b0a23 100644 --- a/project/jni/sdl-1.3/src/audio/alsa/SDL_alsa_audio.c +++ b/project/jni/sdl-1.3/src/audio/alsa/SDL_alsa_audio.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_ALSA + /* Allow access to a raw mixing buffer */ #include @@ -38,9 +39,6 @@ #include "SDL_loadso.h" #endif -/* The tag name used by ALSA audio */ -#define DRIVER_NAME "alsa" - static int (*ALSA_snd_pcm_open) (snd_pcm_t **, const char *, snd_pcm_stream_t, int); static int (*ALSA_snd_pcm_close) (snd_pcm_t * pcm); @@ -85,11 +83,12 @@ static int (*ALSA_snd_pcm_sw_params_set_start_threshold) static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *); static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int); static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int); -#define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof -#define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof - +static int (*ALSA_snd_pcm_sw_params_set_avail_min) + (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC +#define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof +#define snd_pcm_sw_params_sizeof ALSA_snd_pcm_sw_params_sizeof static const char *alsa_library = SDL_AUDIO_DRIVER_ALSA_DYNAMIC; static void *alsa_handle = NULL; @@ -144,6 +143,7 @@ load_alsa_syms(void) SDL_ALSA_SYM(snd_pcm_sw_params); SDL_ALSA_SYM(snd_pcm_nonblock); SDL_ALSA_SYM(snd_pcm_wait); + SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min); return 0; } @@ -622,6 +622,13 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture) ALSA_snd_strerror(status)); return 0; } + status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, this->spec.samples); + if (status < 0) { + ALSA_CloseDevice(this); + SDL_SetError("Couldn't set minimum available samples: %s", + ALSA_snd_strerror(status)); + return 0; + } status = ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1); if (status < 0) { @@ -685,7 +692,9 @@ ALSA_Init(SDL_AudioDriverImpl * impl) AudioBootStrap ALSA_bootstrap = { - DRIVER_NAME, "ALSA PCM audio", ALSA_Init, 0 + "alsa", "ALSA PCM audio", ALSA_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_ALSA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/alsa/SDL_alsa_audio.h b/project/jni/sdl-1.3/src/audio/alsa/SDL_alsa_audio.h index d50e3f76a..f28d0697a 100644 --- a/project/jni/sdl-1.3/src/audio/alsa/SDL_alsa_audio.h +++ b/project/jni/sdl-1.3/src/audio/alsa/SDL_alsa_audio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/arts/SDL_artsaudio.c b/project/jni/sdl-1.3/src/audio/arts/SDL_artsaudio.c index fa8788a8a..57c29c56b 100644 --- a/project/jni/sdl-1.3/src/audio/arts/SDL_artsaudio.c +++ b/project/jni/sdl-1.3/src/audio/arts/SDL_artsaudio.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_ARTS + /* Allow access to a raw mixing buffer */ #ifdef HAVE_SIGNAL_H @@ -42,9 +43,6 @@ #define SDL_NAME(X) X #endif -/* The tag name used by artsc audio */ -#define ARTS_DRIVER_NAME "arts" - #ifdef SDL_AUDIO_DRIVER_ARTS_DYNAMIC static const char *arts_library = SDL_AUDIO_DRIVER_ARTS_DYNAMIC; @@ -373,7 +371,9 @@ ARTS_Init(SDL_AudioDriverImpl * impl) AudioBootStrap ARTS_bootstrap = { - ARTS_DRIVER_NAME, "Analog RealTime Synthesizer", ARTS_Init, 0 + "arts", "Analog RealTime Synthesizer", ARTS_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_ARTS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/arts/SDL_artsaudio.h b/project/jni/sdl-1.3/src/audio/arts/SDL_artsaudio.h index ae46dc6cf..15cf3d904 100644 --- a/project/jni/sdl-1.3/src/audio/arts/SDL_artsaudio.h +++ b/project/jni/sdl-1.3/src/audio/arts/SDL_artsaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/baudio/SDL_beaudio.cc b/project/jni/sdl-1.3/src/audio/baudio/SDL_beaudio.cc index 2f04f8d4d..310cb53bc 100644 --- a/project/jni/sdl-1.3/src/audio/baudio/SDL_beaudio.cc +++ b/project/jni/sdl-1.3/src/audio/baudio/SDL_beaudio.cc @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_BEOSAUDIO + /* Allow access to the audio stream on BeOS */ #include @@ -215,4 +216,6 @@ AudioBootStrap BEOSAUDIO_bootstrap = { "baudio", "BeOS BSoundPlayer", BEOSAUDIO_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_BEOSAUDIO */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/baudio/SDL_beaudio.h b/project/jni/sdl-1.3/src/audio/baudio/SDL_beaudio.h index f009ca1ee..509b23ac3 100644 --- a/project/jni/sdl-1.3/src/audio/baudio/SDL_beaudio.h +++ b/project/jni/sdl-1.3/src/audio/baudio/SDL_beaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/bsd/SDL_bsdaudio.c b/project/jni/sdl-1.3/src/audio/bsd/SDL_bsdaudio.c index 5d5db8a19..8d1b0895d 100644 --- a/project/jni/sdl-1.3/src/audio/bsd/SDL_bsdaudio.c +++ b/project/jni/sdl-1.3/src/audio/bsd/SDL_bsdaudio.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_BSD + /* * Driver for native OpenBSD/NetBSD audio(4). * vedge@vedge.com.ar. @@ -42,100 +43,17 @@ #include "../SDL_audiodev_c.h" #include "SDL_bsdaudio.h" -/* The tag name used by NetBSD/OpenBSD audio */ -#ifdef __NetBSD__ -#define BSD_AUDIO_DRIVER_NAME "netbsd" -#define BSD_AUDIO_DRIVER_DESC "Native NetBSD audio" -#else -#define BSD_AUDIO_DRIVER_NAME "openbsd" -#define BSD_AUDIO_DRIVER_DESC "Native OpenBSD audio" -#endif - -/* Open the audio device for playback, and don't block if busy */ -/* #define USE_BLOCKING_WRITES */ - /* Use timer for synchronization */ /* #define USE_TIMER_SYNC */ /* #define DEBUG_AUDIO */ /* #define DEBUG_AUDIO_STREAM */ -#ifdef USE_BLOCKING_WRITES -#define OPEN_FLAGS_OUTPUT O_WRONLY -#define OPEN_FLAGS_INPUT O_RDONLY -#else -#define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK) -#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK) -#endif - -/* !!! FIXME: so much cut and paste with dsp/dma drivers... */ -static char **outputDevices = NULL; -static int outputDeviceCount = 0; -static char **inputDevices = NULL; -static int inputDeviceCount = 0; - -static inline void -free_device_list(char ***devs, int *count) -{ - SDL_FreeUnixAudioDevices(devs, count); -} - -static inline void -build_device_list(int iscapture, char ***devs, int *count) -{ - const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); - free_device_list(devs, count); - SDL_EnumUnixAudioDevices(flags, 0, NULL, devs, count); -} - -static inline void -build_device_lists(void) -{ - build_device_list(0, &outputDevices, &outputDeviceCount); - build_device_list(1, &inputDevices, &inputDeviceCount); -} - - -static inline void -free_device_lists(void) -{ - free_device_list(&outputDevices, &outputDeviceCount); - free_device_list(&inputDevices, &inputDeviceCount); -} - static void -BSDAUDIO_Deinitialize(void) +BSDAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) { - free_device_lists(); -} - - -static int -BSDAUDIO_DetectDevices(int iscapture) -{ - if (iscapture) { - build_device_list(1, &inputDevices, &inputDeviceCount); - return inputDeviceCount; - } else { - build_device_list(0, &outputDevices, &outputDeviceCount); - return outputDeviceCount; - } - - return 0; /* shouldn't ever hit this. */ -} - -static const char * -BSDAUDIO_GetDeviceName(int index, int iscapture) -{ - if ((iscapture) && (index < inputDeviceCount)) { - return inputDevices[index]; - } else if ((!iscapture) && (index < outputDeviceCount)) { - return outputDevices[index]; - } - - SDL_SetError("No such device"); - return NULL; + SDL_EnumUnixAudioDevices(iscapture, 0, NULL, addfn); } @@ -319,12 +237,11 @@ BSDAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ if (devname == NULL) { - if (((iscapture) && (inputDeviceCount == 0)) || - ((!iscapture) && (outputDeviceCount == 0))) { + devname = SDL_GetAudioDeviceName(0, iscapture); + if (devname == NULL) { SDL_SetError("No such audio device"); return 0; } - devname = ((iscapture) ? inputDevices[0] : outputDevices[0]); } /* Initialize all variables that we clean on shutdown */ @@ -435,22 +352,20 @@ BSDAUDIO_Init(SDL_AudioDriverImpl * impl) { /* Set the function pointers */ impl->DetectDevices = BSDAUDIO_DetectDevices; - impl->GetDeviceName = BSDAUDIO_GetDeviceName; impl->OpenDevice = BSDAUDIO_OpenDevice; impl->PlayDevice = BSDAUDIO_PlayDevice; impl->WaitDevice = BSDAUDIO_WaitDevice; impl->GetDeviceBuf = BSDAUDIO_GetDeviceBuf; impl->CloseDevice = BSDAUDIO_CloseDevice; - impl->Deinitialize = BSDAUDIO_Deinitialize; - - build_device_lists(); return 1; /* this audio target is available. */ } AudioBootStrap BSD_AUDIO_bootstrap = { - BSD_AUDIO_DRIVER_NAME, BSD_AUDIO_DRIVER_DESC, BSDAUDIO_Init, 0 + "bsd", "BSD audio", BSDAUDIO_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_BSD */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/bsd/SDL_bsdaudio.h b/project/jni/sdl-1.3/src/audio/bsd/SDL_bsdaudio.h index 298b2e9a9..550c8abcc 100644 --- a/project/jni/sdl-1.3/src/audio/bsd/SDL_bsdaudio.h +++ b/project/jni/sdl-1.3/src/audio/bsd/SDL_bsdaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/macosx/SDL_coreaudio.c b/project/jni/sdl-1.3/src/audio/coreaudio/SDL_coreaudio.c similarity index 71% rename from project/jni/sdl-1.3/src/audio/macosx/SDL_coreaudio.c rename to project/jni/sdl-1.3/src/audio/coreaudio/SDL_coreaudio.c index 8b56c670b..d5f6b4fef 100644 --- a/project/jni/sdl-1.3/src/audio/macosx/SDL_coreaudio.c +++ b/project/jni/sdl-1.3/src/audio/coreaudio/SDL_coreaudio.c @@ -1,33 +1,24 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" - -#include -#include -#include -#if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_5 -#include -#endif - #include "SDL_audio.h" #include "../SDL_audio_c.h" #include "../SDL_sysaudio.h" @@ -35,47 +26,61 @@ #define DEBUG_COREAUDIO 0 -typedef struct COREAUDIO_DeviceList -{ - AudioDeviceID id; - const char *name; -} COREAUDIO_DeviceList; +static void COREAUDIO_CloseDevice(_THIS); -static COREAUDIO_DeviceList *inputDevices = NULL; -static int inputDeviceCount = 0; -static COREAUDIO_DeviceList *outputDevices = NULL; -static int outputDeviceCount = 0; +#define CHECK_RESULT(msg) \ + if (result != noErr) { \ + COREAUDIO_CloseDevice(this); \ + SDL_SetError("CoreAudio error (%s): %d", msg, (int) result); \ + return 0; \ + } + +#if MACOSX_COREAUDIO +typedef void (*addDevFn)(const char *name, AudioDeviceID devId, void *data); static void -free_device_list(COREAUDIO_DeviceList ** devices, int *devCount) +addToDevList(const char *name, AudioDeviceID devId, void *data) { - if (*devices) { - int i = *devCount; - while (i--) - SDL_free((void *) (*devices)[i].name); - SDL_free(*devices); - *devices = NULL; - } - *devCount = 0; + SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data; + addfn(name); } +typedef struct +{ + const char *findname; + AudioDeviceID devId; + int found; +} FindDevIdData; static void -build_device_list(int iscapture, COREAUDIO_DeviceList ** devices, - int *devCount) +findDevId(const char *name, AudioDeviceID devId, void *_data) +{ + FindDevIdData *data = (FindDevIdData *) _data; + if (!data->found) { + if (SDL_strcmp(name, data->findname) == 0) { + data->found = 1; + data->devId = devId; + } + } +} + +static void +build_device_list(int iscapture, addDevFn addfn, void *addfndata) { - Boolean outWritable = 0; OSStatus result = noErr; UInt32 size = 0; AudioDeviceID *devs = NULL; UInt32 i = 0; UInt32 max = 0; - free_device_list(devices, devCount); - - result = AudioHardwareGetPropertyInfo(kAudioHardwarePropertyDevices, - &size, &outWritable); + AudioObjectPropertyAddress addr = { + kAudioHardwarePropertyDevices, + kAudioObjectPropertyScopeGlobal, + kAudioObjectPropertyElementMaster + }; + result = AudioObjectGetPropertyDataSize(kAudioObjectSystemObject, &addr, + 0, NULL, &size); if (result != kAudioHardwareNoError) return; @@ -83,16 +88,12 @@ build_device_list(int iscapture, COREAUDIO_DeviceList ** devices, if (devs == NULL) return; - max = size / sizeof(AudioDeviceID); - *devices = (COREAUDIO_DeviceList *) SDL_malloc(max * sizeof(**devices)); - if (*devices == NULL) - return; - - result = AudioHardwareGetProperty(kAudioHardwarePropertyDevices, - &size, devs); + result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, + 0, NULL, &size, devs); if (result != kAudioHardwareNoError) return; + max = size / sizeof (AudioDeviceID); for (i = 0; i < max; i++) { CFStringRef cfstr = NULL; char *ptr = NULL; @@ -101,9 +102,11 @@ build_device_list(int iscapture, COREAUDIO_DeviceList ** devices, int usable = 0; CFIndex len = 0; - result = AudioDeviceGetPropertyInfo(dev, 0, iscapture, - kAudioDevicePropertyStreamConfiguration, - &size, &outWritable); + addr.mScope = iscapture ? kAudioDevicePropertyScopeInput : + kAudioDevicePropertyScopeOutput; + addr.mSelector = kAudioDevicePropertyStreamConfiguration; + + result = AudioObjectGetPropertyDataSize(dev, &addr, 0, NULL, &size); if (result != noErr) continue; @@ -111,9 +114,8 @@ build_device_list(int iscapture, COREAUDIO_DeviceList ** devices, if (buflist == NULL) continue; - result = AudioDeviceGetProperty(dev, 0, iscapture, - kAudioDevicePropertyStreamConfiguration, - &size, buflist); + result = AudioObjectGetPropertyData(dev, &addr, 0, NULL, + &size, buflist); if (result == noErr) { UInt32 j; @@ -130,11 +132,9 @@ build_device_list(int iscapture, COREAUDIO_DeviceList ** devices, if (!usable) continue; - size = sizeof(CFStringRef); - result = AudioDeviceGetProperty(dev, 0, iscapture, - kAudioDevicePropertyDeviceNameCFString, - &size, &cfstr); - + addr.mSelector = kAudioObjectPropertyName; + size = sizeof (CFStringRef); + result = AudioObjectGetPropertyData(dev, &addr, 0, NULL, &size, &cfstr); if (result != kAudioHardwareNoError) continue; @@ -157,9 +157,7 @@ build_device_list(int iscapture, COREAUDIO_DeviceList ** devices, usable = (len > 0); } - if (!usable) { - SDL_free(ptr); - } else { + if (usable) { ptr[len] = '\0'; #if DEBUG_COREAUDIO @@ -167,82 +165,81 @@ build_device_list(int iscapture, COREAUDIO_DeviceList ** devices, ((iscapture) ? "capture" : "output"), (int) *devCount, ptr, (int) dev); #endif - - (*devices)[*devCount].id = dev; - (*devices)[*devCount].name = ptr; - (*devCount)++; + addfn(ptr, dev, addfndata); } + SDL_free(ptr); /* addfn() would have copied the string. */ } } -static inline void -build_device_lists(void) -{ - build_device_list(0, &outputDevices, &outputDeviceCount); - build_device_list(1, &inputDevices, &inputDeviceCount); -} - - -static inline void -free_device_lists(void) -{ - free_device_list(&outputDevices, &outputDeviceCount); - free_device_list(&inputDevices, &inputDeviceCount); -} - - -static int -find_device_id(const char *devname, int iscapture, AudioDeviceID * id) -{ - int i = ((iscapture) ? inputDeviceCount : outputDeviceCount); - COREAUDIO_DeviceList *devs = ((iscapture) ? inputDevices : outputDevices); - while (i--) { - if (SDL_strcmp(devname, devs->name) == 0) { - *id = devs->id; - return 1; - } - devs++; - } - - return 0; -} - - -static int -COREAUDIO_DetectDevices(int iscapture) -{ - if (iscapture) { - build_device_list(1, &inputDevices, &inputDeviceCount); - return inputDeviceCount; - } else { - build_device_list(0, &outputDevices, &outputDeviceCount); - return outputDeviceCount; - } - - return 0; /* shouldn't ever hit this. */ -} - - -static const char * -COREAUDIO_GetDeviceName(int index, int iscapture) -{ - if ((iscapture) && (index < inputDeviceCount)) { - return inputDevices[index].name; - } else if ((!iscapture) && (index < outputDeviceCount)) { - return outputDevices[index].name; - } - - SDL_SetError("No such device"); - return NULL; -} - - static void -COREAUDIO_Deinitialize(void) +COREAUDIO_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) { - free_device_lists(); + build_device_list(iscapture, addToDevList, addfn); } +static int +find_device_by_name(_THIS, const char *devname, int iscapture) +{ + AudioDeviceID devid = 0; + OSStatus result = noErr; + UInt32 size = 0; + UInt32 alive = 0; + pid_t pid = 0; + + AudioObjectPropertyAddress addr = { + 0, + kAudioObjectPropertyScopeGlobal, + kAudioObjectPropertyElementMaster + }; + + if (devname == NULL) { + size = sizeof (AudioDeviceID); + addr.mSelector = + ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice : + kAudioHardwarePropertyDefaultOutputDevice); + result = AudioObjectGetPropertyData(kAudioObjectSystemObject, &addr, + 0, NULL, &size, &devid); + CHECK_RESULT("AudioHardwareGetProperty (default device)"); + } else { + FindDevIdData data; + SDL_zero(data); + data.findname = devname; + build_device_list(iscapture, findDevId, &data); + if (!data.found) { + SDL_SetError("CoreAudio: No such audio device."); + return 0; + } + devid = data.devId; + } + + addr.mSelector = kAudioDevicePropertyDeviceIsAlive; + addr.mScope = iscapture ? kAudioDevicePropertyScopeInput : + kAudioDevicePropertyScopeOutput; + + size = sizeof (alive); + result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &alive); + CHECK_RESULT + ("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)"); + + if (!alive) { + SDL_SetError("CoreAudio: requested device exists, but isn't alive."); + return 0; + } + + addr.mSelector = kAudioDevicePropertyHogMode; + size = sizeof (pid); + result = AudioObjectGetPropertyData(devid, &addr, 0, NULL, &size, &pid); + + /* some devices don't support this property, so errors are fine here. */ + if ((result == noErr) && (pid != -1)) { + SDL_SetError("CoreAudio: requested device is being hogged."); + return 0; + } + + this->hidden->deviceID = devid; + return 1; +} +#endif /* The CoreAudio callback */ static OSStatus @@ -344,7 +341,11 @@ COREAUDIO_CloseDevice(_THIS) scope, bus, &callback, sizeof(callback)); + /* !!! FIXME: how does iOS free this? */ + #if MACOSX_COREAUDIO CloseComponent(this->hidden->audioUnit); + #endif + this->hidden->audioUnitOpened = 0; } SDL_free(this->hidden->buffer); @@ -354,100 +355,65 @@ COREAUDIO_CloseDevice(_THIS) } -#define CHECK_RESULT(msg) \ - if (result != noErr) { \ - COREAUDIO_CloseDevice(this); \ - SDL_SetError("CoreAudio error (%s): %d", msg, (int) result); \ - return 0; \ - } - -static int -find_device_by_name(_THIS, const char *devname, int iscapture) -{ - AudioDeviceID devid = 0; - OSStatus result = noErr; - UInt32 size = 0; - UInt32 alive = 0; - pid_t pid = 0; - - if (devname == NULL) { - size = sizeof(AudioDeviceID); - const AudioHardwarePropertyID propid = - ((iscapture) ? kAudioHardwarePropertyDefaultInputDevice : - kAudioHardwarePropertyDefaultOutputDevice); - - result = AudioHardwareGetProperty(propid, &size, &devid); - CHECK_RESULT("AudioHardwareGetProperty (default device)"); - } else { - if (!find_device_id(devname, iscapture, &devid)) { - SDL_SetError("CoreAudio: No such audio device."); - return 0; - } - } - - size = sizeof(alive); - result = AudioDeviceGetProperty(devid, 0, iscapture, - kAudioDevicePropertyDeviceIsAlive, - &size, &alive); - CHECK_RESULT - ("AudioDeviceGetProperty (kAudioDevicePropertyDeviceIsAlive)"); - - if (!alive) { - SDL_SetError("CoreAudio: requested device exists, but isn't alive."); - return 0; - } - - size = sizeof(pid); - result = AudioDeviceGetProperty(devid, 0, iscapture, - kAudioDevicePropertyHogMode, &size, &pid); - - /* some devices don't support this property, so errors are fine here. */ - if ((result == noErr) && (pid != -1)) { - SDL_SetError("CoreAudio: requested device is being hogged."); - return 0; - } - - this->hidden->deviceID = devid; - return 1; -} - - static int prepare_audiounit(_THIS, const char *devname, int iscapture, const AudioStreamBasicDescription * strdesc) { OSStatus result = noErr; AURenderCallbackStruct callback; +#if MACOSX_COREAUDIO ComponentDescription desc; Component comp = NULL; +#else + AudioComponentDescription desc; + AudioComponent comp = NULL; +#endif const AudioUnitElement output_bus = 0; const AudioUnitElement input_bus = 1; const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus); const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output : kAudioUnitScope_Input); +#if MACOSX_COREAUDIO if (!find_device_by_name(this, devname, iscapture)) { SDL_SetError("Couldn't find requested CoreAudio device"); return 0; } - - SDL_memset(&desc, '\0', sizeof(ComponentDescription)); +#endif + + SDL_zero(desc); desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; +#if MACOSX_COREAUDIO + desc.componentSubType = kAudioUnitSubType_DefaultOutput; comp = FindNextComponent(NULL, &desc); +#else + desc.componentSubType = kAudioUnitSubType_RemoteIO; /* !!! FIXME: ? */ + comp = AudioComponentFindNext(NULL, &desc); +#endif + if (comp == NULL) { SDL_SetError("Couldn't find requested CoreAudio component"); return 0; } /* Open & initialize the audio unit */ +#if MACOSX_COREAUDIO result = OpenAComponent(comp, &this->hidden->audioUnit); CHECK_RESULT("OpenAComponent"); +#else + /* + AudioComponentInstanceNew only available on iPhone OS 2.0 and Mac OS X 10.6 + We can't use OpenAComponent on iPhone because it is not present + */ + result = AudioComponentInstanceNew(comp, &this->hidden->audioUnit); + CHECK_RESULT("AudioComponentInstanceNew"); +#endif this->hidden->audioUnitOpened = 1; +#if MACOSX_COREAUDIO result = AudioUnitSetProperty(this->hidden->audioUnit, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, @@ -455,6 +421,7 @@ prepare_audiounit(_THIS, const char *devname, int iscapture, sizeof(AudioDeviceID)); CHECK_RESULT ("AudioUnitSetProperty (kAudioOutputUnitProperty_CurrentDevice)"); +#endif /* Set the data format of the audio unit. */ result = AudioUnitSetProperty(this->hidden->audioUnit, @@ -565,20 +532,22 @@ static int COREAUDIO_Init(SDL_AudioDriverImpl * impl) { /* Set the function pointers */ - impl->DetectDevices = COREAUDIO_DetectDevices; - impl->GetDeviceName = COREAUDIO_GetDeviceName; impl->OpenDevice = COREAUDIO_OpenDevice; impl->CloseDevice = COREAUDIO_CloseDevice; - impl->Deinitialize = COREAUDIO_Deinitialize; - impl->ProvidesOwnCallbackThread = 1; - build_device_lists(); /* do an initial check for devices... */ +#if MACOSX_COREAUDIO + impl->DetectDevices = COREAUDIO_DetectDevices; +#else + impl->OnlyHasDefaultOutputDevice = 1; +#endif + + impl->ProvidesOwnCallbackThread = 1; return 1; /* this audio target is available. */ } AudioBootStrap COREAUDIO_bootstrap = { - "coreaudio", "Mac OS X CoreAudio", COREAUDIO_Init, 0 + "coreaudio", "CoreAudio", COREAUDIO_Init, 0 }; /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/coreaudio/SDL_coreaudio.h b/project/jni/sdl-1.3/src/audio/coreaudio/SDL_coreaudio.h new file mode 100644 index 000000000..511e1325f --- /dev/null +++ b/project/jni/sdl-1.3/src/audio/coreaudio/SDL_coreaudio.h @@ -0,0 +1,58 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_coreaudio_h +#define _SDL_coreaudio_h + +#include "../SDL_sysaudio.h" + +#if !defined(__IPHONEOS__) +#define MACOSX_COREAUDIO 1 +#endif + +#if MACOSX_COREAUDIO +#include +#include +#if MAC_OS_X_VERSION_MAX_ALLOWED <= 1050 +#include +#endif +#endif + +#include + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +struct SDL_PrivateAudioData +{ + AudioUnit audioUnit; + int audioUnitOpened; + void *buffer; + UInt32 bufferOffset; + UInt32 bufferSize; +#if MACOSX_COREAUDIO + AudioDeviceID deviceID; +#endif +}; + +#endif /* _SDL_coreaudio_h */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/windx5/SDL_dx5audio.c b/project/jni/sdl-1.3/src/audio/directsound/SDL_directsound.c similarity index 73% rename from project/jni/sdl-1.3/src/audio/windx5/SDL_dx5audio.c rename to project/jni/sdl-1.3/src/audio/directsound/SDL_directsound.c index c583b3e63..cd5556c90 100644 --- a/project/jni/sdl-1.3/src/audio/windx5/SDL_dx5audio.c +++ b/project/jni/sdl-1.3/src/audio/directsound/SDL_directsound.c @@ -1,56 +1,55 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_DSOUND + /* Allow access to a raw mixing buffer */ #include "SDL_timer.h" +#include "SDL_loadso.h" #include "SDL_audio.h" #include "../SDL_audio_c.h" -#include "SDL_dx5audio.h" - -/* !!! FIXME: move this somewhere that other drivers can use it... */ -#if defined(_WIN32_WCE) -#define WINDOWS_OS_NAME "Windows CE/PocketPC" -#elif defined(WIN64) -#define WINDOWS_OS_NAME "Win64" -#else -#define WINDOWS_OS_NAME "Win32" -#endif +#include "SDL_directsound.h" /* DirectX function pointers for audio */ -static HINSTANCE DSoundDLL = NULL; -static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) = - NULL; +static void* DSoundDLL = NULL; +typedef HRESULT(WINAPI*fnDirectSoundCreate8)(LPGUID,LPDIRECTSOUND*,LPUNKNOWN); +typedef HRESULT(WINAPI*fnDirectSoundEnumerateW)(LPDSENUMCALLBACKW, LPVOID); +typedef HRESULT(WINAPI*fnDirectSoundCaptureEnumerateW)(LPDSENUMCALLBACKW,LPVOID); +static fnDirectSoundCreate8 pDirectSoundCreate8 = NULL; +static fnDirectSoundEnumerateW pDirectSoundEnumerateW = NULL; +static fnDirectSoundCaptureEnumerateW pDirectSoundCaptureEnumerateW = NULL; static void DSOUND_Unload(void) { - if (DSoundDLL != NULL) { - FreeLibrary(DSoundDLL); - } + pDirectSoundCreate8 = NULL; + pDirectSoundEnumerateW = NULL; + pDirectSoundCaptureEnumerateW = NULL; - DSoundCreate = NULL; - DSoundDLL = NULL; + if (DSoundDLL != NULL) { + SDL_UnloadObject(DSoundDLL); + DSoundDLL = NULL; + } } @@ -61,23 +60,23 @@ DSOUND_Load(void) DSOUND_Unload(); - DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL")); + DSoundDLL = SDL_LoadObject("DSOUND.DLL"); if (DSoundDLL == NULL) { SDL_SetError("DirectSound: failed to load DSOUND.DLL"); } else { - /* Now make sure we have DirectX 5 or better... */ - /* (DirectSoundCaptureCreate was added in DX5) */ - if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate"))) { - SDL_SetError("DirectSound: System doesn't appear to have DX5."); - } else { - DSoundCreate = (void *) GetProcAddress(DSoundDLL, - TEXT("DirectSoundCreate")); + /* Now make sure we have DirectX 8 or better... */ + #define DSOUNDLOAD(f) { \ + p##f = (fn##f) SDL_LoadFunction(DSoundDLL, #f); \ + if (!p##f) loaded = 0; \ } + loaded = 1; /* will reset if necessary. */ + DSOUNDLOAD(DirectSoundCreate8); + DSOUNDLOAD(DirectSoundEnumerateW); + DSOUNDLOAD(DirectSoundCaptureEnumerateW); + #undef DSOUNDLOAD - if (!DSoundCreate) { - SDL_SetError("DirectSound: Failed to find DirectSoundCreate"); - } else { - loaded = 1; + if (!loaded) { + SDL_SetError("DirectSound: System doesn't appear to have DX8."); } } @@ -88,6 +87,13 @@ DSOUND_Load(void) return loaded; } +static __inline__ char * +utf16_to_utf8(const WCHAR *S) +{ + /* !!! FIXME: this should be UTF-16, not UCS-2! */ + return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), + (SDL_wcslen(S)+1)*sizeof(WCHAR)); +} static void SetDSerror(const char *function, int code) @@ -98,7 +104,7 @@ SetDSerror(const char *function, int code) errbuf[0] = 0; switch (code) { case E_NOINTERFACE: - error = "Unsupported interface -- Is DirectX 5.0 or later installed?"; + error = "Unsupported interface -- Is DirectX 8.0 or later installed?"; break; case DSERR_ALLOCATED: error = "Audio device in use"; @@ -143,23 +149,32 @@ SetDSerror(const char *function, int code) return; } -/* DirectSound needs to be associated with a window */ -static HWND mainwin = NULL; -/* */ -void -DSOUND_SoundFocus(HWND hwnd) +static BOOL CALLBACK +FindAllDevs(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID data) { - /* !!! FIXME: probably broken with multi-window support in SDL 1.3 ... */ - mainwin = hwnd; + SDL_AddAudioDevice addfn = (SDL_AddAudioDevice) data; + if (guid != NULL) { /* skip default device */ + char *str = utf16_to_utf8(desc); + if (str != NULL) { + addfn(str); + SDL_free(str); /* addfn() makes a copy of this string. */ + } + } + return TRUE; /* keep enumerating. */ } static void -DSOUND_ThreadInit(_THIS) +DSOUND_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) { - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); + if (iscapture) { + pDirectSoundCaptureEnumerateW(FindAllDevs, addfn); + } else { + pDirectSoundEnumerateW(FindAllDevs, addfn); + } } + static void DSOUND_WaitDevice(_THIS) { @@ -394,6 +409,30 @@ CreateSecondary(_THIS, HWND focus, WAVEFORMATEX * wavefmt) return (numchunks); } +typedef struct FindDevGUIDData +{ + const char *devname; + GUID guid; + int found; +} FindDevGUIDData; + +static BOOL CALLBACK +FindDevGUID(LPGUID guid, LPCWSTR desc, LPCWSTR module, LPVOID _data) +{ + if (guid != NULL) { /* skip the default device. */ + FindDevGUIDData *data = (FindDevGUIDData *) _data; + char *str = utf16_to_utf8(desc); + const int match = (SDL_strcmp(str, data->devname) == 0); + SDL_free(str); + if (match) { + data->found = 1; + SDL_memcpy(&data->guid, guid, sizeof (data->guid)); + return FALSE; /* found it! stop enumerating. */ + } + } + return TRUE; /* keep enumerating. */ +} + static int DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) { @@ -401,9 +440,23 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) WAVEFORMATEX waveformat; int valid_format = 0; SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); + FindDevGUIDData devguid; + LPGUID guid = NULL; - /* !!! FIXME: handle devname */ - /* !!! FIXME: handle iscapture */ + if (devname != NULL) { + devguid.found = 0; + devguid.devname = devname; + if (iscapture) + pDirectSoundCaptureEnumerateW(FindDevGUID, &devguid); + else + pDirectSoundEnumerateW(FindDevGUID, &devguid); + + if (!devguid.found) { + SDL_SetError("DirectSound: Requested device not found"); + return 0; + } + guid = &devguid.guid; + } /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) @@ -446,7 +499,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) SDL_CalculateAudioSpec(&this->spec); /* Open the audio device */ - result = DSoundCreate(NULL, &this->hidden->sound, NULL); + result = pDirectSoundCreate8(guid, &this->hidden->sound, NULL); if (result != DS_OK) { DSOUND_CloseDevice(this); SetDSerror("DirectSoundCreate", result); @@ -454,7 +507,7 @@ DSOUND_OpenDevice(_THIS, const char *devname, int iscapture) } /* Create the audio buffer to which we write */ - this->hidden->num_buffers = CreateSecondary(this, mainwin, &waveformat); + this->hidden->num_buffers = CreateSecondary(this, NULL, &waveformat); if (this->hidden->num_buffers < 0) { DSOUND_CloseDevice(this); return 0; @@ -477,42 +530,27 @@ DSOUND_Deinitialize(void) static int DSOUND_Init(SDL_AudioDriverImpl * impl) { - OSVERSIONINFO ver; - - /* - * Unfortunately, the sound drivers on NT have higher latencies than the - * audio buffers used by many SDL applications, so there are gaps in the - * audio - it sounds terrible. Punt for now. - */ - SDL_memset(&ver, '\0', sizeof(OSVERSIONINFO)); - ver.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); - GetVersionEx(&ver); - if (ver.dwPlatformId == VER_PLATFORM_WIN32_NT) { - if (ver.dwMajorVersion <= 4) { - return 0; /* NT4.0 or earlier. Disable dsound support. */ - } - } - if (!DSOUND_Load()) { return 0; } /* Set the function pointers */ + impl->DetectDevices = DSOUND_DetectDevices; impl->OpenDevice = DSOUND_OpenDevice; impl->PlayDevice = DSOUND_PlayDevice; impl->WaitDevice = DSOUND_WaitDevice; impl->WaitDone = DSOUND_WaitDone; - impl->ThreadInit = DSOUND_ThreadInit; impl->GetDeviceBuf = DSOUND_GetDeviceBuf; impl->CloseDevice = DSOUND_CloseDevice; impl->Deinitialize = DSOUND_Deinitialize; - impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME */ return 1; /* this audio target is available. */ } AudioBootStrap DSOUND_bootstrap = { - "dsound", WINDOWS_OS_NAME "DirectSound", DSOUND_Init, 0 + "directsound", "DirectSound", DSOUND_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_DSOUND */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/directsound/SDL_directsound.h b/project/jni/sdl-1.3/src/audio/directsound/SDL_directsound.h new file mode 100644 index 000000000..29e6504c5 --- /dev/null +++ b/project/jni/sdl-1.3/src/audio/directsound/SDL_directsound.h @@ -0,0 +1,46 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_directsound_h +#define _SDL_directsound_h + +#include "directx.h" + +#include "../SDL_sysaudio.h" + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +/* The DirectSound objects */ +struct SDL_PrivateAudioData +{ + LPDIRECTSOUND sound; + LPDIRECTSOUNDBUFFER mixbuf; + int num_buffers; + int mixlen; + DWORD lastchunk; + Uint8 *locked_buf; +}; + +#endif /* _SDL_directsound_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/windx5/directx.h b/project/jni/sdl-1.3/src/audio/directsound/directx.h similarity index 91% rename from project/jni/sdl-1.3/src/audio/windx5/directx.h rename to project/jni/sdl-1.3/src/audio/directsound/directx.h index c283f6bc4..8ddfa00cb 100644 --- a/project/jni/sdl-1.3/src/audio/windx5/directx.h +++ b/project/jni/sdl-1.3/src/audio/directsound/directx.h @@ -2,10 +2,9 @@ #ifndef _directx_h #define _directx_h -/* Include all of the DirectX 5.0 headers and adds any necessary tweaks */ +/* Include all of the DirectX 8.0 headers and adds any necessary tweaks */ -#define WIN32_LEAN_AND_MEAN -#include +#include "../../core/windows/SDL_windows.h" #include #ifndef WIN32 #define WIN32 @@ -71,7 +70,7 @@ */ /* We need these defines to mark what version of DirectX API we use */ #define DIRECTDRAW_VERSION 0x0700 -#define DIRECTSOUND_VERSION 0x0500 +#define DIRECTSOUND_VERSION 0x0800 #define DIRECTINPUT_VERSION 0x0500 #include diff --git a/project/jni/sdl-1.3/src/audio/disk/SDL_diskaudio.c b/project/jni/sdl-1.3/src/audio/disk/SDL_diskaudio.c index 4fa89a893..4e68a3951 100644 --- a/project/jni/sdl-1.3/src/audio/disk/SDL_diskaudio.c +++ b/project/jni/sdl-1.3/src/audio/disk/SDL_diskaudio.c @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - This file written by Ryan C. Gordon (icculus@icculus.org) + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_DISK + /* Output raw audio data to a file. */ #if HAVE_STDIO_H @@ -36,9 +35,6 @@ #include "../SDL_audio_c.h" #include "SDL_diskaudio.h" -/* The tag name used by DISK audio */ -#define DISKAUD_DRIVER_NAME "disk" - /* environment variables and defaults. */ #define DISKENVR_OUTFILE "SDL_DISKAUDIOFILE" #define DISKDEFAULT_OUTFILE "sdlaudio.raw" @@ -162,7 +158,9 @@ DISKAUD_Init(SDL_AudioDriverImpl * impl) } AudioBootStrap DISKAUD_bootstrap = { - DISKAUD_DRIVER_NAME, "direct-to-disk audio", DISKAUD_Init, 1 + "disk", "direct-to-disk audio", DISKAUD_Init, 1 }; +#endif /* SDL_AUDIO_DRIVER_DISK */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/disk/SDL_diskaudio.h b/project/jni/sdl-1.3/src/audio/disk/SDL_diskaudio.h index 9d0902a49..5a83168e1 100644 --- a/project/jni/sdl-1.3/src/audio/disk/SDL_diskaudio.h +++ b/project/jni/sdl-1.3/src/audio/disk/SDL_diskaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/dma/SDL_dmaaudio.c b/project/jni/sdl-1.3/src/audio/dma/SDL_dmaaudio.c deleted file mode 100644 index bd2008918..000000000 --- a/project/jni/sdl-1.3/src/audio/dma/SDL_dmaaudio.c +++ /dev/null @@ -1,535 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* !!! FIXME: merge this driver with "dsp". */ - -/* Allow access to a raw mixing buffer */ - -#include -#include /* For strerror() */ -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if SDL_AUDIO_DRIVER_OSS_SOUNDCARD_H -/* This is installed on some systems */ -#include -#else -/* This is recommended by OSS */ -#include -#endif - -#ifndef MAP_FAILED -#define MAP_FAILED ((Uint8 *)-1) -#endif - -#include "SDL_timer.h" -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "../SDL_audiodev_c.h" -#include "SDL_dmaaudio.h" - -/* The tag name used by DMA audio */ -#define DMA_DRIVER_NAME "dma" - -/* Open the audio device for playback, and don't block if busy */ -#define OPEN_FLAGS_INPUT (O_RDWR|O_NONBLOCK) -#define OPEN_FLAGS_OUTPUT (O_RDWR|O_NONBLOCK) - -static char **outputDevices = NULL; -static int outputDeviceCount = 0; -static char **inputDevices = NULL; -static int inputDeviceCount = 0; - -static int -test_for_mmap(int fd) -{ - int caps = 0; - struct audio_buf_info info; - if ((ioctl(fd, SNDCTL_DSP_GETCAPS, &caps) == 0) && - (caps & DSP_CAP_TRIGGER) && (caps & DSP_CAP_MMAP) && - (ioctl(fd, SNDCTL_DSP_GETOSPACE, &info) == 0)) { - size_t len = info.fragstotal * info.fragsize; - Uint8 *buf = (Uint8 *) mmap(NULL, len, PROT_WRITE, MAP_SHARED, fd, 0); - if (buf != MAP_FAILED) { - munmap(buf, len); - return 1; - } - } - return 0; -} - - -static inline void -free_device_list(char ***devs, int *count) -{ - SDL_FreeUnixAudioDevices(devs, count); -} - -static inline void -build_device_list(int iscapture, char ***devs, int *count) -{ - const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); - free_device_list(devs, count); - SDL_EnumUnixAudioDevices(flags, 0, test_for_mmap, devs, count); -} - -static inline void -build_device_lists(void) -{ - build_device_list(0, &outputDevices, &outputDeviceCount); - build_device_list(1, &inputDevices, &inputDeviceCount); -} - - -static inline void -free_device_lists(void) -{ - free_device_list(&outputDevices, &outputDeviceCount); - free_device_list(&inputDevices, &inputDeviceCount); -} - - -static void -DMA_Deinitialize(void) -{ - free_device_lists(); -} - -static int -DMA_DetectDevices(int iscapture) -{ - if (iscapture) { - build_device_list(1, &inputDevices, &inputDeviceCount); - return inputDeviceCount; - } else { - build_device_list(0, &outputDevices, &outputDeviceCount); - return outputDeviceCount; - } - - return 0; /* shouldn't ever hit this. */ -} - - -static const char * -DMA_GetDeviceName(int index, int iscapture) -{ - if ((iscapture) && (index < inputDeviceCount)) { - return inputDevices[index]; - } else if ((!iscapture) && (index < outputDeviceCount)) { - return outputDevices[index]; - } - - SDL_SetError("No such device"); - return NULL; -} - - -static int -DMA_ReopenAudio(_THIS, const char *audiodev, int format, int stereo) -{ - int frag_spec; - int value; - - /* Close and then reopen the audio device */ - close(audio_fd); - audio_fd = open(audiodev, O_RDWR, 0); - if (audio_fd < 0) { - SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); - return (-1); - } - - /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec(&this->spec); - - /* Determine the power of two of the fragment size */ - for (frag_spec = 0; (0x01 << frag_spec) < this->spec.size; ++frag_spec); - if ((0x01 << frag_spec) != this->spec.size) { - SDL_SetError("Fragment size must be a power of two"); - return (-1); - } - - /* Set the audio buffering parameters */ - if (ioctl(audio_fd, SNDCTL_DSP_SETFRAGMENT, &frag_spec) < 0) { - SDL_SetError("Couldn't set audio fragment spec"); - return (-1); - } - - /* Set the audio format */ - value = format; - if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) { - SDL_SetError("Couldn't set audio format"); - return (-1); - } - - /* Set mono or stereo audio */ - value = (this->spec.channels > 1); - if ((ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo) < 0) || - (value != stereo)) { - SDL_SetError("Couldn't set audio channels"); - return (-1); - } - - /* Set the DSP frequency */ - value = this->spec.freq; - if (ioctl(audio_fd, SNDCTL_DSP_SPEED, &value) < 0) { - SDL_SetError("Couldn't set audio frequency"); - return (-1); - } - this->spec.freq = value; - - /* We successfully re-opened the audio */ - return (0); -} - - -static void -DMA_CloseDevice(_THIS) -{ - if (this->hidden != NULL) { - if (dma_buf != NULL) { - munmap(dma_buf, dma_len); - dma_buf = NULL; - } - if (audio_fd >= 0) { - close(audio_fd); - audio_fd = -1; - } - SDL_free(this->hidden); - this->hidden = NULL; - } -} - - -static int -DMA_OpenDevice(_THIS, const char *devname, int iscapture) -{ - const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); - int format; - int stereo; - int value; - SDL_AudioFormat test_format; - struct audio_buf_info info; - - /* We don't care what the devname is...we'll try to open anything. */ - /* ...but default to first name in the list... */ - if (devname == NULL) { - if (((iscapture) && (inputDeviceCount == 0)) || - ((!iscapture) && (outputDeviceCount == 0))) { - SDL_SetError("No such audio device"); - return 0; - } - devname = ((iscapture) ? inputDevices[0] : outputDevices[0]); - } - - /* Initialize all variables that we clean on shutdown */ - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - if (this->hidden == NULL) { - SDL_OutOfMemory(); - return 0; - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Open the audio device */ - audio_fd = open(devname, flags, 0); - if (audio_fd < 0) { - DMA_CloseDevice(this); - SDL_SetError("Couldn't open %s: %s", devname, strerror(errno)); - return 0; - } - dma_buf = NULL; - ioctl(audio_fd, SNDCTL_DSP_RESET, 0); - - /* Get a list of supported hardware formats */ - if (ioctl(audio_fd, SNDCTL_DSP_GETFMTS, &value) < 0) { - DMA_CloseDevice(this); - SDL_SetError("Couldn't get audio format list"); - return 0; - } - - /* Try for a closest match on audio format */ - format = 0; - for (test_format = SDL_FirstAudioFormat(this->spec.format); - !format && test_format;) { -#ifdef DEBUG_AUDIO - fprintf(stderr, "Trying format 0x%4.4x\n", test_format); -#endif - switch (test_format) { - case AUDIO_U8: - if (value & AFMT_U8) { - format = AFMT_U8; - } - break; - case AUDIO_S8: - if (value & AFMT_S8) { - format = AFMT_S8; - } - break; - case AUDIO_S16LSB: - if (value & AFMT_S16_LE) { - format = AFMT_S16_LE; - } - break; - case AUDIO_S16MSB: - if (value & AFMT_S16_BE) { - format = AFMT_S16_BE; - } - break; - case AUDIO_U16LSB: - if (value & AFMT_U16_LE) { - format = AFMT_U16_LE; - } - break; - case AUDIO_U16MSB: - if (value & AFMT_U16_BE) { - format = AFMT_U16_BE; - } - break; - default: - format = 0; - break; - } - if (!format) { - test_format = SDL_NextAudioFormat(); - } - } - if (format == 0) { - DMA_CloseDevice(this); - SDL_SetError("Couldn't find any hardware audio formats"); - return 0; - } - this->spec.format = test_format; - - /* Set the audio format */ - value = format; - if ((ioctl(audio_fd, SNDCTL_DSP_SETFMT, &value) < 0) || (value != format)) { - DMA_CloseDevice(this); - SDL_SetError("Couldn't set audio format"); - return 0; - } - - /* Set mono or stereo audio (currently only two channels supported) */ - stereo = (this->spec.channels > 1); - ioctl(audio_fd, SNDCTL_DSP_STEREO, &stereo); - if (stereo) { - this->spec.channels = 2; - } else { - this->spec.channels = 1; - } - - /* Because some drivers don't allow setting the buffer size - after setting the format, we must re-open the audio device - once we know what format and channels are supported - */ - if (DMA_ReopenAudio(this, devname, format, stereo) < 0) { - DMA_CloseDevice(this); - /* Error is set by DMA_ReopenAudio() */ - return 0; - } - - /* Memory map the audio buffer */ - if (ioctl(audio_fd, SNDCTL_DSP_GETOSPACE, &info) < 0) { - DMA_CloseDevice(this); - SDL_SetError("Couldn't get OSPACE parameters"); - return 0; - } - this->spec.size = info.fragsize; - this->spec.samples = this->spec.size / ((this->spec.format & 0xFF) / 8); - this->spec.samples /= this->spec.channels; - num_buffers = info.fragstotal; - dma_len = num_buffers * this->spec.size; - dma_buf = (Uint8 *) mmap(NULL, dma_len, PROT_WRITE, MAP_SHARED, - audio_fd, 0); - if (dma_buf == MAP_FAILED) { - DMA_CloseDevice(this); - SDL_SetError("DMA memory map failed"); - dma_buf = NULL; - return 0; - } - SDL_memset(dma_buf, this->spec.silence, dma_len); - - /* Check to see if we need to use select() workaround */ - { - char *workaround; - workaround = SDL_getenv("SDL_DSP_NOSELECT"); - if (workaround) { - frame_ticks = - (float) (this->spec.samples * 1000) / this->spec.freq; - next_frame = SDL_GetTicks() + frame_ticks; - } - } - - /* Trigger audio playback */ - value = 0; - ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value); - value = PCM_ENABLE_OUTPUT; - if (ioctl(audio_fd, SNDCTL_DSP_SETTRIGGER, &value) < 0) { - DMA_CloseDevice(this); - SDL_SetError("Couldn't trigger audio output"); - return 0; - } - - /* Get the parent process id (we're the parent of the audio thread) */ - parent = getpid(); - - /* We're ready to rock and roll. :-) */ - return 1; -} - - -/* This function waits until it is possible to write a full sound buffer */ -static void -DMA_WaitDevice(_THIS) -{ - fd_set fdset; - - /* Check to see if the thread-parent process is still alive */ - { - static int cnt = 0; - /* Note that this only works with thread implementations - that use a different process id for each thread. - */ - if (parent && (((++cnt) % 10) == 0)) { /* Check every 10 loops */ - if (kill(parent, 0) < 0 && errno == ESRCH) { - this->enabled = 0; - } - } - } - - /* See if we need to use timed audio synchronization */ - if (frame_ticks) { - /* Use timer for general audio synchronization */ - Sint32 ticks; - - ticks = ((Sint32) (next_frame - SDL_GetTicks())) - FUDGE_TICKS; - if (ticks > 0) { - SDL_Delay(ticks); - } - } else { - /* Use select() for audio synchronization */ - struct timeval timeout; - FD_ZERO(&fdset); - FD_SET(audio_fd, &fdset); - timeout.tv_sec = 10; - timeout.tv_usec = 0; -#ifdef DEBUG_AUDIO - fprintf(stderr, "Waiting for audio to get ready\n"); -#endif - if (select(audio_fd + 1, NULL, &fdset, NULL, &timeout) <= 0) { - const char *message = -#ifdef AUDIO_OSPACE_HACK - "Audio timeout - buggy audio driver? (trying ospace)"; -#else - "Audio timeout - buggy audio driver? (disabled)"; -#endif - /* In general we should never print to the screen, - but in this case we have no other way of letting - the user know what happened. - */ - fprintf(stderr, "SDL: %s\n", message); -#ifdef AUDIO_OSPACE_HACK - /* We may be able to use GET_OSPACE trick */ - frame_ticks = (float) (this->spec.samples * 1000) / - this->spec.freq; - next_frame = SDL_GetTicks() + frame_ticks; -#else - this->enabled = 0; - /* Don't try to close - may hang */ - audio_fd = -1; -#ifdef DEBUG_AUDIO - fprintf(stderr, "Done disabling audio\n"); -#endif -#endif /* AUDIO_OSPACE_HACK */ - } -#ifdef DEBUG_AUDIO - fprintf(stderr, "Ready!\n"); -#endif - } -} - -static void -DMA_PlayDevice(_THIS) -{ - /* If timer synchronization is enabled, set the next write frame */ - if (frame_ticks) { - next_frame += frame_ticks; - } - return; -} - -static Uint8 * -DMA_GetDeviceBuf(_THIS) -{ - count_info info; - int playing; - int filling; - - /* Get number of blocks, looping if we're not using select() */ - do { - if (ioctl(audio_fd, SNDCTL_DSP_GETOPTR, &info) < 0) { - /* Uh oh... */ - this->enabled = 0; - return (NULL); - } - } while (frame_ticks && (info.blocks < 1)); -#ifdef DEBUG_AUDIO - if (info.blocks > 1) { - printf("Warning: audio underflow (%d frags)\n", info.blocks - 1); - } -#endif - playing = info.ptr / this->spec.size; - filling = (playing + 1) % num_buffers; - return (dma_buf + (filling * this->spec.size)); -} - - -static int -DMA_Init(SDL_AudioDriverImpl * impl) -{ - /* Set the function pointers */ - impl->DetectDevices = DMA_DetectDevices; - impl->GetDeviceName = DMA_GetDeviceName; - impl->OpenDevice = DMA_OpenDevice; - impl->WaitDevice = DMA_WaitDevice; - impl->PlayDevice = DMA_PlayDevice; - impl->GetDeviceBuf = DMA_GetDeviceBuf; - impl->CloseDevice = DMA_CloseDevice; - impl->Deinitialize = DMA_Deinitialize; - - build_device_lists(); - - return 1; /* this audio target is available. */ -} - -AudioBootStrap DMA_bootstrap = { - DMA_DRIVER_NAME, "OSS /dev/dsp DMA audio", DMA_Init, 0 -}; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/dma/SDL_dmaaudio.h b/project/jni/sdl-1.3/src/audio/dma/SDL_dmaaudio.h deleted file mode 100644 index be0e582cc..000000000 --- a/project/jni/sdl-1.3/src/audio/dma/SDL_dmaaudio.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_dmaaudio_h -#define _SDL_dmaaudio_h - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -struct SDL_PrivateAudioData -{ - /* The file descriptor for the audio device */ - int audio_fd; - - /* The parent process id, to detect when application quits */ - pid_t parent; - - /* Raw mixing buffer */ - Uint8 *dma_buf; - int dma_len; - int num_buffers; - - /* Support for audio timing using a timer, in addition to select() */ - float frame_ticks; - float next_frame; -}; -#define FUDGE_TICKS 10 /* The scheduler overhead ticks per frame */ - -/* Old variable names */ -/* !!! FIXME: remove these. */ -#define audio_fd (this->hidden->audio_fd) -#define parent (this->hidden->parent) -#define dma_buf (this->hidden->dma_buf) -#define dma_len (this->hidden->dma_len) -#define num_buffers (this->hidden->num_buffers) -#define frame_ticks (this->hidden->frame_ticks) -#define next_frame (this->hidden->next_frame) - -#endif /* _SDL_dmaaudio_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/dmedia/SDL_irixaudio.c b/project/jni/sdl-1.3/src/audio/dmedia/SDL_irixaudio.c deleted file mode 100644 index bdc9c1bb6..000000000 --- a/project/jni/sdl-1.3/src/audio/dmedia/SDL_irixaudio.c +++ /dev/null @@ -1,238 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include -#include "SDL_config.h" - -/* Allow access to a raw mixing buffer (For IRIX 6.5 and higher) */ -/* patch for IRIX 5 by Georg Schwarz 18/07/2004 */ - -#include "SDL_timer.h" -#include "SDL_audio.h" -#include "../SDL_audiomem.h" -#include "../SDL_audio_c.h" -#include "SDL_irixaudio.h" - - -#ifndef AL_RESOURCE /* as a test whether we use the old IRIX audio libraries */ -#define OLD_IRIX_AUDIO -#define alClosePort(x) ALcloseport(x) -#define alFreeConfig(x) ALfreeconfig(x) -#define alGetFillable(x) ALgetfillable(x) -#define alNewConfig() ALnewconfig() -#define alOpenPort(x,y,z) ALopenport(x,y,z) -#define alSetChannels(x,y) ALsetchannels(x,y) -#define alSetQueueSize(x,y) ALsetqueuesize(x,y) -#define alSetSampFmt(x,y) ALsetsampfmt(x,y) -#define alSetWidth(x,y) ALsetwidth(x,y) -#endif - -void static -IRIXAUDIO_WaitDevice(_THIS) -{ - Sint32 timeleft; - - timeleft = this->spec.samples - alGetFillable(this->hidden->audio_port); - if (timeleft > 0) { - timeleft /= (this->spec.freq / 1000); - SDL_Delay((Uint32) timeleft); - } -} - -static void -IRIXAUDIO_PlayDevice(_THIS) -{ - /* Write the audio data out */ - ALport port = this->hidden->audio_port; - Uint8 *mixbuf = this->hidden->mixbuf; - if (alWriteFrames(port, mixbuf, this->spec.samples) < 0) { - /* Assume fatal error, for now */ - this->enabled = 0; - } -} - -static Uint8 * -IRIXAUDIO_GetDeviceBuf(_THIS) -{ - return (this->hidden->mixbuf); -} - -static void -IRIXAUDIO_CloseDevice(_THIS) -{ - if (this->hidden != NULL) { - if (this->hidden->mixbuf != NULL) { - SDL_FreeAudioMem(this->hidden->mixbuf); - this->hidden->mixbuf = NULL; - } - if (this->hidden->audio_port != NULL) { - alClosePort(this->hidden->audio_port); - this->hidden->audio_port = NULL; - } - SDL_free(this->hidden); - this->hidden = NULL; - } -} - -static int -IRIXAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) -{ - SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); - long width = 0; - long fmt = 0; - int valid = 0; - - /* !!! FIXME: Handle multiple devices and capture? */ - - /* Initialize all variables that we clean on shutdown */ - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - if (this->hidden == NULL) { - SDL_OutOfMemory(); - return 0; - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - -#ifdef OLD_IRIX_AUDIO - { - long audio_param[2]; - audio_param[0] = AL_OUTPUT_RATE; - audio_param[1] = this->spec.freq; - valid = (ALsetparams(AL_DEFAULT_DEVICE, audio_param, 2) < 0); - } -#else - { - ALpv audio_param; - audio_param.param = AL_RATE; - audio_param.value.i = this->spec.freq; - valid = (alSetParams(AL_DEFAULT_OUTPUT, &audio_param, 1) < 0); - } -#endif - - while ((!valid) && (test_format)) { - valid = 1; - this->spec.format = test_format; - - switch (test_format) { - case AUDIO_S8: - width = AL_SAMPLE_8; - fmt = AL_SAMPFMT_TWOSCOMP; - break; - - case AUDIO_S16SYS: - width = AL_SAMPLE_16; - fmt = AL_SAMPFMT_TWOSCOMP; - break; - - case AUDIO_F32SYS: - width = 0; /* not used here... */ - fmt = AL_SAMPFMT_FLOAT; - break; - - /* Docs say there is int24, but not int32.... */ - - default: - valid = 0; - test_format = SDL_NextAudioFormat(); - break; - } - - if (valid) { - ALconfig audio_config = alNewConfig(); - valid = 0; - if (audio_config) { - if (alSetChannels(audio_config, this->spec.channels) < 0) { - if (this->spec.channels > 2) { /* can't handle > stereo? */ - this->spec.channels = 2; /* try again below. */ - } - } - - if ((alSetSampFmt(audio_config, fmt) >= 0) && - ((!width) || (alSetWidth(audio_config, width) >= 0)) && - (alSetQueueSize(audio_config, this->spec.samples * 2) >= - 0) - && (alSetChannels(audio_config, this->spec.channels) >= - 0)) { - - this->hidden->audio_port = alOpenPort("SDL audio", "w", - audio_config); - if (this->hidden->audio_port == NULL) { - /* docs say AL_BAD_CHANNELS happens here, too. */ - int err = oserror(); - if (err == AL_BAD_CHANNELS) { - this->spec.channels = 2; - alSetChannels(audio_config, this->spec.channels); - this->hidden->audio_port = - alOpenPort("SDL audio", "w", audio_config); - } - } - - if (this->hidden->audio_port != NULL) { - valid = 1; - } - } - - alFreeConfig(audio_config); - } - } - } - - if (!valid) { - IRIXAUDIO_CloseDevice(this); - SDL_SetError("Unsupported audio format"); - return 0; - } - - /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec(&this->spec); - - /* Allocate mixing buffer */ - this->hidden->mixbuf = (Uint8 *) SDL_AllocAudioMem(this->spec.size); - if (this->hidden->mixbuf == NULL) { - IRIXAUDIO_CloseDevice(this); - SDL_OutOfMemory(); - return 0; - } - SDL_memset(this->hidden->mixbuf, this->spec.silence, this->spec.size); - - /* We're ready to rock and roll. :-) */ - return 1; -} - -static int -IRIXAUDIO_Init(SDL_AudioDriverImpl * impl) -{ - /* Set the function pointers */ - impl->OpenDevice = DSP_OpenDevice; - impl->PlayDevice = DSP_PlayDevice; - impl->WaitDevice = DSP_WaitDevice; - impl->GetDeviceBuf = DSP_GetDeviceBuf; - impl->CloseDevice = DSP_CloseDevice; - impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: not true, I think. */ - - return 1; /* this audio target is available. */ -} - -AudioBootStrap IRIXAUDIO_bootstrap = { - "AL", "IRIX DMedia audio", IRIXAUDIO_Init, 0 -}; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/dmedia/SDL_irixaudio.h b/project/jni/sdl-1.3/src/audio/dmedia/SDL_irixaudio.h deleted file mode 100644 index adfb99f23..000000000 --- a/project/jni/sdl-1.3/src/audio/dmedia/SDL_irixaudio.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_irixaudio_h -#define _SDL_irixaudio_h - -#include - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -struct SDL_PrivateAudioData -{ - ALport audio_port; /* The handle for the audio device */ - Uint8 *mixbuf; /* The app mixing buffer */ -}; - -#endif /* _SDL_irixaudio_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/dsp/SDL_dspaudio.c b/project/jni/sdl-1.3/src/audio/dsp/SDL_dspaudio.c index e5440b074..5c4a76921 100644 --- a/project/jni/sdl-1.3/src/audio/dsp/SDL_dspaudio.c +++ b/project/jni/sdl-1.3/src/audio/dsp/SDL_dspaudio.c @@ -1,29 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Modified in Oct 2004 by Hannu Savolainen - hannu@opensound.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_OSS + /* Allow access to a raw mixing buffer */ #include /* For perror() */ @@ -51,80 +49,11 @@ #include "../SDL_audiodev_c.h" #include "SDL_dspaudio.h" -/* The tag name used by DSP audio */ -#define DSP_DRIVER_NAME "dsp" - -/* Open the audio device for playback, and don't block if busy */ -#define OPEN_FLAGS_OUTPUT (O_WRONLY|O_NONBLOCK) -#define OPEN_FLAGS_INPUT (O_RDONLY|O_NONBLOCK) - -static char **outputDevices = NULL; -static int outputDeviceCount = 0; -static char **inputDevices = NULL; -static int inputDeviceCount = 0; - -static inline void -free_device_list(char ***devs, int *count) -{ - SDL_FreeUnixAudioDevices(devs, count); -} - -static inline void -build_device_list(int iscapture, char ***devs, int *count) -{ - const int flags = ((iscapture) ? OPEN_FLAGS_INPUT : OPEN_FLAGS_OUTPUT); - free_device_list(devs, count); - SDL_EnumUnixAudioDevices(flags, 0, NULL, devs, count); -} - -static inline void -build_device_lists(void) -{ - build_device_list(0, &outputDevices, &outputDeviceCount); - build_device_list(1, &inputDevices, &inputDeviceCount); -} - - -static inline void -free_device_lists(void) -{ - free_device_list(&outputDevices, &outputDeviceCount); - free_device_list(&inputDevices, &inputDeviceCount); -} - static void -DSP_Deinitialize(void) +DSP_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) { - free_device_lists(); -} - - -static int -DSP_DetectDevices(int iscapture) -{ - if (iscapture) { - build_device_list(1, &inputDevices, &inputDeviceCount); - return inputDeviceCount; - } else { - build_device_list(0, &outputDevices, &outputDeviceCount); - return outputDeviceCount; - } - - return 0; /* shouldn't ever hit this. */ -} - -static const char * -DSP_GetDeviceName(int index, int iscapture) -{ - if ((iscapture) && (index < inputDeviceCount)) { - return inputDevices[index]; - } else if ((!iscapture) && (index < outputDeviceCount)) { - return outputDevices[index]; - } - - SDL_SetError("No such device"); - return NULL; + SDL_EnumUnixAudioDevices(iscapture, 0, NULL, addfn); } @@ -158,12 +87,11 @@ DSP_OpenDevice(_THIS, const char *devname, int iscapture) /* We don't care what the devname is...we'll try to open anything. */ /* ...but default to first name in the list... */ if (devname == NULL) { - if (((iscapture) && (inputDeviceCount == 0)) || - ((!iscapture) && (outputDeviceCount == 0))) { + devname = SDL_GetAudioDeviceName(0, iscapture); + if (devname == NULL) { SDL_SetError("No such audio device"); return 0; } - devname = ((iscapture) ? inputDevices[0] : outputDevices[0]); } /* Make sure fragment size stays a power of 2, or OSS fails. */ @@ -373,21 +301,19 @@ DSP_Init(SDL_AudioDriverImpl * impl) { /* Set the function pointers */ impl->DetectDevices = DSP_DetectDevices; - impl->GetDeviceName = DSP_GetDeviceName; impl->OpenDevice = DSP_OpenDevice; impl->PlayDevice = DSP_PlayDevice; impl->GetDeviceBuf = DSP_GetDeviceBuf; impl->CloseDevice = DSP_CloseDevice; - impl->Deinitialize = DSP_Deinitialize; - - build_device_lists(); return 1; /* this audio target is available. */ } AudioBootStrap DSP_bootstrap = { - DSP_DRIVER_NAME, "OSS /dev/dsp standard audio", DSP_Init, 0 + "dsp", "OSS /dev/dsp standard audio", DSP_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_OSS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/dsp/SDL_dspaudio.h b/project/jni/sdl-1.3/src/audio/dsp/SDL_dspaudio.h index c9495e6ce..223e5686f 100644 --- a/project/jni/sdl-1.3/src/audio/dsp/SDL_dspaudio.h +++ b/project/jni/sdl-1.3/src/audio/dsp/SDL_dspaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/dummy/SDL_dummyaudio.c b/project/jni/sdl-1.3/src/audio/dummy/SDL_dummyaudio.c index 749818cc4..5ee014b22 100644 --- a/project/jni/sdl-1.3/src/audio/dummy/SDL_dummyaudio.c +++ b/project/jni/sdl-1.3/src/audio/dummy/SDL_dummyaudio.c @@ -1,25 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - This file written by Ryan C. Gordon (icculus@icculus.org) + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/dummy/SDL_dummyaudio.h b/project/jni/sdl-1.3/src/audio/dummy/SDL_dummyaudio.h index 2d438be2b..49ea253b5 100644 --- a/project/jni/sdl-1.3/src/audio/dummy/SDL_dummyaudio.h +++ b/project/jni/sdl-1.3/src/audio/dummy/SDL_dummyaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/esd/SDL_esdaudio.c b/project/jni/sdl-1.3/src/audio/esd/SDL_esdaudio.c index 25287170a..03ae3278a 100644 --- a/project/jni/sdl-1.3/src/audio/esd/SDL_esdaudio.c +++ b/project/jni/sdl-1.3/src/audio/esd/SDL_esdaudio.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_ESD + /* Allow access to an ESD network stream mixing buffer */ #include @@ -42,9 +43,6 @@ #define SDL_NAME(X) X #endif -/* The tag name used by ESD audio */ -#define ESD_DRIVER_NAME "esd" - #ifdef SDL_AUDIO_DRIVER_ESD_DYNAMIC static const char *esd_library = SDL_AUDIO_DRIVER_ESD_DYNAMIC; @@ -346,7 +344,9 @@ ESD_Init(SDL_AudioDriverImpl * impl) AudioBootStrap ESD_bootstrap = { - ESD_DRIVER_NAME, "Enlightened Sound Daemon", ESD_Init, 0 + "esd", "Enlightened Sound Daemon", ESD_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_ESD */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/esd/SDL_esdaudio.h b/project/jni/sdl-1.3/src/audio/esd/SDL_esdaudio.h index 8794ba376..47ad8a399 100644 --- a/project/jni/sdl-1.3/src/audio/esd/SDL_esdaudio.h +++ b/project/jni/sdl-1.3/src/audio/esd/SDL_esdaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/fusionsound/SDL_fsaudio.c b/project/jni/sdl-1.3/src/audio/fusionsound/SDL_fsaudio.c index a0341d595..05bd1754e 100644 --- a/project/jni/sdl-1.3/src/audio/fusionsound/SDL_fsaudio.c +++ b/project/jni/sdl-1.3/src/audio/fusionsound/SDL_fsaudio.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_FUSIONSOUND + /* Allow access to a raw mixing buffer */ #ifdef HAVE_SIGNAL_H @@ -49,8 +50,6 @@ typedef DFBResult DirectResult; #endif -/* The tag name used by fusionsoundc audio */ -#define SDL_FS_DRIVER_NAME "fusionsound" /* Buffers to use - more than 2 gives a lot of latency */ #define FUSION_BUFFERS (2) @@ -345,7 +344,9 @@ SDL_FS_Init(SDL_AudioDriverImpl * impl) AudioBootStrap FUSIONSOUND_bootstrap = { - SDL_FS_DRIVER_NAME, "FusionSound", SDL_FS_Init, 0 + "fusionsound", "FusionSound", SDL_FS_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_FUSIONSOUND */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/fusionsound/SDL_fsaudio.h b/project/jni/sdl-1.3/src/audio/fusionsound/SDL_fsaudio.h index 1186071d2..7be96de5a 100644 --- a/project/jni/sdl-1.3/src/audio/fusionsound/SDL_fsaudio.h +++ b/project/jni/sdl-1.3/src/audio/fusionsound/SDL_fsaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/iphoneos/SDL_coreaudio_iphone.c b/project/jni/sdl-1.3/src/audio/iphoneos/SDL_coreaudio_iphone.c deleted file mode 100644 index b8a32d4d9..000000000 --- a/project/jni/sdl-1.3/src/audio/iphoneos/SDL_coreaudio_iphone.c +++ /dev/null @@ -1,340 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "../SDL_sysaudio.h" -#include "SDL_coreaudio_iphone.h" - -#define DEBUG_COREAUDIO 0 - -static void -COREAUDIO_Deinitialize(void) -{ -} - -/* The CoreAudio callback */ -static OSStatus -outputCallback(void *inRefCon, - AudioUnitRenderActionFlags * ioActionFlags, - const AudioTimeStamp * inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, - AudioBufferList * ioDataList) -{ - SDL_AudioDevice *this = (SDL_AudioDevice *) inRefCon; - AudioBuffer *ioData = &ioDataList->mBuffers[0]; - UInt32 remaining, len; - void *ptr; - - /* Is there ever more than one buffer, and what do you do with it? */ - if (ioDataList->mNumberBuffers != 1) { - return noErr; - } - - /* Only do anything if audio is enabled and not paused */ - if (!this->enabled || this->paused) { - SDL_memset(ioData->mData, this->spec.silence, ioData->mDataByteSize); - return 0; - } - - /* No SDL conversion should be needed here, ever, since we accept - any input format in OpenAudio, and leave the conversion to CoreAudio. - */ - /* - assert(!this->convert.needed); - assert(this->spec.channels == ioData->mNumberChannels); - */ - - remaining = ioData->mDataByteSize; - ptr = ioData->mData; - while (remaining > 0) { - if (this->hidden->bufferOffset >= this->hidden->bufferSize) { - /* Generate the data */ - SDL_memset(this->hidden->buffer, this->spec.silence, - this->hidden->bufferSize); - SDL_mutexP(this->mixer_lock); - (*this->spec.callback) (this->spec.userdata, this->hidden->buffer, - this->hidden->bufferSize); - SDL_mutexV(this->mixer_lock); - this->hidden->bufferOffset = 0; - } - - len = this->hidden->bufferSize - this->hidden->bufferOffset; - if (len > remaining) - len = remaining; - SDL_memcpy(ptr, - (char *) this->hidden->buffer + this->hidden->bufferOffset, - len); - ptr = (char *) ptr + len; - remaining -= len; - this->hidden->bufferOffset += len; - } - - return 0; -} - -static OSStatus -inputCallback(void *inRefCon, - AudioUnitRenderActionFlags * ioActionFlags, - const AudioTimeStamp * inTimeStamp, - UInt32 inBusNumber, UInt32 inNumberFrames, - AudioBufferList * ioData) -{ - //err = AudioUnitRender(afr->fAudioUnit, ioActionFlags, inTimeStamp, inBusNumber, inNumberFrames, afr->fAudioBuffer); - // !!! FIXME: write me! - return noErr; -} - - -static void -COREAUDIO_CloseDevice(_THIS) -{ - if (this->hidden != NULL) { - if (this->hidden->audioUnitOpened) { - OSStatus result = noErr; - AURenderCallbackStruct callback; - const AudioUnitElement output_bus = 0; - const AudioUnitElement input_bus = 1; - const int iscapture = this->iscapture; - const AudioUnitElement bus = - ((iscapture) ? input_bus : output_bus); - const AudioUnitScope scope = - ((iscapture) ? kAudioUnitScope_Output : - kAudioUnitScope_Input); - - /* stop processing the audio unit */ - result = AudioOutputUnitStop(this->hidden->audioUnit); - - /* Remove the input callback */ - SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct)); - result = AudioUnitSetProperty(this->hidden->audioUnit, - kAudioUnitProperty_SetRenderCallback, - scope, bus, &callback, - sizeof(callback)); - - //CloseComponent(this->hidden->audioUnit); - this->hidden->audioUnitOpened = 0; - } - SDL_free(this->hidden->buffer); - SDL_free(this->hidden); - this->hidden = NULL; - } -} - - -#define CHECK_RESULT(msg) \ - if (result != noErr) { \ - COREAUDIO_CloseDevice(this); \ - SDL_SetError("CoreAudio error (%s): %d", msg, result); \ - return 0; \ - } - -static int -prepare_audiounit(_THIS, const char *devname, int iscapture, - const AudioStreamBasicDescription * strdesc) -{ - OSStatus result = noErr; - AURenderCallbackStruct callback; - AudioComponentDescription desc; - AudioComponent comp = NULL; - - UInt32 enableIO = 0; - const AudioUnitElement output_bus = 0; - const AudioUnitElement input_bus = 1; - const AudioUnitElement bus = ((iscapture) ? input_bus : output_bus); - const AudioUnitScope scope = ((iscapture) ? kAudioUnitScope_Output : - kAudioUnitScope_Input); - - SDL_memset(&desc, '\0', sizeof(AudioComponentDescription)); - desc.componentType = kAudioUnitType_Output; - desc.componentSubType = kAudioUnitSubType_RemoteIO; - desc.componentManufacturer = kAudioUnitManufacturer_Apple; - - comp = AudioComponentFindNext(NULL, &desc); - if (comp == NULL) { - SDL_SetError("Couldn't find requested CoreAudio component"); - return 0; - } - - /* Open & initialize the audio unit */ - /* - AudioComponentInstanceNew only available on iPhone OS 2.0 and Mac OS X 10.6 - We can't use OpenAComponent on iPhone because it is not present - */ - result = AudioComponentInstanceNew(comp, &this->hidden->audioUnit); - CHECK_RESULT("AudioComponentInstanceNew"); - - this->hidden->audioUnitOpened = 1; - - // !!! FIXME: this is wrong? - enableIO = ((iscapture) ? 1 : 0); - result = AudioUnitSetProperty(this->hidden->audioUnit, - kAudioOutputUnitProperty_EnableIO, - kAudioUnitScope_Input, input_bus, - &enableIO, sizeof(enableIO)); - CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_EnableIO input)"); - - // !!! FIXME: this is wrong? - enableIO = ((iscapture) ? 0 : 1); - result = AudioUnitSetProperty(this->hidden->audioUnit, - kAudioOutputUnitProperty_EnableIO, - kAudioUnitScope_Output, output_bus, - &enableIO, sizeof(enableIO)); - CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_EnableIO output)"); - - /*result = AudioUnitSetProperty(this->hidden->audioUnit, - kAudioOutputUnitProperty_CurrentDevice, - kAudioUnitScope_Global, 0, - &this->hidden->deviceID, - sizeof(AudioDeviceID)); - - CHECK_RESULT("AudioUnitSetProperty (kAudioOutputUnitProperty_CurrentDevice)"); */ - - /* Set the data format of the audio unit. */ - result = AudioUnitSetProperty(this->hidden->audioUnit, - kAudioUnitProperty_StreamFormat, - scope, bus, strdesc, sizeof(*strdesc)); - CHECK_RESULT("AudioUnitSetProperty (kAudioUnitProperty_StreamFormat)"); - - /* Set the audio callback */ - SDL_memset(&callback, '\0', sizeof(AURenderCallbackStruct)); - callback.inputProc = ((iscapture) ? inputCallback : outputCallback); - callback.inputProcRefCon = this; - result = AudioUnitSetProperty(this->hidden->audioUnit, - kAudioUnitProperty_SetRenderCallback, - scope, bus, &callback, sizeof(callback)); - CHECK_RESULT - ("AudioUnitSetProperty (kAudioUnitProperty_SetInputCallback)"); - - /* Calculate the final parameters for this audio specification */ - SDL_CalculateAudioSpec(&this->spec); - - /* Allocate a sample buffer */ - this->hidden->bufferOffset = this->hidden->bufferSize = this->spec.size; - this->hidden->buffer = SDL_malloc(this->hidden->bufferSize); - - result = AudioUnitInitialize(this->hidden->audioUnit); - CHECK_RESULT("AudioUnitInitialize"); - - /* Finally, start processing of the audio unit */ - result = AudioOutputUnitStart(this->hidden->audioUnit); - CHECK_RESULT("AudioOutputUnitStart"); - /* We're running! */ - return 1; -} - -static int -COREAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) -{ - AudioStreamBasicDescription strdesc; - SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); - int valid_datatype = 0; - - /* Initialize all variables that we clean on shutdown */ - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - if (this->hidden == NULL) { - SDL_OutOfMemory(); - return (0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Setup a AudioStreamBasicDescription with the requested format */ - SDL_memset(&strdesc, '\0', sizeof(AudioStreamBasicDescription)); - strdesc.mFormatID = kAudioFormatLinearPCM; - strdesc.mFormatFlags = kLinearPCMFormatFlagIsPacked; - strdesc.mChannelsPerFrame = this->spec.channels; - strdesc.mSampleRate = this->spec.freq; - strdesc.mFramesPerPacket = 1; - - while ((!valid_datatype) && (test_format)) { - this->spec.format = test_format; - /* Just a list of valid SDL formats, so people don't pass junk here. */ - switch (test_format) { - case AUDIO_U8: - case AUDIO_S8: - case AUDIO_U16LSB: - case AUDIO_S16LSB: - case AUDIO_U16MSB: - case AUDIO_S16MSB: - case AUDIO_S32LSB: - case AUDIO_S32MSB: - case AUDIO_F32LSB: - case AUDIO_F32MSB: - valid_datatype = 1; - strdesc.mBitsPerChannel = SDL_AUDIO_BITSIZE(this->spec.format); - if (SDL_AUDIO_ISBIGENDIAN(this->spec.format)) - strdesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian; - - if (SDL_AUDIO_ISFLOAT(this->spec.format)) - strdesc.mFormatFlags |= kLinearPCMFormatFlagIsFloat; - else if (SDL_AUDIO_ISSIGNED(this->spec.format)) - strdesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; - break; - } - } - - if (!valid_datatype) { /* shouldn't happen, but just in case... */ - COREAUDIO_CloseDevice(this); - SDL_SetError("Unsupported audio format"); - return 0; - } - - strdesc.mBytesPerFrame = - strdesc.mBitsPerChannel * strdesc.mChannelsPerFrame / 8; - strdesc.mBytesPerPacket = - strdesc.mBytesPerFrame * strdesc.mFramesPerPacket; - - if (!prepare_audiounit(this, devname, iscapture, &strdesc)) { - COREAUDIO_CloseDevice(this); - return 0; /* prepare_audiounit() will call SDL_SetError()... */ - } - - return 1; /* good to go. */ -} - -static int -COREAUDIO_Init(SDL_AudioDriverImpl * impl) -{ - /* Set the function pointers */ - impl->OpenDevice = COREAUDIO_OpenDevice; - impl->CloseDevice = COREAUDIO_CloseDevice; - impl->Deinitialize = COREAUDIO_Deinitialize; - impl->ProvidesOwnCallbackThread = 1; - - /* added for iPhone */ - impl->OnlyHasDefaultInputDevice = 1; - impl->OnlyHasDefaultOutputDevice = 1; - impl->HasCaptureSupport = 0; /* still needs to be written */ - - return 1; /* this audio target is available. */ -} - -AudioBootStrap COREAUDIOIPHONE_bootstrap = { - "coreaudio-iphoneos", "SDL CoreAudio (iPhone OS) audio driver", - COREAUDIO_Init, 0 -}; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/iphoneos/SDL_coreaudio_iphone.h b/project/jni/sdl-1.3/src/audio/iphoneos/SDL_coreaudio_iphone.h deleted file mode 100644 index 5b935ff98..000000000 --- a/project/jni/sdl-1.3/src/audio/iphoneos/SDL_coreaudio_iphone.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_coreaudio_h -#define _SDL_coreaudio_h - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -struct SDL_PrivateAudioData -{ - AudioUnit audioUnit; - int audioUnitOpened; - void *buffer; - UInt32 bufferOffset; - UInt32 bufferSize; - // AudioDeviceID deviceID; -}; - -#endif /* _SDL_coreaudio_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/macosx/SDL_coreaudio.h b/project/jni/sdl-1.3/src/audio/macosx/SDL_coreaudio.h deleted file mode 100644 index fe3743815..000000000 --- a/project/jni/sdl-1.3/src/audio/macosx/SDL_coreaudio.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_coreaudio_h -#define _SDL_coreaudio_h - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -struct SDL_PrivateAudioData -{ - AudioUnit audioUnit; - int audioUnitOpened; - void *buffer; - UInt32 bufferOffset; - UInt32 bufferSize; - AudioDeviceID deviceID; -}; - -#endif /* _SDL_coreaudio_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/mme/SDL_mmeaudio.c b/project/jni/sdl-1.3/src/audio/mme/SDL_mmeaudio.c deleted file mode 100644 index 9eb55d8dc..000000000 --- a/project/jni/sdl-1.3/src/audio/mme/SDL_mmeaudio.c +++ /dev/null @@ -1,260 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Tru64 UNIX MME support */ -#include - -#include "SDL_timer.h" -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "SDL_mmeaudio.h" - -static BOOL inUse[NUM_BUFFERS]; - -static void -SetMMerror(char *function, MMRESULT code) -{ - int len; - char errbuf[MAXERRORLENGTH]; - - SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); - len = SDL_strlen(errbuf); - waveOutGetErrorText(code, errbuf + len, MAXERRORLENGTH - len); - SDL_SetError("%s", errbuf); -} - -static void CALLBACK -MME_Callback(HWAVEOUT hwo, - UINT uMsg, DWORD dwInstance, LPARAM dwParam1, LPARAM dwParam2) -{ - WAVEHDR *wp = (WAVEHDR *) dwParam1; - - if (uMsg == WOM_DONE) - inUse[wp->dwUser] = FALSE; -} - -static int -MME_OpenDevice(_THIS, const char *devname, int iscapture) -{ - int valid_format = 0; - MMRESULT result; - Uint8 *mixbuf = NULL; - int i; - - /* Initialize all variables that we clean on shutdown */ - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - if (this->hidden == NULL) { - SDL_OutOfMemory(); - return 0; - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - - /* Set basic WAVE format parameters */ - this->hidden->shm = mmeAllocMem(sizeof(*this->hidden->shm)); - if (this->hidden->shm == NULL) { - MME_CloseDevice(this); - SDL_OutOfMemory(); - return 0; - } - - SDL_memset(this->hidden->shm, '\0', sizeof(*this->hidden->shm)); - this->hidden->shm->sound = 0; - this->hidden->shm->wFmt.wf.wFormatTag = WAVE_FORMAT_PCM; - - /* Determine the audio parameters from the AudioSpec */ - /* Try for a closest match on audio format */ - for (test_format = SDL_FirstAudioFormat(this->spec.format); - !valid_format && test_format;) { - valid_format = 1; - switch (test_format) { - case AUDIO_U8: - case AUDIO_S16: - case AUDIO_S32: - break; - default: - valid_format = 0; - test_format = SDL_NextAudioFormat(); - } - } - - if (!valid_format) { - MME_CloseDevice(this); - SDL_SetError("Unsupported audio format"); - return 0; - } - - this->spec.format = test_format; - this->hidden->shm->wFmt.wBitsPerSample = SDL_AUDIO_BITSIZE(test_format); - - /* !!! FIXME: Can this handle more than stereo? */ - this->hidden->shm->wFmt.wf.nChannels = this->spec.channels; - this->hidden->shm->wFmt.wf.nSamplesPerSec = this->spec.freq; - this->hidden->shm->wFmt.wf.nBlockAlign = - this->hidden->shm->wFmt.wf.nChannels * - this->hidden->shm->wFmt.wBitsPerSample / 8; - this->hidden->shm->wFmt.wf.nAvgBytesPerSec = - this->hidden->shm->wFmt.wf.nSamplesPerSec * - this->hidden->shm->wFmt.wf.nBlockAlign; - - /* Check the buffer size -- minimum of 1/4 second (word aligned) */ - if (this->spec.samples < (this->spec.freq / 4)) - this->spec.samples = ((this->spec.freq / 4) + 3) & ~3; - - /* Update the fragment size as size in bytes */ - SDL_CalculateAudioSpec(&this->spec); - - /* Open the audio device */ - result = waveOutOpen(&(this->hidden->shm->sound), - WAVE_MAPPER, - &(this->hidden->shm->wFmt.wf), - MME_Callback, - NULL, (CALLBACK_FUNCTION | WAVE_OPEN_SHAREABLE)); - if (result != MMSYSERR_NOERROR) { - MME_CloseDevice(this); - SetMMerror("waveOutOpen()", result); - return 0; - } - - /* Create the sound buffers */ - mixbuf = (Uint8 *) mmeAllocBuffer(NUM_BUFFERS * (this->spec.size)); - if (mixbuf == NULL) { - MME_CloseDevice(this); - SDL_OutOfMemory(); - return 0; - } - this->hidden->mixbuf = mixbuf; - - for (i = 0; i < NUM_BUFFERS; i++) { - this->hidden->shm->wHdr[i].lpData = &mixbuf[i * (this->spec.size)]; - this->hidden->shm->wHdr[i].dwBufferLength = this->spec.size; - this->hidden->shm->wHdr[i].dwFlags = 0; - this->hidden->shm->wHdr[i].dwUser = i; - this->hidden->shm->wHdr[i].dwLoops = 0; /* loop control counter */ - this->hidden->shm->wHdr[i].lpNext = NULL; /* reserved for driver */ - this->hidden->shm->wHdr[i].reserved = 0; - inUse[i] = FALSE; - } - this->hidden->next_buffer = 0; - - return 1; -} - -static void -MME_WaitDevice(_THIS) -{ - while (inUse[this->hidden->next_buffer]) { - mmeWaitForCallbacks(); - mmeProcessCallbacks(); - } -} - -static Uint8 * -MME_GetDeviceBuf(_THIS) -{ - void *retval = this->hidden->shm->wHdr[this->hidden->next_buffer].lpData; - inUse[this->hidden->next_buffer] = TRUE; - return (Uint8 *) retval; -} - -static void -MME_PlayDevice(_THIS) -{ - /* Queue it up */ - waveOutWrite(this->hidden->shm->sound, - &(this->hidden->shm->wHdr[this->hidden->next_buffer]), - sizeof(WAVEHDR)); - this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS; -} - -static void -MME_WaitDone(_THIS) -{ - MMRESULT result; - int i; - - if (this->hidden->shm->sound) { - for (i = 0; i < NUM_BUFFERS; i++) - while (inUse[i]) { - mmeWaitForCallbacks(); - mmeProcessCallbacks(); - } - result = waveOutReset(this->hidden->shm->sound); - if (result != MMSYSERR_NOERROR) - SetMMerror("waveOutReset()", result); - mmeProcessCallbacks(); - } -} - -static void -MME_CloseDevice(_THIS) -{ - if (this->hidden != NULL) { - MMRESULT result; - - if (this->hidden->mixbuf) { - result = mmeFreeBuffer(this->hidden->mixbuf); - if (result != MMSYSERR_NOERROR) - SetMMerror("mmeFreeBuffer", result); - this->hidden->mixbuf = NULL; - } - - if (this->hidden->shm) { - if (this->hidden->shm->sound) { - result = waveOutClose(this->hidden->shm->sound); - if (result != MMSYSERR_NOERROR) - SetMMerror("waveOutClose()", result); - mmeProcessCallbacks(); - } - result = mmeFreeMem(this->hidden->shm); - if (result != MMSYSERR_NOERROR) - SetMMerror("mmeFreeMem()", result); - this->hidden->shm = NULL; - } - - SDL_free(this->hidden); - this->hidden = NULL; - } -} - -static int -MME_Init(SDL_AudioDriverImpl * impl) -{ - /* Set the function pointers */ - impl->OpenDevice = MME_OpenDevice; - impl->WaitDevice = MME_WaitDevice; - impl->WaitDone = MME_WaitDone; - impl->PlayDevice = MME_PlayDevice; - impl->GetDeviceBuf = MME_GetDeviceBuf; - impl->CloseDevice = MME_CloseDevice; - impl->OnlyHasDefaultOutputDevice = 1; - - return 1; /* this audio target is available. */ -} - -/* !!! FIXME: Windows "windib" driver is called waveout, too */ -AudioBootStrap MMEAUDIO_bootstrap = { - "waveout", "Tru64 MME WaveOut", MME_Init, 0 -}; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/mme/SDL_mmeaudio.h b/project/jni/sdl-1.3/src/audio/mme/SDL_mmeaudio.h deleted file mode 100644 index e8f07bd3d..000000000 --- a/project/jni/sdl-1.3/src/audio/mme/SDL_mmeaudio.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Allow access to a raw mixing buffer */ - -#ifndef _SDL_mmeaudio_h -#define _SDL_mmeaudio_h - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this -#define NUM_BUFFERS 2 - -struct SharedMem -{ - HWAVEOUT sound; - WAVEHDR wHdr[NUM_BUFFERS]; - PCMWAVEFORMAT wFmt; -}; - -struct SDL_PrivateAudioData -{ - Uint8 *mixbuf; /* The raw allocated mixing buffer */ - struct SharedMem *shm; - int next_buffer; -}; - -#endif /* _SDL_mmeaudio_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/nas/SDL_nasaudio.c b/project/jni/sdl-1.3/src/audio/nas/SDL_nasaudio.c index a9b134842..d44f55627 100644 --- a/project/jni/sdl-1.3/src/audio/nas/SDL_nasaudio.c +++ b/project/jni/sdl-1.3/src/audio/nas/SDL_nasaudio.c @@ -1,30 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - This driver was written by: - Erik Inge Bolsø - knan@mo.himolde.no + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_NAS + /* Allow access to a raw mixing buffer */ #include @@ -37,9 +34,6 @@ #include "../SDL_audio_c.h" #include "SDL_nasaudio.h" -/* The tag name used by nas audio */ -#define NAS_DRIVER_NAME "nas" - static struct SDL_PrivateAudioData *this2 = NULL; @@ -116,8 +110,8 @@ LoadNASLibrary(void) nas_handle = SDL_LoadObject(nas_library); if (nas_handle == NULL) { /* Copy error string so we can use it in a new SDL_SetError(). */ - char *origerr = SDL_GetError(); - size_t len = SDL_strlen(origerr) + 1; + const char *origerr = SDL_GetError(); + const size_t len = SDL_strlen(origerr) + 1; char *err = (char *) alloca(len); SDL_strlcpy(err, origerr, len); retval = -1; @@ -402,7 +396,9 @@ NAS_Init(SDL_AudioDriverImpl * impl) } AudioBootStrap NAS_bootstrap = { - NAS_DRIVER_NAME, "Network Audio System", NAS_Init, 0 + "nas", "Network Audio System", NAS_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_NAS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/nas/SDL_nasaudio.h b/project/jni/sdl-1.3/src/audio/nas/SDL_nasaudio.h index 960402741..a83c938d9 100644 --- a/project/jni/sdl-1.3/src/audio/nas/SDL_nasaudio.h +++ b/project/jni/sdl-1.3/src/audio/nas/SDL_nasaudio.h @@ -1,27 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - This driver was written by: - Erik Inge Bolsø - knan@mo.himolde.no + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/nds/SDL_ndsaudio.c b/project/jni/sdl-1.3/src/audio/nds/SDL_ndsaudio.c index 672bdc0e0..034e1726b 100644 --- a/project/jni/sdl-1.3/src/audio/nds/SDL_ndsaudio.c +++ b/project/jni/sdl-1.3/src/audio/nds/SDL_ndsaudio.c @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - This file written by Ryan C. Gordon (icculus@icculus.org) + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_NDS + /* Output audio to NDS */ #include @@ -57,11 +56,13 @@ NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture) } } +#if 0 /* set the generic sound parameters */ setGenericSound(22050, /* sample rate */ 127, /* volume */ 64, /* panning/balance */ 0); /* sound format */ +#endif return 1; } @@ -69,13 +70,9 @@ NDSAUD_OpenDevice(_THIS, const char *devname, int iscapture) static void NDSAUD_PlayDevice(_THIS) { - TransferSoundData *sound = SDL_malloc(sizeof(TransferSoundData)); - if (!sound) { - SDL_OutOfMemory(); - } - - playGenericSound(this->hidden->mixbuf, this->hidden->mixlen); #if 0 + playGenericSound(this->hidden->mixbuf, this->hidden->mixlen); + // sound->data = this->hidden->mixbuf;/* pointer to raw audio data */ // sound->len = this->hidden->mixlen; /* size of raw data pointed to above */ // sound->rate = 22050; /* sample rate = 22050Hz */ @@ -127,4 +124,6 @@ AudioBootStrap NDSAUD_bootstrap = { "nds", "SDL NDS audio driver", NDSAUD_Init, 0 /*1? */ }; +#endif /* SDL_AUDIO_DRIVER_NDS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/nds/SDL_ndsaudio.h b/project/jni/sdl-1.3/src/audio/nds/SDL_ndsaudio.h index a9cf83660..ab0d7e3fa 100644 --- a/project/jni/sdl-1.3/src/audio/nds/SDL_ndsaudio.h +++ b/project/jni/sdl-1.3/src/audio/nds/SDL_ndsaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -32,7 +31,6 @@ struct SDL_PrivateAudioData { - TransferSoundData *sound; /* The file descriptor for the audio device */ Uint8 *mixbuf; Uint32 mixlen; diff --git a/project/jni/sdl-1.3/src/audio/paudio/SDL_paudio.c b/project/jni/sdl-1.3/src/audio/paudio/SDL_paudio.c index cd05ddf21..821fa7718 100644 --- a/project/jni/sdl-1.3/src/audio/paudio/SDL_paudio.c +++ b/project/jni/sdl-1.3/src/audio/paudio/SDL_paudio.c @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Carsten Griwodz - griff@kom.tu-darmstadt.de - - based on linux/SDL_dspaudio.c by Sam Lantinga + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_PAUDIO + /* Allow access to a raw mixing buffer */ #include @@ -48,9 +47,6 @@ #undef BIG_ENDIAN #include -/* The tag name used by paud audio */ -#define PAUDIO_DRIVER_NAME "paud" - /* Open the audio device for playback, and don't block if busy */ /* #define OPEN_FLAGS (O_WRONLY|O_NONBLOCK) */ #define OPEN_FLAGS O_WRONLY @@ -432,7 +428,7 @@ PAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) /* * The AIX paud device init can't modify the values of the audio_init * structure that we pass to it. So we don't need any recalculation - * of this stuff and no reinit call as in linux dsp and dma code. + * of this stuff and no reinit call as in linux dsp code. * * /dev/paud supports all of the encoding formats, so we don't need * to do anything like reopening the device, either. @@ -548,7 +544,9 @@ PAUDIO_Init(SDL_AudioDriverImpl * impl) } AudioBootStrap PAUDIO_bootstrap = { - PAUDIO_DRIVER_NAME, "AIX Paudio", PAUDIO_Init, 0 + "paud", "AIX Paudio", PAUDIO_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_PAUDIO */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/paudio/SDL_paudio.h b/project/jni/sdl-1.3/src/audio/paudio/SDL_paudio.h index 2dc5de624..d572ba918 100644 --- a/project/jni/sdl-1.3/src/audio/paudio/SDL_paudio.h +++ b/project/jni/sdl-1.3/src/audio/paudio/SDL_paudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/pulseaudio/SDL_pulseaudio.c b/project/jni/sdl-1.3/src/audio/pulseaudio/SDL_pulseaudio.c index 63bd030d7..6b2333e02 100644 --- a/project/jni/sdl-1.3/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/project/jni/sdl-1.3/src/audio/pulseaudio/SDL_pulseaudio.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /* @@ -26,9 +25,10 @@ was the cleanest way to move it to 1.3. The 1.2 target was written by Stéphan Kochen: stephan .a.t. kochen.nl */ - #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_PULSEAUDIO + /* Allow access to a raw mixing buffer */ #ifdef HAVE_SIGNAL_H @@ -47,9 +47,6 @@ #include "SDL_pulseaudio.h" #include "SDL_loadso.h" -/* The tag name used by pulse audio */ -#define PULSEAUDIO_DRIVER_NAME "pulseaudio" - #if (PA_API_VERSION < 12) /** Return non-zero if the passed state is one of the connected states */ static inline int PA_CONTEXT_IS_GOOD(pa_context_state_t x) { @@ -304,38 +301,6 @@ PULSEAUDIO_CloseDevice(_THIS) } -/* !!! FIXME: this could probably be expanded. */ -/* Try to get the name of the program */ -static char * -get_progname(void) -{ -#ifdef __LINUX__ - char *progname = NULL; - FILE *fp; - static char temp[BUFSIZ]; - - SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid()); - fp = fopen(temp, "r"); - if (fp != NULL) { - if (fgets(temp, sizeof(temp) - 1, fp)) { - progname = SDL_strrchr(temp, '/'); - if (progname == NULL) { - progname = temp; - } else { - progname = progname + 1; - } - } - fclose(fp); - } - return(progname); -#elif defined(__NetBSD__) - return getprogname(); -#else - return("unknown"); -#endif -} - - static int PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) { @@ -438,7 +403,7 @@ PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture) } h->mainloop_api = PULSEAUDIO_pa_mainloop_get_api(h->mainloop); - h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, get_progname()); + h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, NULL); if (!h->context) { PULSEAUDIO_CloseDevice(this); SDL_SetError("pa_context_new() failed"); @@ -534,7 +499,9 @@ PULSEAUDIO_Init(SDL_AudioDriverImpl * impl) AudioBootStrap PULSEAUDIO_bootstrap = { - PULSEAUDIO_DRIVER_NAME, "PulseAudio", PULSEAUDIO_Init, 0 + "pulseaudio", "PulseAudio", PULSEAUDIO_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_PULSEAUDIO */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/pulseaudio/SDL_pulseaudio.h b/project/jni/sdl-1.3/src/audio/pulseaudio/SDL_pulseaudio.h index b429b8af0..57b9412c7 100644 --- a/project/jni/sdl-1.3/src/audio/pulseaudio/SDL_pulseaudio.h +++ b/project/jni/sdl-1.3/src/audio/pulseaudio/SDL_pulseaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/qsa/SDL_qsa_audio.c b/project/jni/sdl-1.3/src/audio/qsa/SDL_qsa_audio.c index 6d7362594..2cf4b8b54 100644 --- a/project/jni/sdl-1.3/src/audio/qsa/SDL_qsa_audio.c +++ b/project/jni/sdl-1.3/src/audio/qsa/SDL_qsa_audio.c @@ -1,27 +1,28 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_QSA + #include #include #include @@ -39,9 +40,6 @@ #include "../SDL_audio_c.h" #include "SDL_qsa_audio.h" -/* The tag name used by QSA audio framework */ -#define DRIVER_NAME "qsa" - /* default channel communication parameters */ #define DEFAULT_CPARAMS_RATE 44100 #define DEFAULT_CPARAMS_VOICES 1 @@ -114,6 +112,7 @@ QSA_CheckBuggyCards(_THIS, unsigned long checkfor) return 0; } +/* !!! FIXME: does this need to be here? Does the SDL version not work? */ static void QSA_ThreadInit(_THIS) { @@ -651,8 +650,8 @@ QSA_OpenDevice(_THIS, const char *devname, int iscapture) return 1; } -int -QSA_DetectDevices(int iscapture) +static void +QSA_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) { uint32_t it; uint32_t cards; @@ -667,7 +666,7 @@ QSA_DetectDevices(int iscapture) /* of available audio devices */ if (cards == 0) { /* We have no any available audio devices */ - return 0; + return; } /* Find requested devices by type */ @@ -702,6 +701,7 @@ QSA_DetectDevices(int iscapture) devices; status = snd_pcm_close(handle); if (status == EOK) { + addfn(qsa_playback_device[qsa_playback_devices].name); qsa_playback_devices++; } } else { @@ -757,6 +757,7 @@ QSA_DetectDevices(int iscapture) devices; status = snd_pcm_close(handle); if (status == EOK) { + addfn(qsa_capture_device[qsa_capture_devices].name); qsa_capture_devices++; } } else { @@ -782,34 +783,9 @@ QSA_DetectDevices(int iscapture) } } } - - /* Return amount of available playback or capture devices */ - if (!iscapture) { - return qsa_playback_devices; - } else { - return qsa_capture_devices; - } } -const char * -QSA_GetDeviceName(int index, int iscapture) -{ - if (!iscapture) { - if (index >= qsa_playback_devices) { - return "No such playback device"; - } - - return qsa_playback_device[index].name; - } else { - if (index >= qsa_capture_devices) { - return "No such capture device"; - } - - return qsa_capture_device[index].name; - } -} - -void +static void QSA_WaitDone(_THIS) { if (!this->hidden->iscapture) { @@ -827,7 +803,7 @@ QSA_WaitDone(_THIS) } } -void +static void QSA_Deinitialize(void) { /* Clear devices array on shutdown */ @@ -857,7 +833,6 @@ QSA_Init(SDL_AudioDriverImpl * impl) /* DeviceLock and DeviceUnlock functions are used default, */ /* provided by SDL, which uses pthread_mutex for lock/unlock */ impl->DetectDevices = QSA_DetectDevices; - impl->GetDeviceName = QSA_GetDeviceName; impl->OpenDevice = QSA_OpenDevice; impl->ThreadInit = QSA_ThreadInit; impl->WaitDevice = QSA_WaitDevice; @@ -887,7 +862,9 @@ QSA_Init(SDL_AudioDriverImpl * impl) } AudioBootStrap QSAAUDIO_bootstrap = { - DRIVER_NAME, "QNX QSA Audio", QSA_Init, 0 + "qsa", "QNX QSA Audio", QSA_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_QSA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/qsa/SDL_qsa_audio.h b/project/jni/sdl-1.3/src/audio/qsa/SDL_qsa_audio.h index 228565f29..2ec87d263 100644 --- a/project/jni/sdl-1.3/src/audio/qsa/SDL_qsa_audio.h +++ b/project/jni/sdl-1.3/src/audio/qsa/SDL_qsa_audio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/sdlgenaudiocvt.pl b/project/jni/sdl-1.3/src/audio/sdlgenaudiocvt.pl index 9ffa0f95b..0282a8adc 100755 --- a/project/jni/sdl-1.3/src/audio/sdlgenaudiocvt.pl +++ b/project/jni/sdl-1.3/src/audio/sdlgenaudiocvt.pl @@ -37,25 +37,24 @@ sub outputHeader { print < - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken\@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -537,7 +536,6 @@ ${sym}(SDL_AudioCVT * cvt, SDL_AudioFormat format) fprintf(stderr, "$resample (x${multiple}) AUDIO_${from}, ${channels} channels.\\n"); #endif - const int srcsize = cvt->len_cvt; const int dstsize = cvt->len_cvt $lencvtop $multiple; EOF diff --git a/project/jni/sdl-1.3/src/audio/sun/SDL_sunaudio.c b/project/jni/sdl-1.3/src/audio/sun/SDL_sunaudio.c index 399eece9b..2768cf30e 100644 --- a/project/jni/sdl-1.3/src/audio/sun/SDL_sunaudio.c +++ b/project/jni/sdl-1.3/src/audio/sun/SDL_sunaudio.c @@ -1,31 +1,32 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_AUDIO_DRIVER_SUNAUDIO + /* I'm gambling no one uses this audio backend...we'll see who emails. :) */ #error this code has not been updated for SDL 1.3. #error if no one emails icculus at icculus.org and tells him that this #error code is needed, this audio backend will eventually be removed from SDL. -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - /* Allow access to a raw mixing buffer */ #include @@ -451,4 +452,6 @@ snd2au(int sample) return (mask & sample); } +#endif /* SDL_AUDIO_DRIVER_SUNAUDIO */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/sun/SDL_sunaudio.h b/project/jni/sdl-1.3/src/audio/sun/SDL_sunaudio.h index 652a8a5c1..f73e1d182 100644 --- a/project/jni/sdl-1.3/src/audio/sun/SDL_sunaudio.h +++ b/project/jni/sdl-1.3/src/audio/sun/SDL_sunaudio.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/audio/ums/SDL_umsaudio.c b/project/jni/sdl-1.3/src/audio/ums/SDL_umsaudio.c deleted file mode 100644 index b6e30d647..000000000 --- a/project/jni/sdl-1.3/src/audio/ums/SDL_umsaudio.c +++ /dev/null @@ -1,563 +0,0 @@ -/* I'm gambling no one uses this audio backend...we'll see who emails. :) */ -#error this code has not been updated for SDL 1.3. -#error if no one emails icculus at icculus.org and tells him that this -#error code is needed, this audio backend will eventually be removed from SDL. - -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Carsten Griwodz - griff@kom.tu-darmstadt.de - - based on linux/SDL_dspaudio.c by Sam Lantinga -*/ -#include "SDL_config.h" - -/* Allow access to a raw mixing buffer */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SDL_audio.h" -#include "../SDL_audio_c.h" -#include "SDL_umsaudio.h" - -/* The tag name used by UMS audio */ -#define UMS_DRIVER_NAME "ums" - -#define DEBUG_AUDIO 1 - -/* Audio driver functions */ -static int UMS_OpenAudio(_THIS, SDL_AudioSpec * spec); -static void UMS_PlayAudio(_THIS); -static Uint8 *UMS_GetAudioBuf(_THIS); -static void UMS_CloseAudio(_THIS); - -static UMSAudioDevice_ReturnCode UADOpen(_THIS, string device, string mode, - long flags); -static UMSAudioDevice_ReturnCode UADClose(_THIS); -static UMSAudioDevice_ReturnCode UADGetBitsPerSample(_THIS, long *bits); -static UMSAudioDevice_ReturnCode UADSetBitsPerSample(_THIS, long bits); -static UMSAudioDevice_ReturnCode UADSetSampleRate(_THIS, long rate, - long *set_rate); -static UMSAudioDevice_ReturnCode UADSetByteOrder(_THIS, string byte_order); -static UMSAudioDevice_ReturnCode UADSetAudioFormatType(_THIS, string fmt); -static UMSAudioDevice_ReturnCode UADSetNumberFormat(_THIS, string fmt); -static UMSAudioDevice_ReturnCode UADInitialize(_THIS); -static UMSAudioDevice_ReturnCode UADStart(_THIS); -static UMSAudioDevice_ReturnCode UADStop(_THIS); -static UMSAudioDevice_ReturnCode UADSetTimeFormat(_THIS, - UMSAudioTypes_TimeFormat - fmt); -static UMSAudioDevice_ReturnCode UADWriteBuffSize(_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADWriteBuffRemain(_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADWriteBuffUsed(_THIS, long *buff_size); -static UMSAudioDevice_ReturnCode UADSetDMABufferSize(_THIS, long bytes, - long *bytes_ret); -static UMSAudioDevice_ReturnCode UADSetVolume(_THIS, long volume); -static UMSAudioDevice_ReturnCode UADSetBalance(_THIS, long balance); -static UMSAudioDevice_ReturnCode UADSetChannels(_THIS, long channels); -static UMSAudioDevice_ReturnCode UADPlayRemainingData(_THIS, boolean block); -static UMSAudioDevice_ReturnCode UADEnableOutput(_THIS, string output, - long *left_gain, - long *right_gain); -static UMSAudioDevice_ReturnCode UADWrite(_THIS, UMSAudioTypes_Buffer * buff, - long samples, - long *samples_written); - -/* Audio driver bootstrap functions */ -static int -Audio_Available(void) -{ - return 1; -} - -static void -Audio_DeleteDevice(_THIS) -{ - if (this->hidden->playbuf._buffer) - SDL_free(this->hidden->playbuf._buffer); - if (this->hidden->fillbuf._buffer) - SDL_free(this->hidden->fillbuf._buffer); - _somFree(this->hidden->umsdev); - SDL_free(this->hidden); - SDL_free(this); -} - -static SDL_AudioDevice * -Audio_CreateDevice(int devindex) -{ - SDL_AudioDevice *this; - - /* - * Allocate and initialize management storage and private management - * storage for this SDL-using library. - */ - this = (SDL_AudioDevice *) SDL_malloc(sizeof(SDL_AudioDevice)); - if (this) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateAudioData *) - SDL_malloc((sizeof *this->hidden)); - } - if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory(); - if (this) { - SDL_free(this); - } - return (0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); -#ifdef DEBUG_AUDIO - fprintf(stderr, "Creating UMS Audio device\n"); -#endif - - /* - * Calls for UMS env initialization and audio object construction. - */ - this->hidden->ev = somGetGlobalEnvironment(); - this->hidden->umsdev = UMSAudioDeviceNew(); - - /* - * Set the function pointers. - */ - this->OpenAudio = UMS_OpenAudio; - this->WaitAudio = NULL; /* we do blocking output */ - this->PlayAudio = UMS_PlayAudio; - this->GetAudioBuf = UMS_GetAudioBuf; - this->CloseAudio = UMS_CloseAudio; - this->free = Audio_DeleteDevice; - -#ifdef DEBUG_AUDIO - fprintf(stderr, "done\n"); -#endif - return this; -} - -AudioBootStrap UMS_bootstrap = { - UMS_DRIVER_NAME, "AIX UMS audio", - Audio_Available, Audio_CreateDevice, 0 -}; - -static Uint8 * -UMS_GetAudioBuf(_THIS) -{ -#ifdef DEBUG_AUDIO - fprintf(stderr, "enter UMS_GetAudioBuf\n"); -#endif - return this->hidden->fillbuf._buffer; -/* - long bufSize; - UMSAudioDevice_ReturnCode rc; - - rc = UADSetTimeFormat(this, UMSAudioTypes_Bytes ); - rc = UADWriteBuffSize(this, bufSize ); -*/ -} - -static void -UMS_CloseAudio(_THIS) -{ - UMSAudioDevice_ReturnCode rc; - -#ifdef DEBUG_AUDIO - fprintf(stderr, "enter UMS_CloseAudio\n"); -#endif - rc = UADPlayRemainingData(this, TRUE); - rc = UADStop(this); - rc = UADClose(this); -} - -static void -UMS_PlayAudio(_THIS) -{ - UMSAudioDevice_ReturnCode rc; - long samplesToWrite; - long samplesWritten; - UMSAudioTypes_Buffer swpbuf; - -#ifdef DEBUG_AUDIO - fprintf(stderr, "enter UMS_PlayAudio\n"); -#endif - samplesToWrite = - this->hidden->playbuf._length / this->hidden->bytesPerSample; - do { - rc = UADWrite(this, &this->hidden->playbuf, - samplesToWrite, &samplesWritten); - samplesToWrite -= samplesWritten; - - /* rc values: UMSAudioDevice_Success - * UMSAudioDevice_Failure - * UMSAudioDevice_Preempted - * UMSAudioDevice_Interrupted - * UMSAudioDevice_DeviceError - */ - if (rc == UMSAudioDevice_DeviceError) { -#ifdef DEBUG_AUDIO - fprintf(stderr, "Returning from PlayAudio with devices error\n"); -#endif - return; - } - } while (samplesToWrite > 0); - - SDL_LockAudio(); - SDL_memcpy(&swpbuf, &this->hidden->playbuf, sizeof(UMSAudioTypes_Buffer)); - SDL_memcpy(&this->hidden->playbuf, &this->hidden->fillbuf, - sizeof(UMSAudioTypes_Buffer)); - SDL_memcpy(&this->hidden->fillbuf, &swpbuf, sizeof(UMSAudioTypes_Buffer)); - SDL_UnlockAudio(); - -#ifdef DEBUG_AUDIO - fprintf(stderr, "Wrote audio data and swapped buffer\n"); -#endif -} - -#if 0 -// /* Set the DSP frequency */ -// value = spec->freq; -// if ( ioctl(this->hidden->audio_fd, SOUND_PCM_WRITE_RATE, &value) < 0 ) { -// SDL_SetError("Couldn't set audio frequency"); -// return(-1); -// } -// spec->freq = value; -#endif - -static int -UMS_OpenAudio(_THIS, SDL_AudioSpec * spec) -{ - char *audiodev = "/dev/paud0"; - long lgain; - long rgain; - long outRate; - long outBufSize; - long bitsPerSample; - long samplesPerSec; - long success; - SDL_AudioFormat test_format; - int frag_spec; - UMSAudioDevice_ReturnCode rc; - -#ifdef DEBUG_AUDIO - fprintf(stderr, "enter UMS_OpenAudio\n"); -#endif - rc = UADOpen(this, audiodev, "PLAY", UMSAudioDevice_BlockingIO); - if (rc != UMSAudioDevice_Success) { - SDL_SetError("Couldn't open %s: %s", audiodev, strerror(errno)); - return -1; - } - - rc = UADSetAudioFormatType(this, "PCM"); - - success = 0; - test_format = SDL_FirstAudioFormat(spec->format); - do { -#ifdef DEBUG_AUDIO - fprintf(stderr, "Trying format 0x%4.4x\n", test_format); -#endif - switch (test_format) { - case AUDIO_U8: -/* from the mac code: better ? */ -/* sample_bits = spec->size / spec->samples / spec->channels * 8; */ - success = 1; - bitsPerSample = 8; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "MSB"); /* irrelevant */ - rc = UADSetNumberFormat(this, "UNSIGNED"); - break; - case AUDIO_S8: - success = 1; - bitsPerSample = 8; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "MSB"); /* irrelevant */ - rc = UADSetNumberFormat(this, "SIGNED"); - break; - case AUDIO_S16LSB: - success = 1; - bitsPerSample = 16; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "LSB"); - rc = UADSetNumberFormat(this, "SIGNED"); - break; - case AUDIO_S16MSB: - success = 1; - bitsPerSample = 16; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "MSB"); - rc = UADSetNumberFormat(this, "SIGNED"); - break; - case AUDIO_U16LSB: - success = 1; - bitsPerSample = 16; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "LSB"); - rc = UADSetNumberFormat(this, "UNSIGNED"); - break; - case AUDIO_U16MSB: - success = 1; - bitsPerSample = 16; - rc = UADSetSampleRate(this, spec->freq << 16, &outRate); - rc = UADSetByteOrder(this, "MSB"); - rc = UADSetNumberFormat(this, "UNSIGNED"); - break; - default: - break; - } - if (!success) { - test_format = SDL_NextAudioFormat(); - } - } while (!success && test_format); - - if (success == 0) { - SDL_SetError("Couldn't find any hardware audio formats"); - return -1; - } - - spec->format = test_format; - - for (frag_spec = 0; (0x01 << frag_spec) < spec->size; ++frag_spec); - if ((0x01 << frag_spec) != spec->size) { - SDL_SetError("Fragment size must be a power of two"); - return -1; - } - if (frag_spec > 2048) - frag_spec = 2048; - - this->hidden->bytesPerSample = (bitsPerSample / 8) * spec->channels; - samplesPerSec = this->hidden->bytesPerSample * outRate; - - this->hidden->playbuf._length = 0; - this->hidden->playbuf._maximum = spec->size; - this->hidden->playbuf._buffer = (unsigned char *) SDL_malloc(spec->size); - this->hidden->fillbuf._length = 0; - this->hidden->fillbuf._maximum = spec->size; - this->hidden->fillbuf._buffer = (unsigned char *) SDL_malloc(spec->size); - - rc = UADSetBitsPerSample(this, bitsPerSample); - rc = UADSetDMABufferSize(this, frag_spec, &outBufSize); - rc = UADSetChannels(this, spec->channels); /* functions reduces to mono or stereo */ - - lgain = 100; /*maximum left input gain */ - rgain = 100; /*maimum right input gain */ - rc = UADEnableOutput(this, "LINE_OUT", &lgain, &rgain); - rc = UADInitialize(this); - rc = UADStart(this); - rc = UADSetVolume(this, 100); - rc = UADSetBalance(this, 0); - - /* We're ready to rock and roll. :-) */ - return 0; -} - - -static UMSAudioDevice_ReturnCode -UADGetBitsPerSample(_THIS, long *bits) -{ - return UMSAudioDevice_get_bits_per_sample(this->hidden->umsdev, - this->hidden->ev, bits); -} - -static UMSAudioDevice_ReturnCode -UADSetBitsPerSample(_THIS, long bits) -{ - return UMSAudioDevice_set_bits_per_sample(this->hidden->umsdev, - this->hidden->ev, bits); -} - -static UMSAudioDevice_ReturnCode -UADSetSampleRate(_THIS, long rate, long *set_rate) -{ - /* from the mac code: sample rate = spec->freq << 16; */ - return UMSAudioDevice_set_sample_rate(this->hidden->umsdev, - this->hidden->ev, rate, set_rate); -} - -static UMSAudioDevice_ReturnCode -UADSetByteOrder(_THIS, string byte_order) -{ - return UMSAudioDevice_set_byte_order(this->hidden->umsdev, - this->hidden->ev, byte_order); -} - -static UMSAudioDevice_ReturnCode -UADSetAudioFormatType(_THIS, string fmt) -{ - /* possible PCM, A_LAW or MU_LAW */ - return UMSAudioDevice_set_audio_format_type(this->hidden->umsdev, - this->hidden->ev, fmt); -} - -static UMSAudioDevice_ReturnCode -UADSetNumberFormat(_THIS, string fmt) -{ - /* possible SIGNED, UNSIGNED, or TWOS_COMPLEMENT */ - return UMSAudioDevice_set_number_format(this->hidden->umsdev, - this->hidden->ev, fmt); -} - -static UMSAudioDevice_ReturnCode -UADInitialize(_THIS) -{ - return UMSAudioDevice_initialize(this->hidden->umsdev, this->hidden->ev); -} - -static UMSAudioDevice_ReturnCode -UADStart(_THIS) -{ - return UMSAudioDevice_start(this->hidden->umsdev, this->hidden->ev); -} - -static UMSAudioDevice_ReturnCode -UADSetTimeFormat(_THIS, UMSAudioTypes_TimeFormat fmt) -{ - /* - * Switches the time format to the new format, immediately. - * possible UMSAudioTypes_Msecs, UMSAudioTypes_Bytes or UMSAudioTypes_Samples - */ - return UMSAudioDevice_set_time_format(this->hidden->umsdev, - this->hidden->ev, fmt); -} - -static UMSAudioDevice_ReturnCode -UADWriteBuffSize(_THIS, long *buff_size) -{ - /* - * returns write buffer size in the current time format - */ - return UMSAudioDevice_write_buff_size(this->hidden->umsdev, - this->hidden->ev, buff_size); -} - -static UMSAudioDevice_ReturnCode -UADWriteBuffRemain(_THIS, long *buff_size) -{ - /* - * returns amount of available space in the write buffer - * in the current time format - */ - return UMSAudioDevice_write_buff_remain(this->hidden->umsdev, - this->hidden->ev, buff_size); -} - -static UMSAudioDevice_ReturnCode -UADWriteBuffUsed(_THIS, long *buff_size) -{ - /* - * returns amount of filled space in the write buffer - * in the current time format - */ - return UMSAudioDevice_write_buff_used(this->hidden->umsdev, - this->hidden->ev, buff_size); -} - -static UMSAudioDevice_ReturnCode -UADSetDMABufferSize(_THIS, long bytes, long *bytes_ret) -{ - /* - * Request a new DMA buffer size, maximum requested size 2048. - * Takes effect with next initialize() call. - * Devices may or may not support DMA. - */ - return UMSAudioDevice_set_DMA_buffer_size(this->hidden->umsdev, - this->hidden->ev, - bytes, bytes_ret); -} - -static UMSAudioDevice_ReturnCode -UADSetVolume(_THIS, long volume) -{ - /* - * Set the volume. - * Takes effect immediately. - */ - return UMSAudioDevice_set_volume(this->hidden->umsdev, - this->hidden->ev, volume); -} - -static UMSAudioDevice_ReturnCode -UADSetBalance(_THIS, long balance) -{ - /* - * Set the balance. - * Takes effect immediately. - */ - return UMSAudioDevice_set_balance(this->hidden->umsdev, - this->hidden->ev, balance); -} - -static UMSAudioDevice_ReturnCode -UADSetChannels(_THIS, long channels) -{ - /* - * Set mono or stereo. - * Takes effect with next initialize() call. - */ - if (channels != 1) - channels = 2; - return UMSAudioDevice_set_number_of_channels(this->hidden->umsdev, - this->hidden->ev, channels); -} - -static UMSAudioDevice_ReturnCode -UADOpen(_THIS, string device, string mode, long flags) -{ - return UMSAudioDevice_open(this->hidden->umsdev, - this->hidden->ev, device, mode, flags); -} - -static UMSAudioDevice_ReturnCode -UADWrite(_THIS, UMSAudioTypes_Buffer * buff, - long samples, long *samples_written) -{ - return UMSAudioDevice_write(this->hidden->umsdev, - this->hidden->ev, - buff, samples, samples_written); -} - -static UMSAudioDevice_ReturnCode -UADPlayRemainingData(_THIS, boolean block) -{ - return UMSAudioDevice_play_remaining_data(this->hidden->umsdev, - this->hidden->ev, block); -} - -static UMSAudioDevice_ReturnCode -UADStop(_THIS) -{ - return UMSAudioDevice_stop(this->hidden->umsdev, this->hidden->ev); -} - -static UMSAudioDevice_ReturnCode -UADClose(_THIS) -{ - return UMSAudioDevice_close(this->hidden->umsdev, this->hidden->ev); -} - -static UMSAudioDevice_ReturnCode -UADEnableOutput(_THIS, string output, long *left_gain, long *right_gain) -{ - return UMSAudioDevice_enable_output(this->hidden->umsdev, - this->hidden->ev, - output, left_gain, right_gain); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/ums/SDL_umsaudio.h b/project/jni/sdl-1.3/src/audio/ums/SDL_umsaudio.h deleted file mode 100644 index e2977da26..000000000 --- a/project/jni/sdl-1.3/src/audio/ums/SDL_umsaudio.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Carsten Griwodz - griff@kom.tu-darmstadt.de - - based on linux/SDL_dspaudio.h by Sam Lantinga -*/ -#include "SDL_config.h" - -#ifndef _SDL_UMSaudio_h -#define _SDL_UMSaudio_h - -#include - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -struct SDL_PrivateAudioData -{ - /* Pointer to the (open) UMS audio device */ - Environment *ev; - UMSAudioDevice umsdev; - - /* Raw mixing buffer */ - UMSAudioTypes_Buffer playbuf; - UMSAudioTypes_Buffer fillbuf; - - long bytesPerSample; -}; - -#endif /* _SDL_UMSaudio_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/windib/SDL_dibaudio.h b/project/jni/sdl-1.3/src/audio/windib/SDL_dibaudio.h deleted file mode 100644 index 39a95f30e..000000000 --- a/project/jni/sdl-1.3/src/audio/windib/SDL_dibaudio.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_dibaudio_h -#define _SDL_dibaudio_h - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -#define NUM_BUFFERS 2 /* -- Don't lower this! */ - -struct SDL_PrivateAudioData -{ - HWAVEOUT sound; - HANDLE audio_sem; - Uint8 *mixbuf; /* The raw allocated mixing buffer */ - WAVEHDR wavebuf[NUM_BUFFERS]; /* Wave audio fragments */ - int next_buffer; -}; - -#endif /* _SDL_dibaudio_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/windx5/SDL_dx5audio.h b/project/jni/sdl-1.3/src/audio/windx5/SDL_dx5audio.h deleted file mode 100644 index 6906c4757..000000000 --- a/project/jni/sdl-1.3/src/audio/windx5/SDL_dx5audio.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_dx5audio_h -#define _SDL_dx5audio_h - -#include "directx.h" - -#include "../SDL_sysaudio.h" - -/* Hidden "this" pointer for the audio functions */ -#define _THIS SDL_AudioDevice *this - -/* The DirectSound objects */ -struct SDL_PrivateAudioData -{ - LPDIRECTSOUND sound; - LPDIRECTSOUNDBUFFER mixbuf; - int num_buffers; - int mixlen; - DWORD lastchunk; - Uint8 *locked_buf; -}; - -#endif /* _SDL_dx5audio_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/windib/SDL_dibaudio.c b/project/jni/sdl-1.3/src/audio/winmm/SDL_winmm.c similarity index 55% rename from project/jni/sdl-1.3/src/audio/windib/SDL_dibaudio.c rename to project/jni/sdl-1.3/src/audio/winmm/SDL_winmm.c index 7640c5eee..019f7dff2 100644 --- a/project/jni/sdl-1.3/src/audio/windib/SDL_dibaudio.c +++ b/project/jni/sdl-1.3/src/audio/winmm/SDL_winmm.c @@ -1,52 +1,92 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_AUDIO_DRIVER_WINMM + /* Allow access to a raw mixing buffer */ -#define WIN32_LEAN_AND_MEAN -#include +#include "../../core/windows/SDL_windows.h" #include #include "SDL_timer.h" #include "SDL_audio.h" #include "../SDL_audio_c.h" -#include "SDL_dibaudio.h" +#include "SDL_winmm.h" #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) #include "win_ce_semaphore.h" #endif -#if defined(_WIN32_WCE) -#define WINDOWS_OS_NAME "Windows CE/PocketPC" -#elif defined(WIN64) -#define WINDOWS_OS_NAME "Win64" +#define DETECT_DEV_IMPL(typ, capstyp) \ +static void DetectWave##typ##Devs(SDL_AddAudioDevice addfn) { \ + const UINT devcount = wave##typ##GetNumDevs(); \ + capstyp caps; \ + UINT i; \ + for (i = 0; i < devcount; i++) { \ + if (wave##typ##GetDevCaps(i,&caps,sizeof(caps))==MMSYSERR_NOERROR) { \ + char *name = WIN_StringToUTF8(caps.szPname); \ + if (name != NULL) { \ + addfn(name); \ + SDL_free(name); \ + } \ + } \ + } \ +} + +DETECT_DEV_IMPL(Out, WAVEOUTCAPS) +DETECT_DEV_IMPL(In, WAVEINCAPS) + +static void +WINMM_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) +{ + if (iscapture) { + DetectWaveInDevs(addfn); + } else { + DetectWaveOutDevs(addfn); + } +} + +static void CALLBACK +CaptureSound(HWAVEIN hwi, UINT uMsg, DWORD_PTR dwInstance, + DWORD_PTR dwParam1, DWORD_PTR dwParam2) +{ + SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance; + + /* Only service "buffer is filled" messages */ + if (uMsg != WIM_DATA) + return; + + /* Signal that we have a new buffer of data */ +#if defined(_WIN32_WCE) && (_WIN32_WCE < 300) + ReleaseSemaphoreCE(this->hidden->audio_sem, 1, NULL); #else -#define WINDOWS_OS_NAME "Win32" + ReleaseSemaphore(this->hidden->audio_sem, 1, NULL); #endif +} + /* The Win32 callback for filling the WAVE device */ static void CALLBACK FillSound(HWAVEOUT hwo, UINT uMsg, DWORD_PTR dwInstance, - DWORD dwParam1, DWORD dwParam2) + DWORD_PTR dwParam1, DWORD_PTR dwParam2) { SDL_AudioDevice *this = (SDL_AudioDevice *) dwInstance; @@ -67,34 +107,20 @@ SetMMerror(char *function, MMRESULT code) { size_t len; char errbuf[MAXERRORLENGTH]; -#ifdef _WIN32_WCE wchar_t werrbuf[MAXERRORLENGTH]; -#endif SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function); len = SDL_strlen(errbuf); -#ifdef _WIN32_WCE - /* UNICODE version */ waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len); WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len, MAXERRORLENGTH - len, NULL, NULL); -#else - waveOutGetErrorText(code, errbuf + len, (UINT) (MAXERRORLENGTH - len)); -#endif SDL_SetError("%s", errbuf); } -/* Set high priority for the audio thread */ static void -WINWAVEOUT_ThreadInit(_THIS) -{ - SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); -} - -void -WINWAVEOUT_WaitDevice(_THIS) +WINMM_WaitDevice(_THIS) { /* Wait for an audio chunk to finish */ #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) @@ -104,25 +130,25 @@ WINWAVEOUT_WaitDevice(_THIS) #endif } -Uint8 * -WINWAVEOUT_GetDeviceBuf(_THIS) +static Uint8 * +WINMM_GetDeviceBuf(_THIS) { return (Uint8 *) (this->hidden-> wavebuf[this->hidden->next_buffer].lpData); } -void -WINWAVEOUT_PlayDevice(_THIS) +static void +WINMM_PlayDevice(_THIS) { /* Queue it up */ - waveOutWrite(this->hidden->sound, + waveOutWrite(this->hidden->hout, &this->hidden->wavebuf[this->hidden->next_buffer], sizeof(this->hidden->wavebuf[0])); this->hidden->next_buffer = (this->hidden->next_buffer + 1) % NUM_BUFFERS; } -void -WINWAVEOUT_WaitDone(_THIS) +static void +WINMM_WaitDone(_THIS) { int i, left; @@ -139,8 +165,8 @@ WINWAVEOUT_WaitDone(_THIS) } while (left > 0); } -void -WINWAVEOUT_CloseDevice(_THIS) +static void +WINMM_CloseDevice(_THIS) { /* Close up audio */ if (this->hidden != NULL) { @@ -155,15 +181,20 @@ WINWAVEOUT_CloseDevice(_THIS) this->hidden->audio_sem = 0; } - if (this->hidden->sound) { - waveOutClose(this->hidden->sound); - this->hidden->sound = 0; + if (this->hidden->hin) { + waveInClose(this->hidden->hin); + this->hidden->hin = 0; + } + + if (this->hidden->hout) { + waveOutClose(this->hidden->hout); + this->hidden->hout = 0; } /* Clean up mixing buffers */ for (i = 0; i < NUM_BUFFERS; ++i) { if (this->hidden->wavebuf[i].dwUser != 0xFFFF) { - waveOutUnprepareHeader(this->hidden->sound, + waveOutUnprepareHeader(this->hidden->hout, &this->hidden->wavebuf[i], sizeof(this->hidden->wavebuf[i])); this->hidden->wavebuf[i].dwUser = 0xFFFF; @@ -181,15 +212,52 @@ WINWAVEOUT_CloseDevice(_THIS) } } -int -WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) +static int +WINMM_OpenDevice(_THIS, const char *devname, int iscapture) { SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); int valid_datatype = 0; MMRESULT result; WAVEFORMATEX waveformat; + UINT_PTR devId = WAVE_MAPPER; /* WAVE_MAPPER == choose system's default */ + char *utf8 = NULL; int i; + if (devname != NULL) { /* specific device requested? */ + if (iscapture) { + const int devcount = (int) waveInGetNumDevs(); + WAVEINCAPS caps; + for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) { + result = waveInGetDevCaps(i, &caps, sizeof (caps)); + if (result != MMSYSERR_NOERROR) + continue; + else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL) + continue; + else if (SDL_strcmp(devname, utf8) == 0) + devId = (UINT_PTR) i; + SDL_free(utf8); + } + } else { + const int devcount = (int) waveOutGetNumDevs(); + WAVEOUTCAPS caps; + for (i = 0; (i < devcount) && (devId == WAVE_MAPPER); i++) { + result = waveOutGetDevCaps(i, &caps, sizeof (caps)); + if (result != MMSYSERR_NOERROR) + continue; + else if ((utf8 = WIN_StringToUTF8(caps.szPname)) == NULL) + continue; + else if (SDL_strcmp(devname, utf8) == 0) + devId = (UINT_PTR) i; + SDL_free(utf8); + } + } + + if (devId == WAVE_MAPPER) { + SDL_SetError("Requested device not found"); + return 0; + } + } + /* Initialize all variables that we clean on shutdown */ this->hidden = (struct SDL_PrivateAudioData *) SDL_malloc((sizeof *this->hidden)); @@ -220,7 +288,7 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) } if (!valid_datatype) { - WINWAVEOUT_CloseDevice(this); + WINMM_CloseDevice(this); SDL_SetError("Unsupported audio format"); return 0; } @@ -248,11 +316,18 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) SDL_CalculateAudioSpec(&this->spec); /* Open the audio device */ - result = waveOutOpen(&this->hidden->sound, WAVE_MAPPER, &waveformat, - (DWORD_PTR) FillSound, (DWORD_PTR) this, - CALLBACK_FUNCTION); + if (iscapture) { + result = waveInOpen(&this->hidden->hin, devId, &waveformat, + (DWORD_PTR) CaptureSound, (DWORD_PTR) this, + CALLBACK_FUNCTION); + } else { + result = waveOutOpen(&this->hidden->hout, devId, &waveformat, + (DWORD_PTR) FillSound, (DWORD_PTR) this, + CALLBACK_FUNCTION); + } + if (result != MMSYSERR_NOERROR) { - WINWAVEOUT_CloseDevice(this); + WINMM_CloseDevice(this); SetMMerror("waveOutOpen()", result); return 0; } @@ -261,10 +336,10 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) { WAVEOUTCAPS caps; - result = waveOutGetDevCaps((UINT) this->hidden->sound, + result = waveOutGetDevCaps((UINT) this->hidden->hout, &caps, sizeof(caps)); if (result != MMSYSERR_NOERROR) { - WINWAVEOUT_CloseDevice(this); + WINMM_CloseDevice(this); SetMMerror("waveOutGetDevCaps()", result); return 0; } @@ -280,7 +355,7 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) CreateSemaphore(NULL, NUM_BUFFERS - 1, NUM_BUFFERS, NULL); #endif if (this->hidden->audio_sem == NULL) { - WINWAVEOUT_CloseDevice(this); + WINMM_CloseDevice(this); SDL_SetError("Couldn't create semaphore"); return 0; } @@ -289,7 +364,7 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) this->hidden->mixbuf = (Uint8 *) SDL_malloc(NUM_BUFFERS * this->spec.size); if (this->hidden->mixbuf == NULL) { - WINWAVEOUT_CloseDevice(this); + WINMM_CloseDevice(this); SDL_OutOfMemory(); return 0; } @@ -300,11 +375,11 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) this->hidden->wavebuf[i].dwFlags = WHDR_DONE; this->hidden->wavebuf[i].lpData = (LPSTR) & this->hidden->mixbuf[i * this->spec.size]; - result = waveOutPrepareHeader(this->hidden->sound, + result = waveOutPrepareHeader(this->hidden->hout, &this->hidden->wavebuf[i], sizeof(this->hidden->wavebuf[i])); if (result != MMSYSERR_NOERROR) { - WINWAVEOUT_CloseDevice(this); + WINMM_CloseDevice(this); SetMMerror("waveOutPrepareHeader()", result); return 0; } @@ -315,23 +390,24 @@ WINWAVEOUT_OpenDevice(_THIS, const char *devname, int iscapture) static int -WINWAVEOUT_Init(SDL_AudioDriverImpl * impl) +WINMM_Init(SDL_AudioDriverImpl * impl) { /* Set the function pointers */ - impl->OpenDevice = WINWAVEOUT_OpenDevice; - impl->ThreadInit = WINWAVEOUT_ThreadInit; - impl->PlayDevice = WINWAVEOUT_PlayDevice; - impl->WaitDevice = WINWAVEOUT_WaitDevice; - impl->WaitDone = WINWAVEOUT_WaitDone; - impl->GetDeviceBuf = WINWAVEOUT_GetDeviceBuf; - impl->CloseDevice = WINWAVEOUT_CloseDevice; - impl->OnlyHasDefaultOutputDevice = 1; /* !!! FIXME: Is this true? */ + impl->DetectDevices = WINMM_DetectDevices; + impl->OpenDevice = WINMM_OpenDevice; + impl->PlayDevice = WINMM_PlayDevice; + impl->WaitDevice = WINMM_WaitDevice; + impl->WaitDone = WINMM_WaitDone; + impl->GetDeviceBuf = WINMM_GetDeviceBuf; + impl->CloseDevice = WINMM_CloseDevice; return 1; /* this audio target is available. */ } -AudioBootStrap WINWAVEOUT_bootstrap = { - "waveout", WINDOWS_OS_NAME " WaveOut", WINWAVEOUT_Init, 0 +AudioBootStrap WINMM_bootstrap = { + "winmm", "Windows Waveform Audio", WINMM_Init, 0 }; +#endif /* SDL_AUDIO_DRIVER_WINMM */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/winmm/SDL_winmm.h b/project/jni/sdl-1.3/src/audio/winmm/SDL_winmm.h new file mode 100644 index 000000000..f68ed28d7 --- /dev/null +++ b/project/jni/sdl-1.3/src/audio/winmm/SDL_winmm.h @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_winmm_h +#define _SDL_winmm_h + +#include "../SDL_sysaudio.h" + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +#define NUM_BUFFERS 2 /* -- Don't lower this! */ + +struct SDL_PrivateAudioData +{ + HWAVEOUT hout; + HWAVEIN hin; + HANDLE audio_sem; + Uint8 *mixbuf; /* The raw allocated mixing buffer */ + WAVEHDR wavebuf[NUM_BUFFERS]; /* Wave audio fragments */ + int next_buffer; +}; + +#endif /* _SDL_winmm_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/audio/xaudio2/SDL_xaudio2.c b/project/jni/sdl-1.3/src/audio/xaudio2/SDL_xaudio2.c new file mode 100644 index 000000000..a1230e4d7 --- /dev/null +++ b/project/jni/sdl-1.3/src/audio/xaudio2/SDL_xaudio2.c @@ -0,0 +1,445 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_AUDIO_DRIVER_XAUDIO2 + +#include "../../core/windows/SDL_windows.h" +#include "SDL_audio.h" +#include "../SDL_audio_c.h" +#include "../SDL_sysaudio.h" +#include "SDL_assert.h" + +#include /* XAudio2 exists as of the March 2008 DirectX SDK */ +#if (!defined(_DXSDK_BUILD_MAJOR) || (_DXSDK_BUILD_MAJOR < 1284)) +# warning Your DirectX SDK is too old. Disabling XAudio2 support. +#else +# define SDL_XAUDIO2_HAS_SDK 1 +#endif + +#ifdef SDL_XAUDIO2_HAS_SDK + +#define INITGUID 1 +#include + +/* Hidden "this" pointer for the audio functions */ +#define _THIS SDL_AudioDevice *this + +struct SDL_PrivateAudioData +{ + IXAudio2 *ixa2; + IXAudio2SourceVoice *source; + IXAudio2MasteringVoice *mastering; + HANDLE semaphore; + Uint8 *mixbuf; + int mixlen; + Uint8 *nextbuf; +}; + + +static __inline__ char * +utf16_to_utf8(const WCHAR *S) +{ + /* !!! FIXME: this should be UTF-16, not UCS-2! */ + return SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), + (SDL_wcslen(S)+1)*sizeof(WCHAR)); +} + +static void +XAUDIO2_DetectDevices(int iscapture, SDL_AddAudioDevice addfn) +{ + IXAudio2 *ixa2 = NULL; + UINT32 devcount = 0; + UINT32 i = 0; + void *ptr = NULL; + + if (iscapture) { + SDL_SetError("XAudio2: capture devices unsupported."); + return; + } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) { + SDL_SetError("XAudio2: XAudio2Create() failed."); + return; + } else if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) { + SDL_SetError("XAudio2: IXAudio2::GetDeviceCount() failed."); + IXAudio2_Release(ixa2); + return; + } + + for (i = 0; i < devcount; i++) { + XAUDIO2_DEVICE_DETAILS details; + if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) { + char *str = utf16_to_utf8(details.DisplayName); + if (str != NULL) { + addfn(str); + SDL_free(str); /* addfn() made a copy of the string. */ + } + } + } + + IXAudio2_Release(ixa2); +} + +static void STDMETHODCALLTYPE +VoiceCBOnBufferEnd(THIS_ void *data) +{ + /* Just signal the SDL audio thread and get out of XAudio2's way. */ + SDL_AudioDevice *this = (SDL_AudioDevice *) data; + ReleaseSemaphore(this->hidden->semaphore, 1, NULL); +} + +static void STDMETHODCALLTYPE +VoiceCBOnVoiceError(THIS_ void *data, HRESULT Error) +{ + /* !!! FIXME: attempt to recover, or mark device disconnected. */ + SDL_assert(0 && "write me!"); +} + +/* no-op callbacks... */ +static void STDMETHODCALLTYPE VoiceCBOnStreamEnd(THIS) {} +static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassStart(THIS_ UINT32 b) {} +static void STDMETHODCALLTYPE VoiceCBOnVoiceProcessPassEnd(THIS) {} +static void STDMETHODCALLTYPE VoiceCBOnBufferStart(THIS_ void *data) {} +static void STDMETHODCALLTYPE VoiceCBOnLoopEnd(THIS_ void *data) {} + + +static Uint8 * +XAUDIO2_GetDeviceBuf(_THIS) +{ + return this->hidden->nextbuf; +} + +static void +XAUDIO2_PlayDevice(_THIS) +{ + XAUDIO2_BUFFER buffer; + Uint8 *mixbuf = this->hidden->mixbuf; + Uint8 *nextbuf = this->hidden->nextbuf; + const int mixlen = this->hidden->mixlen; + IXAudio2SourceVoice *source = this->hidden->source; + HRESULT result = S_OK; + + if (!this->enabled) { /* shutting down? */ + return; + } + + /* Submit the next filled buffer */ + SDL_zero(buffer); + buffer.AudioBytes = mixlen; + buffer.pAudioData = nextbuf; + buffer.pContext = this; + + if (nextbuf == mixbuf) { + nextbuf += mixlen; + } else { + nextbuf = mixbuf; + } + this->hidden->nextbuf = nextbuf; + + result = IXAudio2SourceVoice_SubmitSourceBuffer(source, &buffer, NULL); + if (result == XAUDIO2_E_DEVICE_INVALIDATED) { + /* !!! FIXME: possibly disconnected or temporary lost. Recover? */ + } + + if (result != S_OK) { /* uhoh, panic! */ + IXAudio2SourceVoice_FlushSourceBuffers(source); + this->enabled = 0; + } +} + +static void +XAUDIO2_WaitDevice(_THIS) +{ + if (this->enabled) { + WaitForSingleObject(this->hidden->semaphore, INFINITE); + } +} + +static void +XAUDIO2_WaitDone(_THIS) +{ + IXAudio2SourceVoice *source = this->hidden->source; + XAUDIO2_VOICE_STATE state; + SDL_assert(!this->enabled); /* flag that stops playing. */ + IXAudio2SourceVoice_Discontinuity(source); + IXAudio2SourceVoice_GetState(source, &state); + while (state.BuffersQueued > 0) { + WaitForSingleObject(this->hidden->semaphore, INFINITE); + IXAudio2SourceVoice_GetState(source, &state); + } +} + + +static void +XAUDIO2_CloseDevice(_THIS) +{ + if (this->hidden != NULL) { + IXAudio2 *ixa2 = this->hidden->ixa2; + IXAudio2SourceVoice *source = this->hidden->source; + IXAudio2MasteringVoice *mastering = this->hidden->mastering; + + if (source != NULL) { + IXAudio2SourceVoice_Stop(source, 0, XAUDIO2_COMMIT_NOW); + IXAudio2SourceVoice_FlushSourceBuffers(source); + IXAudio2SourceVoice_DestroyVoice(source); + } + if (ixa2 != NULL) { + IXAudio2_StopEngine(ixa2); + } + if (mastering != NULL) { + IXAudio2MasteringVoice_DestroyVoice(mastering); + } + if (ixa2 != NULL) { + IXAudio2_Release(ixa2); + } + if (this->hidden->mixbuf != NULL) { + SDL_free(this->hidden->mixbuf); + } + if (this->hidden->semaphore != NULL) { + CloseHandle(this->hidden->semaphore); + } + + SDL_free(this->hidden); + this->hidden = NULL; + } +} + +static int +XAUDIO2_OpenDevice(_THIS, const char *devname, int iscapture) +{ + HRESULT result = S_OK; + WAVEFORMATEX waveformat; + int valid_format = 0; + SDL_AudioFormat test_format = SDL_FirstAudioFormat(this->spec.format); + IXAudio2 *ixa2 = NULL; + IXAudio2SourceVoice *source = NULL; + UINT32 devId = 0; /* 0 == system default device. */ + + static IXAudio2VoiceCallbackVtbl callbacks_vtable = { + VoiceCBOnVoiceProcessPassStart, + VoiceCBOnVoiceProcessPassEnd, + VoiceCBOnStreamEnd, + VoiceCBOnBufferStart, + VoiceCBOnBufferEnd, + VoiceCBOnLoopEnd, + VoiceCBOnVoiceError + }; + + static IXAudio2VoiceCallback callbacks = { &callbacks_vtable }; + + if (iscapture) { + SDL_SetError("XAudio2: capture devices unsupported."); + return 0; + } else if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) { + SDL_SetError("XAudio2: XAudio2Create() failed."); + return 0; + } + + if (devname != NULL) { + UINT32 devcount = 0; + UINT32 i = 0; + + if (IXAudio2_GetDeviceCount(ixa2, &devcount) != S_OK) { + IXAudio2_Release(ixa2); + SDL_SetError("XAudio2: IXAudio2_GetDeviceCount() failed."); + return 0; + } + for (i = 0; i < devcount; i++) { + XAUDIO2_DEVICE_DETAILS details; + if (IXAudio2_GetDeviceDetails(ixa2, i, &details) == S_OK) { + char *str = utf16_to_utf8(details.DisplayName); + if (str != NULL) { + const int match = (SDL_strcmp(str, devname) == 0); + SDL_free(str); + if (match) { + devId = i; + break; + } + } + } + } + + if (i == devcount) { + IXAudio2_Release(ixa2); + SDL_SetError("XAudio2: Requested device not found."); + return 0; + } + } + + /* Initialize all variables that we clean on shutdown */ + this->hidden = (struct SDL_PrivateAudioData *) + SDL_malloc((sizeof *this->hidden)); + if (this->hidden == NULL) { + IXAudio2_Release(ixa2); + SDL_OutOfMemory(); + return 0; + } + SDL_memset(this->hidden, 0, (sizeof *this->hidden)); + + this->hidden->ixa2 = ixa2; + this->hidden->semaphore = CreateSemaphore(NULL, 1, 2, NULL); + if (this->hidden->semaphore == NULL) { + XAUDIO2_CloseDevice(this); + SDL_SetError("XAudio2: CreateSemaphore() failed!"); + return 0; + } + + while ((!valid_format) && (test_format)) { + switch (test_format) { + case AUDIO_U8: + case AUDIO_S16: + case AUDIO_S32: + case AUDIO_F32: + this->spec.format = test_format; + valid_format = 1; + break; + } + test_format = SDL_NextAudioFormat(); + } + + if (!valid_format) { + XAUDIO2_CloseDevice(this); + SDL_SetError("XAudio2: Unsupported audio format"); + return 0; + } + + /* Update the fragment size as size in bytes */ + SDL_CalculateAudioSpec(&this->spec); + + /* We feed a Source, it feeds the Mastering, which feeds the device. */ + this->hidden->mixlen = this->spec.size; + this->hidden->mixbuf = (Uint8 *) SDL_malloc(2 * this->hidden->mixlen); + if (this->hidden->mixbuf == NULL) { + XAUDIO2_CloseDevice(this); + SDL_OutOfMemory(); + return 0; + } + this->hidden->nextbuf = this->hidden->mixbuf; + SDL_memset(this->hidden->mixbuf, '\0', 2 * this->hidden->mixlen); + + /* We use XAUDIO2_DEFAULT_CHANNELS instead of this->spec.channels. On + Xbox360, this means 5.1 output, but on Windows, it means "figure out + what the system has." It might be preferable to let XAudio2 blast + stereo output to appropriate surround sound configurations + instead of clamping to 2 channels, even though we'll configure the + Source Voice for whatever number of channels you supply. */ + result = IXAudio2_CreateMasteringVoice(ixa2, &this->hidden->mastering, + XAUDIO2_DEFAULT_CHANNELS, + this->spec.freq, 0, devId, NULL); + if (result != S_OK) { + XAUDIO2_CloseDevice(this); + SDL_SetError("XAudio2: Couldn't create mastering voice"); + return 0; + } + + SDL_zero(waveformat); + if (SDL_AUDIO_ISFLOAT(this->spec.format)) { + waveformat.wFormatTag = WAVE_FORMAT_IEEE_FLOAT; + } else { + waveformat.wFormatTag = WAVE_FORMAT_PCM; + } + waveformat.wBitsPerSample = SDL_AUDIO_BITSIZE(this->spec.format); + waveformat.nChannels = this->spec.channels; + waveformat.nSamplesPerSec = this->spec.freq; + waveformat.nBlockAlign = + waveformat.nChannels * (waveformat.wBitsPerSample / 8); + waveformat.nAvgBytesPerSec = + waveformat.nSamplesPerSec * waveformat.nBlockAlign; + + result = IXAudio2_CreateSourceVoice(ixa2, &source, &waveformat, + XAUDIO2_VOICE_NOSRC | + XAUDIO2_VOICE_NOPITCH, + 1.0f, &callbacks, NULL, NULL); + if (result != S_OK) { + XAUDIO2_CloseDevice(this); + SDL_SetError("XAudio2: Couldn't create source voice"); + return 0; + } + this->hidden->source = source; + + /* Start everything playing! */ + result = IXAudio2_StartEngine(ixa2); + if (result != S_OK) { + XAUDIO2_CloseDevice(this); + SDL_SetError("XAudio2: Couldn't start engine"); + return 0; + } + + result = IXAudio2SourceVoice_Start(source, 0, XAUDIO2_COMMIT_NOW); + if (result != S_OK) { + XAUDIO2_CloseDevice(this); + SDL_SetError("XAudio2: Couldn't start source voice"); + return 0; + } + + return 1; /* good to go. */ +} + +static void +XAUDIO2_Deinitialize(void) +{ + WIN_CoUninitialize(); +} + +#endif /* SDL_XAUDIO2_HAS_SDK */ + + +static int +XAUDIO2_Init(SDL_AudioDriverImpl * impl) +{ +#ifndef SDL_XAUDIO2_HAS_SDK + SDL_SetError("XAudio2: SDL was built without XAudio2 support (old DirectX SDK)."); + return 0; /* no XAudio2 support, ever. Update your SDK! */ +#else + /* XAudio2Create() is a macro that uses COM; we don't load the .dll */ + IXAudio2 *ixa2 = NULL; + if (FAILED(WIN_CoInitialize())) { + SDL_SetError("XAudio2: CoInitialize() failed"); + return 0; + } + + if (XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR) != S_OK) { + WIN_CoUninitialize(); + SDL_SetError("XAudio2: XAudio2Create() failed"); + return 0; /* not available. */ + } + IXAudio2_Release(ixa2); + + /* Set the function pointers */ + impl->DetectDevices = XAUDIO2_DetectDevices; + impl->OpenDevice = XAUDIO2_OpenDevice; + impl->PlayDevice = XAUDIO2_PlayDevice; + impl->WaitDevice = XAUDIO2_WaitDevice; + impl->WaitDone = XAUDIO2_WaitDone; + impl->GetDeviceBuf = XAUDIO2_GetDeviceBuf; + impl->CloseDevice = XAUDIO2_CloseDevice; + impl->Deinitialize = XAUDIO2_Deinitialize; + + return 1; /* this audio target is available. */ +#endif +} + +AudioBootStrap XAUDIO2_bootstrap = { + "xaudio2", "XAudio2", XAUDIO2_Init, 0 +}; + +#endif /* SDL_AUDIO_DRIVER_XAUDIO2 */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/core/windows/SDL_windows.c b/project/jni/sdl-1.3/src/core/windows/SDL_windows.c new file mode 100644 index 000000000..a7c4425bb --- /dev/null +++ b/project/jni/sdl-1.3/src/core/windows/SDL_windows.c @@ -0,0 +1,66 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef __WIN32__ + +#include "SDL_error.h" +#include "SDL_windows.h" + +#include /* for CoInitialize/CoUninitialize */ + + +/* Sets an error message based on GetLastError() */ +void +WIN_SetError(const char *prefix) +{ + TCHAR buffer[1024]; + char *message; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, + buffer, SDL_arraysize(buffer), NULL); + message = WIN_StringToUTF8(buffer); + SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message); + SDL_free(message); +} + +HRESULT +WIN_CoInitialize(void) +{ + const HRESULT hr = CoInitialize(NULL); + + /* S_FALSE means success, but someone else already initialized. */ + /* You still need to call CoUninitialize in this case! */ + if (hr == S_FALSE) { + return S_OK; + } + + return hr; +} + +void +WIN_CoUninitialize(void) +{ + CoUninitialize(); +} + +#endif /* __WIN32__ */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/core/windows/SDL_windows.h b/project/jni/sdl-1.3/src/core/windows/SDL_windows.h new file mode 100644 index 000000000..604370ba4 --- /dev/null +++ b/project/jni/sdl-1.3/src/core/windows/SDL_windows.h @@ -0,0 +1,56 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +/* This is an include file for windows.h with the SDL build settings */ + +#ifndef _INCLUDED_WINDOWS_H +#define _INCLUDED_WINDOWS_H + +#define WIN32_LEAN_AND_MEAN +#define STRICT +#ifndef UNICODE +#define UNICODE 1 +#endif +#undef _WIN32_WINNT +#define _WIN32_WINNT 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */ + +#include + + +/* Routines to convert from UTF8 to native Windows text */ +#if UNICODE +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR)) +#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)(S), SDL_strlen(S)+1) +#else +#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1)) +#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1) +#endif + +/* Sets an error message based on GetLastError() */ +extern void WIN_SetError(const char *prefix); + +/* Wrap up the oddities of CoInitialize() into a common function. */ +extern HRESULT WIN_CoInitialize(void); +extern void WIN_CoUninitialize(void); + +#endif /* _INCLUDED_WINDOWS_H */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/cpuinfo/SDL_cpuinfo.c b/project/jni/sdl-1.3/src/cpuinfo/SDL_cpuinfo.c index 7fa382818..379511c3a 100644 --- a/project/jni/sdl-1.3/src/cpuinfo/SDL_cpuinfo.c +++ b/project/jni/sdl-1.3/src/cpuinfo/SDL_cpuinfo.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -39,18 +38,18 @@ #include #endif #ifdef __WIN32__ -#define WIN32_LEAN_AND_MEAN -#include +#include "../core/windows/SDL_windows.h" #endif #define CPU_HAS_RDTSC 0x00000001 -#define CPU_HAS_MMX 0x00000002 -#define CPU_HAS_MMXEXT 0x00000004 -#define CPU_HAS_3DNOW 0x00000010 -#define CPU_HAS_3DNOWEXT 0x00000020 -#define CPU_HAS_SSE 0x00000040 -#define CPU_HAS_SSE2 0x00000080 -#define CPU_HAS_ALTIVEC 0x00000100 +#define CPU_HAS_ALTIVEC 0x00000002 +#define CPU_HAS_MMX 0x00000004 +#define CPU_HAS_3DNOW 0x00000008 +#define CPU_HAS_SSE 0x00000010 +#define CPU_HAS_SSE2 0x00000020 +#define CPU_HAS_SSE3 0x00000040 +#define CPU_HAS_SSE41 0x00000100 +#define CPU_HAS_SSE42 0x00000200 #if SDL_ALTIVEC_BLITTERS && HAVE_SETJMP && !__MACOSX__ /* This is the brute force way of detecting instruction sets... @@ -202,20 +201,6 @@ CPU_getCPUIDFeatures(void) return features; } -static __inline__ int -CPU_getCPUIDFeaturesExt(void) -{ - int features = 0; - int a, b, c, d; - - cpuid(0x80000000, a, b, c, d); - if (a >= 0x80000001) { - cpuid(0x80000001, a, b, c, d); - features = d; - } - return features; -} - static __inline__ int CPU_haveRDTSC(void) { @@ -225,60 +210,6 @@ CPU_haveRDTSC(void) return 0; } -static __inline__ int -CPU_haveMMX(void) -{ - if (CPU_haveCPUID()) { - return (CPU_getCPUIDFeatures() & 0x00800000); - } - return 0; -} - -static __inline__ int -CPU_haveMMXExt(void) -{ - if (CPU_haveCPUID()) { - return (CPU_getCPUIDFeaturesExt() & 0x00400000); - } - return 0; -} - -static __inline__ int -CPU_have3DNow(void) -{ - if (CPU_haveCPUID()) { - return (CPU_getCPUIDFeaturesExt() & 0x80000000); - } - return 0; -} - -static __inline__ int -CPU_have3DNowExt(void) -{ - if (CPU_haveCPUID()) { - return (CPU_getCPUIDFeaturesExt() & 0x40000000); - } - return 0; -} - -static __inline__ int -CPU_haveSSE(void) -{ - if (CPU_haveCPUID()) { - return (CPU_getCPUIDFeatures() & 0x02000000); - } - return 0; -} - -static __inline__ int -CPU_haveSSE2(void) -{ - if (CPU_haveCPUID()) { - return (CPU_getCPUIDFeatures() & 0x04000000); - } - return 0; -} - static __inline__ int CPU_haveAltiVec(void) { @@ -302,10 +233,97 @@ CPU_haveAltiVec(void) return altivec; } +static __inline__ int +CPU_haveMMX(void) +{ + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeatures() & 0x00800000); + } + return 0; +} + +static __inline__ int +CPU_have3DNow(void) +{ + if (CPU_haveCPUID()) { + int a, b, c, d; + + cpuid(0x80000000, a, b, c, d); + if (a >= 0x80000001) { + cpuid(0x80000001, a, b, c, d); + return (d & 0x80000000); + } + } + return 0; +} + +static __inline__ int +CPU_haveSSE(void) +{ + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeatures() & 0x02000000); + } + return 0; +} + +static __inline__ int +CPU_haveSSE2(void) +{ + if (CPU_haveCPUID()) { + return (CPU_getCPUIDFeatures() & 0x04000000); + } + return 0; +} + +static __inline__ int +CPU_haveSSE3(void) +{ + if (CPU_haveCPUID()) { + int a, b, c, d; + + cpuid(0, a, b, c, d); + if (a >= 1) { + cpuid(1, a, b, c, d); + return (c & 0x00000001); + } + } + return 0; +} + +static __inline__ int +CPU_haveSSE41(void) +{ + if (CPU_haveCPUID()) { + int a, b, c, d; + + cpuid(1, a, b, c, d); + if (a >= 1) { + cpuid(1, a, b, c, d); + return (c & 0x00080000); + } + } + return 0; +} + +static __inline__ int +CPU_haveSSE42(void) +{ + if (CPU_haveCPUID()) { + int a, b, c, d; + + cpuid(1, a, b, c, d); + if (a >= 1) { + cpuid(1, a, b, c, d); + return (c & 0x00100000); + } + } + return 0; +} + static int SDL_CPUCount = 0; int -SDL_GetCPUCount() +SDL_GetCPUCount(void) { if (!SDL_CPUCount) { #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN) @@ -336,75 +354,130 @@ SDL_GetCPUCount() /* Oh, such a sweet sweet trick, just not very useful. :) */ static const char * -SDL_GetCPUType() +SDL_GetCPUType(void) { - static char SDL_CPUType[48]; + static char SDL_CPUType[13]; if (!SDL_CPUType[0]) { int i = 0; int a, b, c, d; + if (CPU_haveCPUID()) { + cpuid(0x00000000, a, b, c, d); + SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; + } + if (!SDL_CPUType[0]) { + SDL_strlcpy(SDL_CPUType, "Unknown", sizeof(SDL_CPUType)); + } + } + return SDL_CPUType; +} + + +#ifdef TEST_MAIN /* !!! FIXME: only used for test at the moment. */ +static const char * +SDL_GetCPUName(void) +{ + static char SDL_CPUName[48]; + + if (!SDL_CPUName[0]) { + int i = 0; + int a, b, c, d; + if (CPU_haveCPUID()) { cpuid(0x80000000, a, b, c, d); if (a >= 0x80000004) { cpuid(0x80000002, a, b, c, d); - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; cpuid(0x80000003, a, b, c, d); - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; cpuid(0x80000004, a, b, c, d); - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; - SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; + SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8; } } - if (!SDL_CPUType[0]) { - SDL_strlcpy(SDL_CPUType, "Unknown", sizeof(SDL_CPUType)); + if (!SDL_CPUName[0]) { + SDL_strlcpy(SDL_CPUName, "Unknown", sizeof(SDL_CPUName)); } } - return SDL_CPUType; + return SDL_CPUName; +} +#endif + +int +SDL_GetCPUCacheLineSize(void) +{ + const char *cpuType = SDL_GetCPUType(); + + if (SDL_strcmp(cpuType, "GenuineIntel") == 0) { + int a, b, c, d; + + cpuid(0x00000001, a, b, c, d); + return (((b >> 8) & 0xff) * 8); + } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0) { + int a, b, c, d; + + cpuid(0x80000005, a, b, c, d); + return (c & 0xff); + } else { + /* Just make a guess here... */ + return SDL_CACHELINE_SIZE; + } } static Uint32 SDL_CPUFeatures = 0xFFFFFFFF; @@ -417,26 +490,29 @@ SDL_GetCPUFeatures(void) if (CPU_haveRDTSC()) { SDL_CPUFeatures |= CPU_HAS_RDTSC; } + if (CPU_haveAltiVec()) { + SDL_CPUFeatures |= CPU_HAS_ALTIVEC; + } if (CPU_haveMMX()) { SDL_CPUFeatures |= CPU_HAS_MMX; } - if (CPU_haveMMXExt()) { - SDL_CPUFeatures |= CPU_HAS_MMXEXT; - } if (CPU_have3DNow()) { SDL_CPUFeatures |= CPU_HAS_3DNOW; } - if (CPU_have3DNowExt()) { - SDL_CPUFeatures |= CPU_HAS_3DNOWEXT; - } if (CPU_haveSSE()) { SDL_CPUFeatures |= CPU_HAS_SSE; } if (CPU_haveSSE2()) { SDL_CPUFeatures |= CPU_HAS_SSE2; } - if (CPU_haveAltiVec()) { - SDL_CPUFeatures |= CPU_HAS_ALTIVEC; + if (CPU_haveSSE3()) { + SDL_CPUFeatures |= CPU_HAS_SSE3; + } + if (CPU_haveSSE41()) { + SDL_CPUFeatures |= CPU_HAS_SSE41; + } + if (CPU_haveSSE42()) { + SDL_CPUFeatures |= CPU_HAS_SSE42; } } return SDL_CPUFeatures; @@ -451,6 +527,15 @@ SDL_HasRDTSC(void) return SDL_FALSE; } +SDL_bool +SDL_HasAltiVec(void) +{ + if (SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC) { + return SDL_TRUE; + } + return SDL_FALSE; +} + SDL_bool SDL_HasMMX(void) { @@ -460,15 +545,6 @@ SDL_HasMMX(void) return SDL_FALSE; } -SDL_bool -SDL_HasMMXExt(void) -{ - if (SDL_GetCPUFeatures() & CPU_HAS_MMXEXT) { - return SDL_TRUE; - } - return SDL_FALSE; -} - SDL_bool SDL_Has3DNow(void) { @@ -478,15 +554,6 @@ SDL_Has3DNow(void) return SDL_FALSE; } -SDL_bool -SDL_Has3DNowExt(void) -{ - if (SDL_GetCPUFeatures() & CPU_HAS_3DNOWEXT) { - return SDL_TRUE; - } - return SDL_FALSE; -} - SDL_bool SDL_HasSSE(void) { @@ -506,9 +573,27 @@ SDL_HasSSE2(void) } SDL_bool -SDL_HasAltiVec(void) +SDL_HasSSE3(void) { - if (SDL_GetCPUFeatures() & CPU_HAS_ALTIVEC) { + if (SDL_GetCPUFeatures() & CPU_HAS_SSE3) { + return SDL_TRUE; + } + return SDL_FALSE; +} + +SDL_bool +SDL_HasSSE41(void) +{ + if (SDL_GetCPUFeatures() & CPU_HAS_SSE41) { + return SDL_TRUE; + } + return SDL_FALSE; +} + +SDL_bool +SDL_HasSSE42(void) +{ + if (SDL_GetCPUFeatures() & CPU_HAS_SSE42) { return SDL_TRUE; } return SDL_FALSE; @@ -522,15 +607,18 @@ int main() { printf("CPU count: %d\n", SDL_GetCPUCount()); - printf("CPU name: %s\n", SDL_GetCPUType()); + printf("CPU type: %s\n", SDL_GetCPUType()); + printf("CPU name: %s\n", SDL_GetCPUName()); + printf("CacheLine size: %d\n", SDL_GetCPUCacheLineSize()); printf("RDTSC: %d\n", SDL_HasRDTSC()); + printf("Altivec: %d\n", SDL_HasAltiVec()); printf("MMX: %d\n", SDL_HasMMX()); - printf("MMXExt: %d\n", SDL_HasMMXExt()); printf("3DNow: %d\n", SDL_Has3DNow()); - printf("3DNowExt: %d\n", SDL_Has3DNowExt()); printf("SSE: %d\n", SDL_HasSSE()); printf("SSE2: %d\n", SDL_HasSSE2()); - printf("AltiVec: %d\n", SDL_HasAltiVec()); + printf("SSE3: %d\n", SDL_HasSSE3()); + printf("SSE4.1: %d\n", SDL_HasSSE41()); + printf("SSE4.2: %d\n", SDL_HasSSE42()); return 0; } diff --git a/project/jni/sdl-1.3/src/events/SDL_clipboardevents.c b/project/jni/sdl-1.3/src/events/SDL_clipboardevents.c index 2d5a2c48d..ec3233bb8 100644 --- a/project/jni/sdl-1.3/src/events/SDL_clipboardevents.c +++ b/project/jni/sdl-1.3/src/events/SDL_clipboardevents.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/events/SDL_clipboardevents_c.h b/project/jni/sdl-1.3/src/events/SDL_clipboardevents_c.h index 9e35a5aba..bfdbd473a 100644 --- a/project/jni/sdl-1.3/src/events/SDL_clipboardevents_c.h +++ b/project/jni/sdl-1.3/src/events/SDL_clipboardevents_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/events/SDL_dropevents.c b/project/jni/sdl-1.3/src/events/SDL_dropevents.c new file mode 100644 index 000000000..a84672b44 --- /dev/null +++ b/project/jni/sdl-1.3/src/events/SDL_dropevents.c @@ -0,0 +1,47 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* Drag and drop event handling code for SDL */ + +#include "SDL_events.h" +#include "SDL_events_c.h" +#include "SDL_dropevents_c.h" + + +int +SDL_SendDropFile(const char *file) +{ + int posted; + + /* Post the event, if desired */ + posted = 0; + if (SDL_GetEventState(SDL_DROPFILE) == SDL_ENABLE) { + SDL_Event event; + event.type = SDL_DROPFILE; + event.drop.file = SDL_strdup(file); + + posted = (SDL_PushEvent(&event) > 0); + } + return (posted); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/events/SDL_dropevents_c.h b/project/jni/sdl-1.3/src/events/SDL_dropevents_c.h new file mode 100644 index 000000000..2bbe78dbf --- /dev/null +++ b/project/jni/sdl-1.3/src/events/SDL_dropevents_c.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_dropevents_c_h +#define _SDL_dropevents_c_h + +extern int SDL_SendDropFile(const char *file); + +#endif /* _SDL_dropevents_c_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/events/SDL_events.c b/project/jni/sdl-1.3/src/events/SDL_events.c index 06f533cd2..921c3d9e2 100644 --- a/project/jni/sdl-1.3/src/events/SDL_events.c +++ b/project/jni/sdl-1.3/src/events/SDL_events.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -27,17 +26,25 @@ #include "SDL_events.h" #include "SDL_syswm.h" #include "SDL_thread.h" -#include "SDL_sysevents.h" #include "SDL_events_c.h" #include "../timer/SDL_timer_c.h" #if !SDL_JOYSTICK_DISABLED #include "../joystick/SDL_joystick_c.h" #endif +#include "../video/SDL_sysvideo.h" /* Public data -- the event filter */ SDL_EventFilter SDL_EventOK = NULL; void *SDL_EventOKParam; +typedef struct SDL_EventWatcher { + SDL_EventFilter callback; + void *userdata; + struct SDL_EventWatcher *next; +} SDL_EventWatcher; + +static SDL_EventWatcher *SDL_event_watchers = NULL; + typedef struct { Uint32 bits[8]; } SDL_DisabledEventBlock; @@ -58,36 +65,6 @@ static struct struct SDL_SysWMmsg wmmsg[MAXEVENTS]; } SDL_EventQ; -/* Private data -- event locking structure */ -static struct -{ - SDL_mutex *lock; - int safe; -} SDL_EventLock; - -/* Thread functions */ -static SDL_Thread *SDL_EventThread = NULL; /* Thread handle */ -static SDL_threadID event_thread; /* The event thread id */ - -void -SDL_Lock_EventThread(void) -{ - if (SDL_EventThread && (SDL_ThreadID() != event_thread)) { - /* Grab lock and spin until we're sure event thread stopped */ - SDL_mutexP(SDL_EventLock.lock); - while (!SDL_EventLock.safe) { - SDL_Delay(1); - } - } -} - -void -SDL_Unlock_EventThread(void) -{ - if (SDL_EventThread && (SDL_ThreadID() != event_thread)) { - SDL_mutexV(SDL_EventLock.lock); - } -} static __inline__ SDL_bool SDL_ShouldPollJoystick() @@ -102,112 +79,6 @@ SDL_ShouldPollJoystick() return SDL_FALSE; } -static int SDLCALL -SDL_GobbleEvents(void *unused) -{ - event_thread = SDL_ThreadID(); - - while (SDL_EventQ.active) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - - /* Get events from the video subsystem */ - if (_this) { - _this->PumpEvents(_this); - } -#if !SDL_JOYSTICK_DISABLED - /* Check for joystick state change */ - if (SDL_ShouldPollJoystick()) { - SDL_JoystickUpdate(); - } -#endif - - /* Give up the CPU for the rest of our timeslice */ - SDL_EventLock.safe = 1; - if (SDL_timer_running) { - SDL_ThreadedTimerCheck(); - } - SDL_Delay(1); - - /* Check for event locking. - On the P of the lock mutex, if the lock is held, this thread - will wait until the lock is released before continuing. The - safe flag will be set, meaning that the other thread can go - about it's business. The safe flag is reset before the V, - so as soon as the mutex is free, other threads can see that - it's not safe to interfere with the event thread. - */ - SDL_mutexP(SDL_EventLock.lock); - SDL_EventLock.safe = 0; - SDL_mutexV(SDL_EventLock.lock); - } - SDL_SetTimerThreaded(0); - event_thread = 0; - return (0); -} - -static int -SDL_StartEventThread(Uint32 flags) -{ - /* Reset everything to zero */ - SDL_EventThread = NULL; - SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock)); - - /* Create the lock and set ourselves active */ -#if !SDL_THREADS_DISABLED - SDL_EventQ.lock = SDL_CreateMutex(); - if (SDL_EventQ.lock == NULL) { - return (-1); - } -#endif /* !SDL_THREADS_DISABLED */ - SDL_EventQ.active = 1; - - if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) { - SDL_EventLock.lock = SDL_CreateMutex(); - if (SDL_EventLock.lock == NULL) { - return (-1); - } - SDL_EventLock.safe = 0; - - /* The event thread will handle timers too */ - SDL_SetTimerThreaded(2); -#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) -#undef SDL_CreateThread - SDL_EventThread = - SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL); -#else - SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL); -#endif - if (SDL_EventThread == NULL) { - return (-1); - } - } else { - event_thread = 0; - } - return (0); -} - -static void -SDL_StopEventThread(void) -{ - SDL_EventQ.active = 0; - if (SDL_EventThread) { - SDL_WaitThread(SDL_EventThread, NULL); - SDL_EventThread = NULL; - SDL_DestroyMutex(SDL_EventLock.lock); - SDL_EventLock.lock = NULL; - } - if (SDL_EventQ.lock) { - SDL_DestroyMutex(SDL_EventQ.lock); - SDL_EventQ.lock = NULL; - } -} - -SDL_threadID -SDL_EventThreadID(void) -{ - return (event_thread); -} - /* Public functions */ void @@ -215,13 +86,10 @@ SDL_StopEventLoop(void) { int i; - /* Halt the event thread, if running */ - SDL_StopEventThread(); - - /* Shutdown event handlers */ - SDL_KeyboardQuit(); - SDL_MouseQuit(); - SDL_QuitQuit(); + if (SDL_EventQ.lock) { + SDL_DestroyMutex(SDL_EventQ.lock); + SDL_EventQ.lock = NULL; + } /* Clean out EventQ */ SDL_EventQ.head = 0; @@ -235,39 +103,36 @@ SDL_StopEventLoop(void) SDL_disabled_events[i] = NULL; } } + + while (SDL_event_watchers) { + SDL_EventWatcher *tmp = SDL_event_watchers; + SDL_event_watchers = tmp->next; + SDL_free(tmp); + } } /* This function (and associated calls) may be called more than once */ int -SDL_StartEventLoop(Uint32 flags) +SDL_StartEventLoop(void) { - int retcode; - /* Clean out the event queue */ - SDL_EventThread = NULL; SDL_EventQ.lock = NULL; SDL_StopEventLoop(); /* No filter to start with, process most event types */ SDL_EventOK = NULL; + SDL_EventState(SDL_DROPFILE, SDL_DISABLE); SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE); - /* Initialize event handlers */ - retcode = 0; - retcode += SDL_KeyboardInit(); - retcode += SDL_MouseInit(); - retcode += SDL_TouchInit(); - retcode += SDL_QuitInit(); - if (retcode < 0) { - /* We don't expect them to fail, but... */ + /* Create the lock and set ourselves active */ +#if !SDL_THREADS_DISABLED + SDL_EventQ.lock = SDL_CreateMutex(); + if (SDL_EventQ.lock == NULL) { return (-1); } +#endif /* !SDL_THREADS_DISABLED */ + SDL_EventQ.active = 1; - /* Create the lock and event thread */ - if (SDL_StartEventThread(flags) < 0) { - SDL_StopEventLoop(); - return (-1); - } return (0); } @@ -405,7 +270,12 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType) } /* Make sure the events are current */ +#if 0 + /* Actually, we can't do this since we might be flushing while processing + a resize event, and calling this might trigger further resize events. + */ SDL_PumpEvents(); +#endif /* Lock the event queue */ if (SDL_mutexP(SDL_EventQ.lock) == 0) { @@ -426,20 +296,18 @@ SDL_FlushEvents(Uint32 minType, Uint32 maxType) void SDL_PumpEvents(void) { - if (!SDL_EventThread) { - SDL_VideoDevice *_this = SDL_GetVideoDevice(); + SDL_VideoDevice *_this = SDL_GetVideoDevice(); - /* Get events from the video subsystem */ - if (_this) { - _this->PumpEvents(_this); - } -#if !SDL_JOYSTICK_DISABLED - /* Check for joystick state change */ - if (SDL_ShouldPollJoystick()) { - SDL_JoystickUpdate(); - } -#endif + /* Get events from the video subsystem */ + if (_this) { + _this->PumpEvents(_this); } +#if !SDL_JOYSTICK_DISABLED + /* Check for joystick state change */ + if (SDL_ShouldPollJoystick()) { + SDL_JoystickUpdate(); + } +#endif } /* Public functions */ @@ -489,9 +357,16 @@ SDL_WaitEventTimeout(SDL_Event * event, int timeout) int SDL_PushEvent(SDL_Event * event) { + SDL_EventWatcher *curr; + if (SDL_EventOK && !SDL_EventOK(SDL_EventOKParam, event)) { return 0; } + + for (curr = SDL_event_watchers; curr; curr = curr->next) { + curr->callback(curr->userdata, event); + } + if (SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0, 0) <= 0) { return -1; } @@ -525,6 +400,43 @@ SDL_GetEventFilter(SDL_EventFilter * filter, void **userdata) return SDL_EventOK ? SDL_TRUE : SDL_FALSE; } +/* FIXME: This is not thread-safe yet */ +void +SDL_AddEventWatch(SDL_EventFilter filter, void *userdata) +{ + SDL_EventWatcher *watcher; + + watcher = (SDL_EventWatcher *)SDL_malloc(sizeof(*watcher)); + if (!watcher) { + /* Uh oh... */ + return; + } + watcher->callback = filter; + watcher->userdata = userdata; + watcher->next = SDL_event_watchers; + SDL_event_watchers = watcher; +} + +/* FIXME: This is not thread-safe yet */ +void +SDL_DelEventWatch(SDL_EventFilter filter, void *userdata) +{ + SDL_EventWatcher *prev = NULL; + SDL_EventWatcher *curr; + + for (curr = SDL_event_watchers; curr; prev = curr, curr = curr->next) { + if (curr->callback == filter && curr->userdata == userdata) { + if (prev) { + prev->next = curr->next; + } else { + SDL_event_watchers = curr->next; + } + SDL_free(curr); + break; + } + } +} + void SDL_FilterEvents(SDL_EventFilter filter, void *userdata) { diff --git a/project/jni/sdl-1.3/src/events/SDL_events_c.h b/project/jni/sdl-1.3/src/events/SDL_events_c.h index ccf29b3da..dc936fe01 100644 --- a/project/jni/sdl-1.3/src/events/SDL_events_c.h +++ b/project/jni/sdl-1.3/src/events/SDL_events_c.h @@ -1,43 +1,41 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" /* Useful functions and variables from SDL_events.c */ #include "SDL_events.h" #include "SDL_thread.h" -#include "SDL_mouse_c.h" +#include "SDL_clipboardevents_c.h" +#include "SDL_dropevents_c.h" +#include "SDL_gesture_c.h" #include "SDL_keyboard_c.h" +#include "SDL_mouse_c.h" #include "SDL_touch_c.h" #include "SDL_windowevents_c.h" -#include "SDL_gesture_c.h" + /* Start and stop the event processing loop */ -extern int SDL_StartEventLoop(Uint32 flags); +extern int SDL_StartEventLoop(void); extern void SDL_StopEventLoop(void); extern void SDL_QuitInterrupt(void); -extern void SDL_Lock_EventThread(void); -extern void SDL_Unlock_EventThread(void); -extern SDL_threadID SDL_EventThreadID(void); - extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message); extern int SDL_QuitInit(void); diff --git a/project/jni/sdl-1.3/src/events/SDL_gesture.c b/project/jni/sdl-1.3/src/events/SDL_gesture.c index 7cf6cfde3..26732a198 100644 --- a/project/jni/sdl-1.3/src/events/SDL_gesture.c +++ b/project/jni/sdl-1.3/src/events/SDL_gesture.c @@ -1,22 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software Founation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -36,7 +36,7 @@ #define MAXPATHSIZE 1024 - + #define DOLLARNPOINTS 64 @@ -44,35 +44,35 @@ #define ENABLE_DOLLAR -#define PHI 0.618033989 +#define PHI 0.618033989 typedef struct { - float x,y; + float x,y; } SDL_FloatPoint; typedef struct { - float length; - - int numPoints; - SDL_FloatPoint p[MAXPATHSIZE]; + float length; + + int numPoints; + SDL_FloatPoint p[MAXPATHSIZE]; } SDL_DollarPath; typedef struct { - SDL_FloatPoint path[DOLLARNPOINTS]; - unsigned long hash; + SDL_FloatPoint path[DOLLARNPOINTS]; + unsigned long hash; } SDL_DollarTemplate; typedef struct { - SDL_GestureID id; - SDL_FloatPoint res; - SDL_FloatPoint centroid; - SDL_DollarPath dollarPath; - Uint16 numDownFingers; + SDL_TouchID id; + SDL_FloatPoint res; + SDL_FloatPoint centroid; + SDL_DollarPath dollarPath; + Uint16 numDownFingers; - int numDollarTemplates; - SDL_DollarTemplate *dollarTemplate; + int numDollarTemplates; + SDL_DollarTemplate *dollarTemplate; - SDL_bool recording; + SDL_bool recording; } SDL_GestureTouch; SDL_GestureTouch *SDL_gestureTouch; @@ -80,585 +80,584 @@ int SDL_numGestureTouches = 0; SDL_bool recordAll; #if 0 -static void PrintPath(SDL_FloatPoint *path) { - int i; - printf("Path:"); - for(i=0;i= 0) - return 1; - } - } - return (touchId < 0); -} - -unsigned long SDL_HashDollar(SDL_FloatPoint* points) { - unsigned long hash = 5381; - int i; - for(i = 0;i < DOLLARNPOINTS; i++) { - hash = ((hash<<5) + hash) + (unsigned long)points[i].x; - hash = ((hash<<5) + hash) + (unsigned long)points[i].y; - } - return hash; -} - - -static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) { - if(src == NULL) return 0; - - - //No Longer storing the Hash, rehash on load - //if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; - - if(SDL_RWwrite(src,templ->path, - sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) - return 0; - - return 1; -} - - -int SDL_SaveAllDollarTemplates(SDL_RWops *src) { - int i,j,rtrn = 0; - for(i = 0; i < SDL_numGestureTouches; i++) { - SDL_GestureTouch* touch = &SDL_gestureTouch[i]; - for(j = 0;j < touch->numDollarTemplates; j++) { - rtrn += SaveTemplate(&touch->dollarTemplate[i],src); +int SDL_RecordGesture(SDL_TouchID touchId) +{ + int i; + if (touchId < 0) recordAll = SDL_TRUE; + for (i = 0; i < SDL_numGestureTouches; i++) { + if ((touchId < 0) || (SDL_gestureTouch[i].id == touchId)) { + SDL_gestureTouch[i].recording = SDL_TRUE; + if (touchId >= 0) + return 1; + } } - } - return rtrn; + return (touchId < 0); } -int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) { - int i,j; - for(i = 0; i < SDL_numGestureTouches; i++) { - SDL_GestureTouch* touch = &SDL_gestureTouch[i]; - for(j = 0;j < touch->numDollarTemplates; j++) { - if(touch->dollarTemplate[i].hash == gestureId) { - return SaveTemplate(&touch->dollarTemplate[i],src); - } +static unsigned long SDL_HashDollar(SDL_FloatPoint* points) +{ + unsigned long hash = 5381; + int i; + for (i = 0; i < DOLLARNPOINTS; i++) { + hash = ((hash<<5) + hash) + (unsigned long)points[i].x; + hash = ((hash<<5) + hash) + (unsigned long)points[i].y; } - } - SDL_SetError("Unknown gestureId"); - return -1; + return hash; +} + + +static int SaveTemplate(SDL_DollarTemplate *templ, SDL_RWops * src) +{ + if (src == NULL) return 0; + + + //No Longer storing the Hash, rehash on load + //if(SDL_RWops.write(src,&(templ->hash),sizeof(templ->hash),1) != 1) return 0; + + if (SDL_RWwrite(src,templ->path, + sizeof(templ->path[0]),DOLLARNPOINTS) != DOLLARNPOINTS) + return 0; + + return 1; +} + + +int SDL_SaveAllDollarTemplates(SDL_RWops *src) +{ + int i,j,rtrn = 0; + for (i = 0; i < SDL_numGestureTouches; i++) { + SDL_GestureTouch* touch = &SDL_gestureTouch[i]; + for (j = 0; j < touch->numDollarTemplates; j++) { + rtrn += SaveTemplate(&touch->dollarTemplate[i],src); + } + } + return rtrn; +} + +int SDL_SaveDollarTemplate(SDL_GestureID gestureId, SDL_RWops *src) +{ + int i,j; + for (i = 0; i < SDL_numGestureTouches; i++) { + SDL_GestureTouch* touch = &SDL_gestureTouch[i]; + for (j = 0; j < touch->numDollarTemplates; j++) { + if (touch->dollarTemplate[i].hash == gestureId) { + return SaveTemplate(&touch->dollarTemplate[i],src); + } + } + } + SDL_SetError("Unknown gestureId"); + return -1; } //path is an already sampled set of points //Returns the index of the gesture on success, or -1 -static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch,SDL_FloatPoint* path) { - SDL_DollarTemplate* dollarTemplate; - SDL_DollarTemplate *templ; - int i = 0; - if(inTouch == NULL) { - if(SDL_numGestureTouches == 0) return -1; - for(i = 0;i < SDL_numGestureTouches; i++) { - inTouch = &SDL_gestureTouch[i]; +static int SDL_AddDollarGesture_one(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) +{ + SDL_DollarTemplate* dollarTemplate; + SDL_DollarTemplate *templ; + int index; - dollarTemplate = + index = inTouch->numDollarTemplates; + dollarTemplate = (SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate, - (inTouch->numDollarTemplates + 1) * - sizeof(SDL_DollarTemplate)); - if(!dollarTemplate) { + (index + 1) * + sizeof(SDL_DollarTemplate)); + if (!dollarTemplate) { SDL_OutOfMemory(); return -1; - } - - inTouch->dollarTemplate = dollarTemplate; - - templ = - &inTouch->dollarTemplate[inTouch->numDollarTemplates]; - SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint)); - templ->hash = SDL_HashDollar(templ->path); - inTouch->numDollarTemplates++; } - return inTouch->numDollarTemplates - 1; - } else { - SDL_DollarTemplate* dollarTemplate = - ( SDL_DollarTemplate *)SDL_realloc(inTouch->dollarTemplate, - (inTouch->numDollarTemplates + 1) * - sizeof(SDL_DollarTemplate)); - if(!dollarTemplate) { - SDL_OutOfMemory(); - return -1; - } - inTouch->dollarTemplate = dollarTemplate; - templ = - &inTouch->dollarTemplate[inTouch->numDollarTemplates]; - SDL_memcpy(templ->path,path,DOLLARNPOINTS*sizeof(SDL_FloatPoint)); + templ = &inTouch->dollarTemplate[index]; + SDL_memcpy(templ->path, path, DOLLARNPOINTS*sizeof(SDL_FloatPoint)); templ->hash = SDL_HashDollar(templ->path); inTouch->numDollarTemplates++; - return inTouch->numDollarTemplates - 1; - } - return -1; + + return index; } -int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) { - int i,loaded = 0; - SDL_GestureTouch *touch = NULL; - if(src == NULL) return 0; - if(touchId >= 0) { - for(i = 0;i < SDL_numGestureTouches; i++) - if(SDL_gestureTouch[i].id == touchId) - touch = &SDL_gestureTouch[i]; - if(touch == NULL) return -1; - } - - while(1) { - SDL_DollarTemplate templ; - - if(SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < - DOLLARNPOINTS) break; - - if(touchId >= 0) { - //printf("Adding loaded gesture to 1 touch\n"); - if(SDL_AddDollarGesture(touch,templ.path)) loaded++; +static int SDL_AddDollarGesture(SDL_GestureTouch* inTouch, SDL_FloatPoint* path) +{ + int index = -1; + int i = 0; + if (inTouch == NULL) { + if (SDL_numGestureTouches == 0) return -1; + for (i = 0; i < SDL_numGestureTouches; i++) { + inTouch = &SDL_gestureTouch[i]; + index = SDL_AddDollarGesture_one(inTouch, path); + if (index < 0) + return -1; + } + // Use the index of the last one added. + return index; + } else { + return SDL_AddDollarGesture_one(inTouch, path); } - else { - //printf("Adding to: %i touches\n",SDL_numGestureTouches); - for(i = 0;i < SDL_numGestureTouches; i++) { - touch = &SDL_gestureTouch[i]; - //printf("Adding loaded gesture to + touches\n"); - //TODO: What if this fails? - SDL_AddDollarGesture(touch,templ.path); - } - loaded++; - } - } + return -1; +} - return loaded; +int SDL_LoadDollarTemplates(SDL_TouchID touchId, SDL_RWops *src) +{ + int i,loaded = 0; + SDL_GestureTouch *touch = NULL; + if (src == NULL) return 0; + if (touchId >= 0) { + for (i = 0; i < SDL_numGestureTouches; i++) + if (SDL_gestureTouch[i].id == touchId) + touch = &SDL_gestureTouch[i]; + if (touch == NULL) return -1; + } + + while (1) { + SDL_DollarTemplate templ; + + if (SDL_RWread(src,templ.path,sizeof(templ.path[0]),DOLLARNPOINTS) < + DOLLARNPOINTS) break; + + if (touchId >= 0) { + //printf("Adding loaded gesture to 1 touch\n"); + if (SDL_AddDollarGesture(touch, templ.path) >= 0) + loaded++; + } + else { + //printf("Adding to: %i touches\n",SDL_numGestureTouches); + for (i = 0; i < SDL_numGestureTouches; i++) { + touch = &SDL_gestureTouch[i]; + //printf("Adding loaded gesture to + touches\n"); + //TODO: What if this fails? + SDL_AddDollarGesture(touch,templ.path); + } + loaded++; + } + } + + return loaded; } -float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) { - // SDL_FloatPoint p[DOLLARNPOINTS]; - float dist = 0; - SDL_FloatPoint p; - int i; - for(i = 0; i < DOLLARNPOINTS; i++) { - p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang)); - p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang)); - dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+ - (p.y-templ[i].y)*(p.y-templ[i].y))); - } - return dist/DOLLARNPOINTS; - +static float dollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ,float ang) +{ + // SDL_FloatPoint p[DOLLARNPOINTS]; + float dist = 0; + SDL_FloatPoint p; + int i; + for (i = 0; i < DOLLARNPOINTS; i++) { + p.x = (float)(points[i].x * SDL_cos(ang) - points[i].y * SDL_sin(ang)); + p.y = (float)(points[i].x * SDL_sin(ang) + points[i].y * SDL_cos(ang)); + dist += (float)(SDL_sqrt((p.x-templ[i].x)*(p.x-templ[i].x)+ + (p.y-templ[i].y)*(p.y-templ[i].y))); + } + return dist/DOLLARNPOINTS; + } -float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) { - //------------BEGIN DOLLAR BLACKBOX----------------// - //-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-// - //-"http://depts.washington.edu/aimgroup/proj/dollar/"-// - double ta = -M_PI/4; - double tb = M_PI/4; - double dt = M_PI/90; - float x1 = (float)(PHI*ta + (1-PHI)*tb); - float f1 = dollarDifference(points,templ,x1); - float x2 = (float)((1-PHI)*ta + PHI*tb); - float f2 = dollarDifference(points,templ,x2); - while(SDL_fabs(ta-tb) > dt) { - if(f1 < f2) { - tb = x2; - x2 = x1; - f2 = f1; - x1 = (float)(PHI*ta + (1-PHI)*tb); - f1 = dollarDifference(points,templ,x1); +static float bestDollarDifference(SDL_FloatPoint* points,SDL_FloatPoint* templ) +{ + //------------BEGIN DOLLAR BLACKBOX----------------// + //-TRANSLATED DIRECTLY FROM PSUDEO-CODE AVAILABLE AT-// + //-"http://depts.washington.edu/aimgroup/proj/dollar/"-// + double ta = -M_PI/4; + double tb = M_PI/4; + double dt = M_PI/90; + float x1 = (float)(PHI*ta + (1-PHI)*tb); + float f1 = dollarDifference(points,templ,x1); + float x2 = (float)((1-PHI)*ta + PHI*tb); + float f2 = dollarDifference(points,templ,x2); + while (SDL_fabs(ta-tb) > dt) { + if (f1 < f2) { + tb = x2; + x2 = x1; + f2 = f1; + x1 = (float)(PHI*ta + (1-PHI)*tb); + f1 = dollarDifference(points,templ,x1); + } + else { + ta = x1; + x1 = x2; + f1 = f2; + x2 = (float)((1-PHI)*ta + PHI*tb); + f2 = dollarDifference(points,templ,x2); + } } - else { - ta = x1; - x1 = x2; - f1 = f2; - x2 = (float)((1-PHI)*ta + PHI*tb); - f2 = dollarDifference(points,templ,x2); - } - } - /* - if(f1 <= f2) - printf("Min angle (x1): %f\n",x1); - else if(f1 > f2) - printf("Min angle (x2): %f\n",x2); - */ - return SDL_min(f1,f2); + /* + if (f1 <= f2) + printf("Min angle (x1): %f\n",x1); + else if (f1 > f2) + printf("Min angle (x2): %f\n",x2); + */ + return SDL_min(f1,f2); } //DollarPath contains raw points, plus (possibly) the calculated length -int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) { - int i; - float interval; - float dist; - int numPoints = 0; - SDL_FloatPoint centroid; - float xmin,xmax,ymin,ymax; - float ang; - float w,h; - float length = path->length; +static int dollarNormalize(const SDL_DollarPath *path,SDL_FloatPoint *points) +{ + int i; + float interval; + float dist; + int numPoints = 0; + SDL_FloatPoint centroid; + float xmin,xmax,ymin,ymax; + float ang; + float w,h; + float length = path->length; - //Calculate length if it hasn't already been done - if(length <= 0) { - for(i=1;inumPoints;i++) { - float dx = path->p[i ].x - - path->p[i-1].x; - float dy = path->p[i ].y - - path->p[i-1].y; - length += (float)(SDL_sqrt(dx*dx+dy*dy)); - } - } - - //Resample - interval = length/(DOLLARNPOINTS - 1); - dist = interval; - - centroid.x = 0;centroid.y = 0; - - //printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); - for(i = 1;i < path->numPoints;i++) { - float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ - (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); - //printf("d = %f dist = %f/%f\n",d,dist,interval); - while(dist + d > interval) { - points[numPoints].x = path->p[i-1].x + - ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); - points[numPoints].y = path->p[i-1].y + - ((interval-dist)/d)*(path->p[i].y-path->p[i-1].y); - centroid.x += points[numPoints].x; - centroid.y += points[numPoints].y; - numPoints++; - - dist -= interval; - } - dist += d; - } - if(numPoints < DOLLARNPOINTS-1) { - SDL_SetError("ERROR: NumPoints = %i\n",numPoints); - return 0; - } - //copy the last point - points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; - numPoints = DOLLARNPOINTS; - - centroid.x /= numPoints; - centroid.y /= numPoints; - - //printf("Centroid (%f,%f)",centroid.x,centroid.y); - //Rotate Points so point 0 is left of centroid and solve for the bounding box - xmin = centroid.x; - xmax = centroid.x; - ymin = centroid.y; - ymax = centroid.y; - - ang = (float)(SDL_atan2(centroid.y - points[0].y, - centroid.x - points[0].x)); - - for(i = 0;i xmax) xmax = points[i].x; - if(points[i].y < ymin) ymin = points[i].y; - if(points[i].y > ymax) ymax = points[i].y; - } - - //Scale points to DOLLARSIZE, and translate to the origin - w = xmax-xmin; - h = ymax-ymin; - - for(i=0;inumDollarTemplates;i++) { - float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); - if(diff < bestDiff) {bestDiff = diff; *bestTempl = i;} + //Calculate length if it hasn't already been done + if (length <= 0) { + for (i=1;i < path->numPoints; i++) { + float dx = path->p[i ].x - path->p[i-1].x; + float dy = path->p[i ].y - path->p[i-1].y; + length += (float)(SDL_sqrt(dx*dx+dy*dy)); } - return bestDiff; -} - -int SDL_GestureAddTouch(SDL_Touch* touch) { - SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch, - (SDL_numGestureTouches + 1) * - sizeof(SDL_GestureTouch)); - - if(!gestureTouch) { - SDL_OutOfMemory(); - return -1; - } - - SDL_gestureTouch = gestureTouch; - - SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres; - SDL_gestureTouch[SDL_numGestureTouches].res.y = touch->yres; - SDL_gestureTouch[SDL_numGestureTouches].numDownFingers = 0; - - SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres; - SDL_gestureTouch[SDL_numGestureTouches].id = touch->id; - - SDL_gestureTouch[SDL_numGestureTouches].numDollarTemplates = 0; - - SDL_gestureTouch[SDL_numGestureTouches].recording = SDL_FALSE; - - SDL_numGestureTouches++; - return 0; -} - -int SDL_GestureRemoveTouch(SDL_TouchID id) { - int i; - for (i = 0; i < SDL_numGestureTouches; i++) { - if (SDL_gestureTouch[i].id == id) { - SDL_numGestureTouches--; - SDL_memcpy(&SDL_gestureTouch[i], &SDL_gestureTouch[SDL_numGestureTouches], sizeof(SDL_gestureTouch[i])); - return 1; } - } - return -1; + + //Resample + interval = length/(DOLLARNPOINTS - 1); + dist = interval; + + centroid.x = 0;centroid.y = 0; + + //printf("(%f,%f)\n",path->p[path->numPoints-1].x,path->p[path->numPoints-1].y); + for (i = 1; i < path->numPoints; i++) { + float d = (float)(SDL_sqrt((path->p[i-1].x-path->p[i].x)*(path->p[i-1].x-path->p[i].x)+ + (path->p[i-1].y-path->p[i].y)*(path->p[i-1].y-path->p[i].y))); + //printf("d = %f dist = %f/%f\n",d,dist,interval); + while (dist + d > interval) { + points[numPoints].x = path->p[i-1].x + + ((interval-dist)/d)*(path->p[i].x-path->p[i-1].x); + points[numPoints].y = path->p[i-1].y + + ((interval-dist)/d)*(path->p[i].y-path->p[i-1].y); + centroid.x += points[numPoints].x; + centroid.y += points[numPoints].y; + numPoints++; + + dist -= interval; + } + dist += d; + } + if (numPoints < DOLLARNPOINTS-1) { + SDL_SetError("ERROR: NumPoints = %i\n",numPoints); + return 0; + } + //copy the last point + points[DOLLARNPOINTS-1] = path->p[path->numPoints-1]; + numPoints = DOLLARNPOINTS; + + centroid.x /= numPoints; + centroid.y /= numPoints; + + //printf("Centroid (%f,%f)",centroid.x,centroid.y); + //Rotate Points so point 0 is left of centroid and solve for the bounding box + xmin = centroid.x; + xmax = centroid.x; + ymin = centroid.y; + ymax = centroid.y; + + ang = (float)(SDL_atan2(centroid.y - points[0].y, + centroid.x - points[0].x)); + + for (i = 0; i xmax) xmax = points[i].x; + if (points[i].y < ymin) ymin = points[i].y; + if (points[i].y > ymax) ymax = points[i].y; + } + + //Scale points to DOLLARSIZE, and translate to the origin + w = xmax-xmin; + h = ymax-ymin; + + for (i=0; inumDollarTemplates; i++) { + float diff = bestDollarDifference(points,touch->dollarTemplate[i].path); + if (diff < bestDiff) {bestDiff = diff; *bestTempl = i;} + } + return bestDiff; } -int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) { - SDL_Event event; - event.mgesture.type = SDL_MULTIGESTURE; - event.mgesture.touchId = touch->id; - event.mgesture.x = touch->centroid.x; - event.mgesture.y = touch->centroid.y; - event.mgesture.dTheta = dTheta; - event.mgesture.dDist = dDist; - event.mgesture.numFingers = touch->numDownFingers; - return SDL_PushEvent(&event) > 0; +int SDL_GestureAddTouch(SDL_Touch* touch) +{ + SDL_GestureTouch *gestureTouch = (SDL_GestureTouch *)SDL_realloc(SDL_gestureTouch, + (SDL_numGestureTouches + 1) * + sizeof(SDL_GestureTouch)); + + if (!gestureTouch) { + SDL_OutOfMemory(); + return -1; + } + + SDL_gestureTouch = gestureTouch; + + SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres; + SDL_gestureTouch[SDL_numGestureTouches].res.y = touch->yres; + SDL_gestureTouch[SDL_numGestureTouches].numDownFingers = 0; + + SDL_gestureTouch[SDL_numGestureTouches].res.x = touch->xres; + SDL_gestureTouch[SDL_numGestureTouches].id = touch->id; + + SDL_gestureTouch[SDL_numGestureTouches].numDollarTemplates = 0; + + SDL_gestureTouch[SDL_numGestureTouches].recording = SDL_FALSE; + + SDL_numGestureTouches++; + return 0; } -int SDL_SendGestureDollar(SDL_GestureTouch* touch, - SDL_GestureID gestureId,float error) { - SDL_Event event; - event.dgesture.type = SDL_DOLLARGESTURE; - event.dgesture.touchId = touch->id; - /* +static SDL_GestureTouch * SDL_GetGestureTouch(SDL_TouchID id) +{ + int i; + for (i = 0; i < SDL_numGestureTouches; i++) { + //printf("%i ?= %i\n",SDL_gestureTouch[i].id,id); + if (SDL_gestureTouch[i].id == id) + return &SDL_gestureTouch[i]; + } + return NULL; +} + +int SDL_SendGestureMulti(SDL_GestureTouch* touch,float dTheta,float dDist) +{ + SDL_Event event; + event.mgesture.type = SDL_MULTIGESTURE; + event.mgesture.touchId = touch->id; + event.mgesture.x = touch->centroid.x; + event.mgesture.y = touch->centroid.y; + event.mgesture.dTheta = dTheta; + event.mgesture.dDist = dDist; + event.mgesture.numFingers = touch->numDownFingers; + return SDL_PushEvent(&event) > 0; +} + +static int SDL_SendGestureDollar(SDL_GestureTouch* touch, + SDL_GestureID gestureId,float error) +{ + SDL_Event event; + event.dgesture.type = SDL_DOLLARGESTURE; + event.dgesture.touchId = touch->id; + /* //TODO: Add this to give location of gesture? - event.mgesture.x = touch->centroid.x; - event.mgesture.y = touch->centroid.y; - */ - event.dgesture.gestureId = gestureId; - event.dgesture.error = error; - //A finger came up to trigger this event. - event.dgesture.numFingers = touch->numDownFingers + 1; - return SDL_PushEvent(&event) > 0; + event.mgesture.x = touch->centroid.x; + event.mgesture.y = touch->centroid.y; + */ + event.dgesture.gestureId = gestureId; + event.dgesture.error = error; + //A finger came up to trigger this event. + event.dgesture.numFingers = touch->numDownFingers + 1; + return SDL_PushEvent(&event) > 0; } -int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) { - SDL_Event event; - event.dgesture.type = SDL_DOLLARRECORD; - event.dgesture.touchId = touch->id; - event.dgesture.gestureId = gestureId; - return SDL_PushEvent(&event) > 0; +static int SDL_SendDollarRecord(SDL_GestureTouch* touch,SDL_GestureID gestureId) +{ + SDL_Event event; + event.dgesture.type = SDL_DOLLARRECORD; + event.dgesture.touchId = touch->id; + event.dgesture.gestureId = gestureId; + return SDL_PushEvent(&event) > 0; } void SDL_GestureProcessEvent(SDL_Event* event) { - float x,y; - SDL_FloatPoint path[DOLLARNPOINTS]; - int index; - int i; - float pathDx, pathDy; - SDL_FloatPoint lastP; - SDL_FloatPoint lastCentroid; - float lDist; - float Dist; - float dtheta; - float dDist; + float x,y; + SDL_FloatPoint path[DOLLARNPOINTS]; + int index; + int i; + float pathDx, pathDy; + SDL_FloatPoint lastP; + SDL_FloatPoint lastCentroid; + float lDist; + float Dist; + float dtheta; + float dDist; - if(event->type == SDL_FINGERMOTION || - event->type == SDL_FINGERDOWN || - event->type == SDL_FINGERUP) { - SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); - - //Shouldn't be possible - if(inTouch == NULL) return; - - //printf("@ (%i,%i) with res: (%i,%i)\n",(int)event->tfinger.x, - // (int)event->tfinger.y, - // (int)inTouch->res.x,(int)inTouch->res.y); + if (event->type == SDL_FINGERMOTION || + event->type == SDL_FINGERDOWN || + event->type == SDL_FINGERUP) { + SDL_GestureTouch* inTouch = SDL_GetGestureTouch(event->tfinger.touchId); - - x = ((float)event->tfinger.x)/(float)inTouch->res.x; - y = ((float)event->tfinger.y)/(float)inTouch->res.y; + //Shouldn't be possible + if (inTouch == NULL) return; + + //printf("@ (%i,%i) with res: (%i,%i)\n",(int)event->tfinger.x, + // (int)event->tfinger.y, + // (int)inTouch->res.x,(int)inTouch->res.y); - //Finger Up - if(event->type == SDL_FINGERUP) { - inTouch->numDownFingers--; - + x = ((float)event->tfinger.x)/(float)inTouch->res.x; + y = ((float)event->tfinger.y)/(float)inTouch->res.y; + + + //Finger Up + if (event->type == SDL_FINGERUP) { + inTouch->numDownFingers--; + #ifdef ENABLE_DOLLAR - if(inTouch->recording) { - inTouch->recording = SDL_FALSE; - dollarNormalize(&inTouch->dollarPath,path); - //PrintPath(path); - if(recordAll) { - index = SDL_AddDollarGesture(NULL,path); - for(i = 0;i < SDL_numGestureTouches; i++) - SDL_gestureTouch[i].recording = SDL_FALSE; - } - else { - index = SDL_AddDollarGesture(inTouch,path); - } - - if(index >= 0) { - SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash); - } - else { - SDL_SendDollarRecord(inTouch,-1); - } - } - else { - int bestTempl; - float error; - error = dollarRecognize(&inTouch->dollarPath, - &bestTempl,inTouch); - if(bestTempl >= 0){ - //Send Event - unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; - SDL_SendGestureDollar(inTouch,gestureId,error); - //printf ("%s\n",);("Dollar error: %f\n",error); - } - } -#endif - //inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; - if(inTouch->numDownFingers > 0) { - inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- - x)/inTouch->numDownFingers; - inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)- - y)/inTouch->numDownFingers; - } - } - else if(event->type == SDL_FINGERMOTION) { - float dx = ((float)event->tfinger.dx)/(float)inTouch->res.x; - float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y; - //printf("dx,dy: (%f,%f)\n",dx,dy); -#ifdef ENABLE_DOLLAR - SDL_DollarPath* path = &inTouch->dollarPath; - if(path->numPoints < MAXPATHSIZE) { - path->p[path->numPoints].x = inTouch->centroid.x; - path->p[path->numPoints].y = inTouch->centroid.y; - pathDx = - (path->p[path->numPoints].x-path->p[path->numPoints-1].x); - pathDy = - (path->p[path->numPoints].y-path->p[path->numPoints-1].y); - path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy); - path->numPoints++; - } + if (inTouch->recording) { + inTouch->recording = SDL_FALSE; + dollarNormalize(&inTouch->dollarPath,path); + //PrintPath(path); + if (recordAll) { + index = SDL_AddDollarGesture(NULL,path); + for (i = 0; i < SDL_numGestureTouches; i++) + SDL_gestureTouch[i].recording = SDL_FALSE; + } + else { + index = SDL_AddDollarGesture(inTouch,path); + } + + if (index >= 0) { + SDL_SendDollarRecord(inTouch,inTouch->dollarTemplate[index].hash); + } + else { + SDL_SendDollarRecord(inTouch,-1); + } + } + else { + int bestTempl; + float error; + error = dollarRecognize(&inTouch->dollarPath, + &bestTempl,inTouch); + if (bestTempl >= 0){ + //Send Event + unsigned long gestureId = inTouch->dollarTemplate[bestTempl].hash; + SDL_SendGestureDollar(inTouch,gestureId,error); + //printf ("%s\n",);("Dollar error: %f\n",error); + } + } #endif - lastP.x = x - dx; - lastP.y = y - dy; - lastCentroid = inTouch->centroid; - - inTouch->centroid.x += dx/inTouch->numDownFingers; - inTouch->centroid.y += dy/inTouch->numDownFingers; - //printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); - if(inTouch->numDownFingers > 1) { - SDL_FloatPoint lv; //Vector from centroid to last x,y position - SDL_FloatPoint v; //Vector from centroid to current x,y position - //lv = inTouch->gestureLast[j].cv; - lv.x = lastP.x - lastCentroid.x; - lv.y = lastP.y - lastCentroid.y; - lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); - //printf("lDist = %f\n",lDist); - v.x = x - inTouch->centroid.x; - v.y = y - inTouch->centroid.y; - //inTouch->gestureLast[j].cv = v; - Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); - // SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) - - //Normalize Vectors to simplify angle calculation - lv.x/=lDist; - lv.y/=lDist; - v.x/=Dist; - v.y/=Dist; - dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); - - dDist = (Dist - lDist); - if(lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values - - //inTouch->gestureLast[j].dDist = dDist; - //inTouch->gestureLast[j].dtheta = dtheta; - - //printf("dDist = %f, dTheta = %f\n",dDist,dtheta); - //gdtheta = gdtheta*.9 + dtheta*.1; - //gdDist = gdDist*.9 + dDist*.1 - //knob.r += dDist/numDownFingers; - //knob.ang += dtheta; - //printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); - //printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); - SDL_SendGestureMulti(inTouch,dtheta,dDist); - } - else { - //inTouch->gestureLast[j].dDist = 0; - //inTouch->gestureLast[j].dtheta = 0; - //inTouch->gestureLast[j].cv.x = 0; - //inTouch->gestureLast[j].cv.y = 0; - } - //inTouch->gestureLast[j].f.p.x = x; - //inTouch->gestureLast[j].f.p.y = y; - //break; - //pressure? - } - - if(event->type == SDL_FINGERDOWN) { + //inTouch->gestureLast[j] = inTouch->gestureLast[inTouch->numDownFingers]; + if (inTouch->numDownFingers > 0) { + inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers+1)- + x)/inTouch->numDownFingers; + inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers+1)- + y)/inTouch->numDownFingers; + } + } + else if (event->type == SDL_FINGERMOTION) { + float dx = ((float)event->tfinger.dx)/(float)inTouch->res.x; + float dy = ((float)event->tfinger.dy)/(float)inTouch->res.y; + //printf("dx,dy: (%f,%f)\n",dx,dy); +#ifdef ENABLE_DOLLAR + SDL_DollarPath* path = &inTouch->dollarPath; + if (path->numPoints < MAXPATHSIZE) { + path->p[path->numPoints].x = inTouch->centroid.x; + path->p[path->numPoints].y = inTouch->centroid.y; + pathDx = + (path->p[path->numPoints].x-path->p[path->numPoints-1].x); + pathDy = + (path->p[path->numPoints].y-path->p[path->numPoints-1].y); + path->length += (float)SDL_sqrt(pathDx*pathDx + pathDy*pathDy); + path->numPoints++; + } +#endif + lastP.x = x - dx; + lastP.y = y - dy; + lastCentroid = inTouch->centroid; - inTouch->numDownFingers++; - inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+ - x)/inTouch->numDownFingers; - inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ - y)/inTouch->numDownFingers; - //printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, - // inTouch->centroid.x,inTouch->centroid.y); + inTouch->centroid.x += dx/inTouch->numDownFingers; + inTouch->centroid.y += dy/inTouch->numDownFingers; + //printf("Centrid : (%f,%f)\n",inTouch->centroid.x,inTouch->centroid.y); + if (inTouch->numDownFingers > 1) { + SDL_FloatPoint lv; //Vector from centroid to last x,y position + SDL_FloatPoint v; //Vector from centroid to current x,y position + //lv = inTouch->gestureLast[j].cv; + lv.x = lastP.x - lastCentroid.x; + lv.y = lastP.y - lastCentroid.y; + lDist = (float)SDL_sqrt(lv.x*lv.x + lv.y*lv.y); + //printf("lDist = %f\n",lDist); + v.x = x - inTouch->centroid.x; + v.y = y - inTouch->centroid.y; + //inTouch->gestureLast[j].cv = v; + Dist = (float)SDL_sqrt(v.x*v.x+v.y*v.y); + // SDL_cos(dTheta) = (v . lv)/(|v| * |lv|) + + //Normalize Vectors to simplify angle calculation + lv.x/=lDist; + lv.y/=lDist; + v.x/=Dist; + v.y/=Dist; + dtheta = (float)SDL_atan2(lv.x*v.y - lv.y*v.x,lv.x*v.x + lv.y*v.y); + + dDist = (Dist - lDist); + if (lDist == 0) {dDist = 0;dtheta = 0;} //To avoid impossible values + + //inTouch->gestureLast[j].dDist = dDist; + //inTouch->gestureLast[j].dtheta = dtheta; + + //printf("dDist = %f, dTheta = %f\n",dDist,dtheta); + //gdtheta = gdtheta*.9 + dtheta*.1; + //gdDist = gdDist*.9 + dDist*.1 + //knob.r += dDist/numDownFingers; + //knob.ang += dtheta; + //printf("thetaSum = %f, distSum = %f\n",gdtheta,gdDist); + //printf("id: %i dTheta = %f, dDist = %f\n",j,dtheta,dDist); + SDL_SendGestureMulti(inTouch,dtheta,dDist); + } + else { + //inTouch->gestureLast[j].dDist = 0; + //inTouch->gestureLast[j].dtheta = 0; + //inTouch->gestureLast[j].cv.x = 0; + //inTouch->gestureLast[j].cv.y = 0; + } + //inTouch->gestureLast[j].f.p.x = x; + //inTouch->gestureLast[j].f.p.y = y; + //break; + //pressure? + } + + if (event->type == SDL_FINGERDOWN) { + + inTouch->numDownFingers++; + inTouch->centroid.x = (inTouch->centroid.x*(inTouch->numDownFingers - 1)+ + x)/inTouch->numDownFingers; + inTouch->centroid.y = (inTouch->centroid.y*(inTouch->numDownFingers - 1)+ + y)/inTouch->numDownFingers; + //printf("Finger Down: (%f,%f). Centroid: (%f,%f\n",x,y, + // inTouch->centroid.x,inTouch->centroid.y); #ifdef ENABLE_DOLLAR - inTouch->dollarPath.length = 0; - inTouch->dollarPath.p[0].x = x; - inTouch->dollarPath.p[0].y = y; - inTouch->dollarPath.numPoints = 1; + inTouch->dollarPath.length = 0; + inTouch->dollarPath.p[0].x = x; + inTouch->dollarPath.p[0].y = y; + inTouch->dollarPath.numPoints = 1; #endif + } } - } } - /* vi: set ts=4 sw=4 expandtab: */ - +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/events/SDL_gesture_c.h b/project/jni/sdl-1.3/src/events/SDL_gesture_c.h index f1f67a3e4..1aabc13ac 100644 --- a/project/jni/sdl-1.3/src/events/SDL_gesture_c.h +++ b/project/jni/sdl-1.3/src/events/SDL_gesture_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/events/SDL_keyboard.c b/project/jni/sdl-1.3/src/events/SDL_keyboard.c index b75aea3d7..6424de9db 100644 --- a/project/jni/sdl-1.3/src/events/SDL_keyboard.c +++ b/project/jni/sdl-1.3/src/events/SDL_keyboard.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -26,7 +25,7 @@ #include "SDL_timer.h" #include "SDL_events.h" #include "SDL_events_c.h" -#include "SDL_sysevents.h" +#include "../video/SDL_sysvideo.h" /* Global keyboard information */ @@ -39,12 +38,12 @@ struct SDL_Keyboard SDL_Window *focus; Uint16 modstate; Uint8 keystate[SDL_NUM_SCANCODES]; - SDLKey keymap[SDL_NUM_SCANCODES]; + SDL_Keycode keymap[SDL_NUM_SCANCODES]; }; static SDL_Keyboard SDL_keyboard; -static const SDLKey SDL_default_keymap[SDL_NUM_SCANCODES] = { +static const SDL_Keycode SDL_default_keymap[SDL_NUM_SCANCODES] = { 0, 0, 0, 0, 'a', 'b', @@ -562,7 +561,7 @@ void SDL_ResetKeyboard(void) { SDL_Keyboard *keyboard = &SDL_keyboard; - SDL_scancode scancode; + SDL_Scancode scancode; for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) { if (keyboard->keystate[scancode] == SDL_PRESSED) { @@ -572,13 +571,13 @@ SDL_ResetKeyboard(void) } void -SDL_GetDefaultKeymap(SDLKey * keymap) +SDL_GetDefaultKeymap(SDL_Keycode * keymap) { SDL_memcpy(keymap, SDL_default_keymap, sizeof(SDL_default_keymap)); } void -SDL_SetKeymap(int start, SDLKey * keys, int length) +SDL_SetKeymap(int start, SDL_Keycode * keys, int length) { SDL_Keyboard *keyboard = &SDL_keyboard; @@ -590,7 +589,7 @@ SDL_SetKeymap(int start, SDLKey * keys, int length) } void -SDL_SetScancodeName(SDL_scancode scancode, const char *name) +SDL_SetScancodeName(SDL_Scancode scancode, const char *name) { SDL_scancode_names[scancode] = name; } @@ -638,7 +637,7 @@ SDL_SetKeyboardFocus(SDL_Window * window) } int -SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode) +SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode) { SDL_Keyboard *keyboard = &SDL_keyboard; int posted; @@ -790,7 +789,6 @@ SDL_SendKeyboardText(const char *text) event.text.type = SDL_TEXTINPUT; event.text.windowID = keyboard->focus ? keyboard->focus->id : 0; SDL_utf8strlcpy(event.text.text, text, SDL_arraysize(event.text.text)); - event.text.windowID = keyboard->focus ? keyboard->focus->id : 0; posted = (SDL_PushEvent(&event) > 0); } return (posted); @@ -832,7 +830,7 @@ SDL_GetKeyboardState(int *numkeys) return keyboard->keystate; } -SDLMod +SDL_Keymod SDL_GetModState(void) { SDL_Keyboard *keyboard = &SDL_keyboard; @@ -841,26 +839,26 @@ SDL_GetModState(void) } void -SDL_SetModState(SDLMod modstate) +SDL_SetModState(SDL_Keymod modstate) { SDL_Keyboard *keyboard = &SDL_keyboard; keyboard->modstate = modstate; } -SDLKey -SDL_GetKeyFromScancode(SDL_scancode scancode) +SDL_Keycode +SDL_GetKeyFromScancode(SDL_Scancode scancode) { SDL_Keyboard *keyboard = &SDL_keyboard; return keyboard->keymap[scancode]; } -SDL_scancode -SDL_GetScancodeFromKey(SDLKey key) +SDL_Scancode +SDL_GetScancodeFromKey(SDL_Keycode key) { SDL_Keyboard *keyboard = &SDL_keyboard; - SDL_scancode scancode; + SDL_Scancode scancode; for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES; ++scancode) { @@ -872,7 +870,7 @@ SDL_GetScancodeFromKey(SDLKey key) } const char * -SDL_GetScancodeName(SDL_scancode scancode) +SDL_GetScancodeName(SDL_Scancode scancode) { const char *name = SDL_scancode_names[scancode]; @@ -882,15 +880,34 @@ SDL_GetScancodeName(SDL_scancode scancode) return ""; } +SDL_Scancode SDL_GetScancodeFromName(const char *name) +{ + int i; + + if (!name || !*name) { + return SDL_SCANCODE_UNKNOWN; + } + + for (i = 0; i < SDL_arraysize(SDL_scancode_names); ++i) { + if (!SDL_scancode_names[i]) { + continue; + } + if (SDL_strcasecmp(name, SDL_scancode_names[i]) == 0) { + return (SDL_Scancode)i; + } + } + return SDL_SCANCODE_UNKNOWN; +} + const char * -SDL_GetKeyName(SDLKey key) +SDL_GetKeyName(SDL_Keycode key) { static char name[8]; char *end; if (key & SDLK_SCANCODE_MASK) { return - SDL_GetScancodeName((SDL_scancode) (key & ~SDLK_SCANCODE_MASK)); + SDL_GetScancodeName((SDL_Scancode) (key & ~SDLK_SCANCODE_MASK)); } switch (key) { @@ -921,4 +938,51 @@ SDL_GetKeyName(SDLKey key) } } +SDL_Keycode +SDL_GetKeyFromName(const char *name) +{ + SDL_Keycode key; + + /* If it's a single UTF-8 character, then that's the keycode itself */ + key = *(const unsigned char *)name; + if (key >= 0xF0) { + if (SDL_strlen(name) == 4) { + int i = 0; + key = (Uint16)(name[i]&0x07) << 18; + key |= (Uint16)(name[++i]&0x3F) << 12; + key |= (Uint16)(name[++i]&0x3F) << 6; + key |= (Uint16)(name[++i]&0x3F); + return key; + } + return SDLK_UNKNOWN; + } else if (key >= 0xE0) { + if (SDL_strlen(name) == 3) { + int i = 0; + key = (Uint16)(name[i]&0x0F) << 12; + key |= (Uint16)(name[++i]&0x3F) << 6; + key |= (Uint16)(name[++i]&0x3F); + return key; + } + return SDLK_UNKNOWN; + } else if (key >= 0xC0) { + if (SDL_strlen(name) == 2) { + int i = 0; + key = (Uint16)(name[i]&0x1F) << 6; + key |= (Uint16)(name[++i]&0x3F); + return key; + } + return SDLK_UNKNOWN; + } else { + if (SDL_strlen(name) == 1) { + if (key >= 'A' && key <= 'Z') { + key += 32; + } + return key; + } + + /* Get the scancode for this name, and the associated keycode */ + return SDL_default_keymap[SDL_GetScancodeFromName(name)]; + } +} + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/events/SDL_keyboard_c.h b/project/jni/sdl-1.3/src/events/SDL_keyboard_c.h index 1eeb9718c..5b2aa4cdf 100644 --- a/project/jni/sdl-1.3/src/events/SDL_keyboard_c.h +++ b/project/jni/sdl-1.3/src/events/SDL_keyboard_c.h @@ -1,30 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef _SDL_keyboard_c_h #define _SDL_keyboard_c_h -#include "SDL_keysym.h" +#include "SDL_keycode.h" #include "SDL_events.h" /* Initialize the keyboard subsystem */ @@ -34,22 +33,22 @@ extern int SDL_KeyboardInit(void); extern void SDL_ResetKeyboard(void); /* Get the default keymap */ -extern void SDL_GetDefaultKeymap(SDLKey * keymap); +extern void SDL_GetDefaultKeymap(SDL_Keycode * keymap); /* Set the mapping of scancode to key codes */ -extern void SDL_SetKeymap(int start, SDLKey * keys, int length); +extern void SDL_SetKeymap(int start, SDL_Keycode * keys, int length); /* Set a platform-dependent key name, overriding the default platform-agnostic name. Encoded as UTF-8. The string is not copied, thus the pointer given to this function must stay valid forever (or at least until the call to VideoQuit()). */ -extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name); +extern void SDL_SetScancodeName(SDL_Scancode scancode, const char *name); /* Set the keyboard focus window */ extern void SDL_SetKeyboardFocus(SDL_Window * window); /* Send a keyboard key event */ -extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode); +extern int SDL_SendKeyboardKey(Uint8 state, SDL_Scancode scancode); /* Send keyboard text input */ extern int SDL_SendKeyboardText(const char *text); diff --git a/project/jni/sdl-1.3/src/events/SDL_mouse.c b/project/jni/sdl-1.3/src/events/SDL_mouse.c index 87e47479b..a514e38d9 100644 --- a/project/jni/sdl-1.3/src/events/SDL_mouse.c +++ b/project/jni/sdl-1.3/src/events/SDL_mouse.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -29,43 +28,7 @@ #include "../video/SDL_sysvideo.h" -/* Global mouse information */ - -typedef struct SDL_Mouse SDL_Mouse; - -struct SDL_Mouse -{ - /* Create a cursor from a surface */ - SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y); - - /* Show the specified cursor, or hide if cursor is NULL */ - int (*ShowCursor) (SDL_Cursor * cursor); - - /* This is called when a mouse motion event occurs */ - void (*MoveCursor) (SDL_Cursor * cursor); - - /* Free a window manager cursor */ - void (*FreeCursor) (SDL_Cursor * cursor); - - /* Warp the mouse to (x,y) */ - void (*WarpMouse) (SDL_Mouse * mouse, SDL_Window * window, int x, int y); - - /* Data common to all mice */ - SDL_Window *focus; - int x; - int y; - int xdelta; - int ydelta; - int last_x, last_y; /* the last reported x and y coordinates */ - Uint8 buttonstate; - SDL_bool relative_mode; - - SDL_Cursor *cursors; - SDL_Cursor *def_cursor; - SDL_Cursor *cur_cursor; - SDL_bool cursor_shown; -}; - +/* The mouse state */ static SDL_Mouse SDL_mouse; @@ -73,19 +36,34 @@ static SDL_Mouse SDL_mouse; int SDL_MouseInit(void) { + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->cursor_shown = SDL_TRUE; + return (0); } void -SDL_ResetMouse(void) +SDL_SetDefaultCursor(SDL_Cursor * cursor) { - /* FIXME */ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->def_cursor = cursor; + if (!mouse->cur_cursor) { + SDL_SetCursor(cursor); + } +} + +SDL_Mouse * +SDL_GetMouse(void) +{ + return &SDL_mouse; } SDL_Window * SDL_GetMouseFocus(void) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); return mouse->focus; } @@ -93,7 +71,7 @@ SDL_GetMouseFocus(void) void SDL_SetMouseFocus(SDL_Window * window) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->focus == window) { return; @@ -114,7 +92,7 @@ SDL_SetMouseFocus(SDL_Window * window) int SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); int posted; int xrel; int yrel; @@ -153,18 +131,22 @@ SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y) } SDL_GetWindowSize(mouse->focus, &x_max, &y_max); + --x_max; + --y_max; /* make sure that the pointers find themselves inside the windows */ /* only check if mouse->xmax is set ! */ - if (x_max && mouse->x > x_max) { + if (mouse->x > x_max) { mouse->x = x_max; - } else if (mouse->x < 0) { + } + if (mouse->x < 0) { mouse->x = 0; } - if (y_max && mouse->y > y_max) { + if (mouse->y > y_max) { mouse->y = y_max; - } else if (mouse->y < 0) { + } + if (mouse->y < 0) { mouse->y = 0; } @@ -200,7 +182,7 @@ SDL_SendMouseMotion(SDL_Window * window, int relative, int x, int y) int SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); int posted; Uint32 type; @@ -249,7 +231,7 @@ SDL_SendMouseButton(SDL_Window * window, Uint8 state, Uint8 button) int SDL_SendMouseWheel(SDL_Window * window, int x, int y) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); int posted; if (window) { @@ -281,7 +263,7 @@ SDL_MouseQuit(void) Uint8 SDL_GetMouseState(int *x, int *y) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); if (x) { *x = mouse->x; @@ -295,7 +277,7 @@ SDL_GetMouseState(int *x, int *y) Uint8 SDL_GetRelativeMouseState(int *x, int *y) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); if (x) { *x = mouse->xdelta; @@ -311,10 +293,10 @@ SDL_GetRelativeMouseState(int *x, int *y) void SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); if (mouse->WarpMouse) { - mouse->WarpMouse(mouse, window, x, y); + mouse->WarpMouse(window, x, y); } else { SDL_SendMouseMotion(window, 0, x, y); } @@ -323,10 +305,20 @@ SDL_WarpMouseInWindow(SDL_Window * window, int x, int y) int SDL_SetRelativeMouseMode(SDL_bool enabled) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); - /* Flush pending mouse motion */ - SDL_FlushEvent(SDL_MOUSEMOTION); + if (enabled == mouse->relative_mode) { + return 0; + } + + if (!mouse->SetRelativeMouseMode) { + SDL_Unsupported(); + return -1; + } + + if (mouse->SetRelativeMouseMode(enabled) < 0) { + return -1; + } /* Set the relative mode */ mouse->relative_mode = enabled; @@ -336,6 +328,9 @@ SDL_SetRelativeMouseMode(SDL_bool enabled) SDL_WarpMouseInWindow(mouse->focus, mouse->x, mouse->y); } + /* Flush pending mouse motion */ + SDL_FlushEvent(SDL_MOUSEMOTION); + /* Update cursor visibility */ SDL_SetCursor(NULL); @@ -345,7 +340,7 @@ SDL_SetRelativeMouseMode(SDL_bool enabled) SDL_bool SDL_GetRelativeMouseMode() { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); return mouse->relative_mode; } @@ -354,7 +349,6 @@ SDL_Cursor * SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, int w, int h, int hot_x, int hot_y) { - SDL_Mouse *mouse = &SDL_mouse; SDL_Surface *surface; SDL_Cursor *cursor; int x, y; @@ -364,24 +358,15 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, const Uint32 white = 0xFFFFFFFF; const Uint32 transparent = 0x00000000; - if (!mouse->CreateCursor) { - SDL_SetError("Cursors are not currently supported"); - return NULL; - } - - /* Sanity check the hot spot */ - if ((hot_x < 0) || (hot_y < 0) || (hot_x >= w) || (hot_y >= h)) { - SDL_SetError("Cursor hot spot doesn't lie within cursor"); - return NULL; - } - /* Make sure the width is a multiple of 8 */ w = ((w + 7) & ~7); /* Create the surface from a bitmap */ - surface = - SDL_CreateRGBSurface(0, w, h, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0xFF000000); + surface = SDL_CreateRGBSurface(0, w, h, 32, + 0x00FF0000, + 0x0000FF00, + 0x000000FF, + 0xFF000000); if (!surface) { return NULL; } @@ -402,13 +387,54 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, } } + cursor = SDL_CreateColorCursor(surface, hot_x, hot_y); + + SDL_FreeSurface(surface); + + return cursor; +} + +SDL_Cursor * +SDL_CreateColorCursor(SDL_Surface *surface, int hot_x, int hot_y) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_Surface *temp = NULL; + SDL_Cursor *cursor; + + if (!surface) { + SDL_SetError("Passed NULL cursor surface"); + return NULL; + } + + if (!mouse->CreateCursor) { + SDL_SetError("Cursors are not currently supported"); + return NULL; + } + + /* Sanity check the hot spot */ + if ((hot_x < 0) || (hot_y < 0) || + (hot_x >= surface->w) || (hot_y >= surface->h)) { + SDL_SetError("Cursor hot spot doesn't lie within cursor"); + return NULL; + } + + if (surface->format->format != SDL_PIXELFORMAT_ARGB8888) { + temp = SDL_ConvertSurfaceFormat(surface, SDL_PIXELFORMAT_ARGB8888, 0); + if (!temp) { + return NULL; + } + surface = temp; + } + cursor = mouse->CreateCursor(surface, hot_x, hot_y); if (cursor) { cursor->next = mouse->cursors; mouse->cursors = cursor; } - SDL_FreeSurface(surface); + if (temp) { + SDL_FreeSurface(temp); + } return cursor; } @@ -420,20 +446,22 @@ SDL_CreateCursor(const Uint8 * data, const Uint8 * mask, void SDL_SetCursor(SDL_Cursor * cursor) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); /* Set the new cursor */ if (cursor) { /* Make sure the cursor is still valid for this mouse */ - SDL_Cursor *found; - for (found = mouse->cursors; found; found = found->next) { - if (found == cursor) { - break; + if (cursor != mouse->def_cursor) { + SDL_Cursor *found; + for (found = mouse->cursors; found; found = found->next) { + if (found == cursor) { + break; + } + } + if (!found) { + SDL_SetError("Cursor not associated with the current mouse"); + return; } - } - if (!found) { - SDL_SetError("Cursor not associated with the current mouse"); - return; } mouse->cur_cursor = cursor; } else { @@ -454,7 +482,7 @@ SDL_SetCursor(SDL_Cursor * cursor) SDL_Cursor * SDL_GetCursor(void) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); if (!mouse) { return NULL; @@ -465,7 +493,7 @@ SDL_GetCursor(void) void SDL_FreeCursor(SDL_Cursor * cursor) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); SDL_Cursor *curr, *prev; if (!cursor) { @@ -499,7 +527,7 @@ SDL_FreeCursor(SDL_Cursor * cursor) int SDL_ShowCursor(int toggle) { - SDL_Mouse *mouse = &SDL_mouse; + SDL_Mouse *mouse = SDL_GetMouse(); SDL_bool shown; if (!mouse) { diff --git a/project/jni/sdl-1.3/src/events/SDL_mouse_c.h b/project/jni/sdl-1.3/src/events/SDL_mouse_c.h index 4983b1a42..36e8d3d90 100644 --- a/project/jni/sdl-1.3/src/events/SDL_mouse_c.h +++ b/project/jni/sdl-1.3/src/events/SDL_mouse_c.h @@ -1,40 +1,81 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef _SDL_mouse_c_h #define _SDL_mouse_c_h +#include "SDL_mouse.h" + struct SDL_Cursor { struct SDL_Cursor *next; void *driverdata; }; +typedef struct +{ + /* Create a cursor from a surface */ + SDL_Cursor *(*CreateCursor) (SDL_Surface * surface, int hot_x, int hot_y); + + /* Show the specified cursor, or hide if cursor is NULL */ + int (*ShowCursor) (SDL_Cursor * cursor); + + /* This is called when a mouse motion event occurs */ + void (*MoveCursor) (SDL_Cursor * cursor); + + /* Free a window manager cursor */ + void (*FreeCursor) (SDL_Cursor * cursor); + + /* Warp the mouse to (x,y) */ + void (*WarpMouse) (SDL_Window * window, int x, int y); + + /* Set relative mode */ + int (*SetRelativeMouseMode) (SDL_bool enabled); + + /* Data common to all mice */ + SDL_Window *focus; + int x; + int y; + int xdelta; + int ydelta; + int last_x, last_y; /* the last reported x and y coordinates */ + Uint8 buttonstate; + SDL_bool relative_mode; + + SDL_Cursor *cursors; + SDL_Cursor *def_cursor; + SDL_Cursor *cur_cursor; + SDL_bool cursor_shown; +} SDL_Mouse; + + /* Initialize the mouse subsystem */ extern int SDL_MouseInit(void); -/* Clear the mouse state */ -extern void SDL_ResetMouse(void); +/* Get the mouse state structure */ +SDL_Mouse *SDL_GetMouse(void); + +/* Set the default mouse cursor */ +extern void SDL_SetDefaultCursor(SDL_Cursor * cursor); /* Set the mouse focus window */ extern void SDL_SetMouseFocus(SDL_Window * window); diff --git a/project/jni/sdl-1.3/src/events/SDL_quit.c b/project/jni/sdl-1.3/src/events/SDL_quit.c index ba4c7b49f..1a3aa003f 100644 --- a/project/jni/sdl-1.3/src/events/SDL_quit.c +++ b/project/jni/sdl-1.3/src/events/SDL_quit.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -47,7 +46,28 @@ SDL_HandleSIG(int sig) int SDL_QuitInit(void) { -#ifdef HAVE_SIGNAL_H +#ifdef HAVE_SIGACTION + struct sigaction action; + sigaction(SIGINT, NULL, &action); +#ifdef HAVE_SA_SIGACTION + if ( action.sa_handler == SIG_DFL && action.sa_sigaction == (void*)SIG_DFL ) { +#else + if ( action.sa_handler == SIG_DFL ) { +#endif + action.sa_handler = SDL_HandleSIG; + sigaction(SIGINT, &action, NULL); + } + sigaction(SIGTERM, NULL, &action); + +#ifdef HAVE_SA_SIGACTION + if ( action.sa_handler == SIG_DFL && action.sa_sigaction == (void*)SIG_DFL ) { +#else + if ( action.sa_handler == SIG_DFL ) { +#endif + action.sa_handler = SDL_HandleSIG; + sigaction(SIGTERM, &action, NULL); + } +#elif HAVE_SIGNAL_H void (*ohandler) (int); /* Both SIGINT and SIGTERM are translated into quit interrupts */ @@ -66,7 +86,19 @@ SDL_QuitInit(void) void SDL_QuitQuit(void) { -#ifdef HAVE_SIGNAL_H +#ifdef HAVE_SIGACTION + struct sigaction action; + sigaction(SIGINT, NULL, &action); + if ( action.sa_handler == SDL_HandleSIG ) { + action.sa_handler = SIG_DFL; + sigaction(SIGINT, &action, NULL); + } + sigaction(SIGTERM, NULL, &action); + if ( action.sa_handler == SDL_HandleSIG ) { + action.sa_handler = SIG_DFL; + sigaction(SIGTERM, &action, NULL); + } +#elif HAVE_SIGNAL_H void (*ohandler) (int); ohandler = signal(SIGINT, SIG_DFL); diff --git a/project/jni/sdl-1.3/src/events/SDL_sysevents.h b/project/jni/sdl-1.3/src/events/SDL_sysevents.h index b3029efeb..7e214e81f 100644 --- a/project/jni/sdl-1.3/src/events/SDL_sysevents.h +++ b/project/jni/sdl-1.3/src/events/SDL_sysevents.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is SDL_free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -29,7 +28,7 @@ #define MUST_THREAD_EVENTS #endif -#ifdef __WIN32__ /* Win32 doesn't allow a separate event thread */ +#ifdef __WIN32__ /* Windows doesn't allow a separate event thread */ #define CANT_THREAD_EVENTS #endif diff --git a/project/jni/sdl-1.3/src/events/SDL_touch.c b/project/jni/sdl-1.3/src/events/SDL_touch.c index 41703da1a..c0c005c80 100644 --- a/project/jni/sdl-1.3/src/events/SDL_touch.c +++ b/project/jni/sdl-1.3/src/events/SDL_touch.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -60,7 +59,7 @@ SDL_GetTouchIndex(int index) return SDL_touchPads[index]; } -int +static int SDL_GetFingerIndexId(SDL_Touch* touch,SDL_FingerID fingerid) { int i; @@ -100,7 +99,8 @@ int SDL_AddTouch(const SDL_Touch * touch, char *name) { SDL_Touch **touchPads; - int index,length; + int index; + size_t length; if (SDL_GetTouchIndexId(touch->id) != -1) { SDL_SetError("Touch ID already in use"); @@ -122,7 +122,7 @@ SDL_AddTouch(const SDL_Touch * touch, char *name) SDL_OutOfMemory(); return -1; } - *SDL_touchPads[index] = *touch; + SDL_memcpy(SDL_touchPads[index], touch, sizeof(*touch)); /* we're setting the touch properties */ length = 0; @@ -190,6 +190,7 @@ SDL_GetNumTouch(void) { return SDL_num_touch; } + SDL_Window * SDL_GetTouchFocusWindow(SDL_TouchID id) { @@ -395,16 +396,15 @@ int SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative, float xin, float yin, float pressurein) { - int index = SDL_GetTouchIndexId(id); - SDL_Touch *touch = SDL_GetTouch(id); - SDL_Finger *finger = SDL_GetFinger(touch,fingerid); + SDL_Touch *touch; + SDL_Finger *finger; int posted; Sint16 xrel, yrel; - float x_max = 0, y_max = 0; - Uint16 x; - Uint16 y; - Uint16 pressure; + Uint16 x; + Uint16 y; + Uint16 pressure; + touch = SDL_GetTouch(id); if (!touch) { return SDL_TouchNotFoundError(id); } @@ -417,6 +417,7 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative, return 0; } + finger = SDL_GetFinger(touch,fingerid); if(finger == NULL || !finger->down) { return SDL_SendFingerDown(id,fingerid,SDL_TRUE,xin,yin,pressurein); } else { @@ -495,14 +496,16 @@ SDL_SendTouchMotion(SDL_TouchID id, SDL_FingerID fingerid, int relative, return posted; } } + int SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button) { - SDL_Touch *touch = SDL_GetTouch(id); + SDL_Touch *touch; int posted; Uint32 type; + touch = SDL_GetTouch(id); if (!touch) { return SDL_TouchNotFoundError(id); } diff --git a/project/jni/sdl-1.3/src/events/SDL_touch_c.h b/project/jni/sdl-1.3/src/events/SDL_touch_c.h index cc97def78..90cf4857e 100644 --- a/project/jni/sdl-1.3/src/events/SDL_touch_c.h +++ b/project/jni/sdl-1.3/src/events/SDL_touch_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #include "../../include/SDL_touch.h" diff --git a/project/jni/sdl-1.3/src/events/SDL_windowevents.c b/project/jni/sdl-1.3/src/events/SDL_windowevents.c index 2a7a7c7db..2d366bf86 100644 --- a/project/jni/sdl-1.3/src/events/SDL_windowevents.c +++ b/project/jni/sdl-1.3/src/events/SDL_windowevents.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -35,7 +34,8 @@ RemovePendingSizeEvents(void * userdata, SDL_Event *event) SDL_Event *new_event = (SDL_Event *)userdata; if (event->type == SDL_WINDOWEVENT && - event->window.event == SDL_WINDOWEVENT_RESIZED && + (event->window.event == SDL_WINDOWEVENT_RESIZED || + event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) && event->window.windowID == new_event->window.windowID) { /* We're about to post a new size event, drop the old one */ return 0; @@ -43,6 +43,20 @@ RemovePendingSizeEvents(void * userdata, SDL_Event *event) return 1; } +static int +RemovePendingMoveEvents(void * userdata, SDL_Event *event) +{ + SDL_Event *new_event = (SDL_Event *)userdata; + + if (event->type == SDL_WINDOWEVENT && + event->window.event == SDL_WINDOWEVENT_MOVED && + event->window.windowID == new_event->window.windowID) { + /* We're about to post a new move event, drop the old one */ + return 0; + } + return 1; +} + int SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, int data2) @@ -57,6 +71,7 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, if (window->flags & SDL_WINDOW_SHOWN) { return 0; } + window->flags &= ~SDL_WINDOW_HIDDEN; window->flags |= SDL_WINDOW_SHOWN; SDL_OnWindowShown(window); break; @@ -65,17 +80,17 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, return 0; } window->flags &= ~SDL_WINDOW_SHOWN; + window->flags |= SDL_WINDOW_HIDDEN; SDL_OnWindowHidden(window); break; case SDL_WINDOWEVENT_MOVED: - if (window->flags & SDL_WINDOW_FULLSCREEN) { + if (SDL_WINDOWPOS_ISUNDEFINED(data1) || + SDL_WINDOWPOS_ISUNDEFINED(data2)) { return 0; } - if (data1 == SDL_WINDOWPOS_UNDEFINED) { - data1 = window->x; - } - if (data2 == SDL_WINDOWPOS_UNDEFINED) { - data2 = window->y; + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + window->windowed.x = data1; + window->windowed.y = data2; } if (data1 == window->x && data2 == window->y) { return 0; @@ -84,8 +99,9 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, window->y = data2; break; case SDL_WINDOWEVENT_RESIZED: - if (window->flags & SDL_WINDOW_FULLSCREEN) { - return 0; + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + window->windowed.w = data1; + window->windowed.h = data2; } if (data1 == window->w && data2 == window->h) { return 0; @@ -153,12 +169,24 @@ SDL_SendWindowEvent(SDL_Window * window, Uint8 windowevent, int data1, event.window.windowID = window->id; /* Fixes queue overflow with resize events that aren't processed */ - if (windowevent == SDL_WINDOWEVENT_RESIZED) { + if (windowevent == SDL_WINDOWEVENT_RESIZED || + windowevent == SDL_WINDOWEVENT_SIZE_CHANGED) { SDL_FilterEvents(RemovePendingSizeEvents, &event); } + if (windowevent == SDL_WINDOWEVENT_MOVED) { + SDL_FilterEvents(RemovePendingMoveEvents, &event); + } posted = (SDL_PushEvent(&event) > 0); } + + if (windowevent == SDL_WINDOWEVENT_CLOSE) { + if ( !window->prev && !window->next ) { + // This is the last window in the list so send the SDL_QUIT event + SDL_SendQuit(); + } + } + return (posted); } diff --git a/project/jni/sdl-1.3/src/events/SDL_windowevents_c.h b/project/jni/sdl-1.3/src/events/SDL_windowevents_c.h index 9b54c41d8..a0f399738 100644 --- a/project/jni/sdl-1.3/src/events/SDL_windowevents_c.h +++ b/project/jni/sdl-1.3/src/events/SDL_windowevents_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/events/blank_cursor.h b/project/jni/sdl-1.3/src/events/blank_cursor.h index 25e98c534..2bd5a3ea4 100644 --- a/project/jni/sdl-1.3/src/events/blank_cursor.h +++ b/project/jni/sdl-1.3/src/events/blank_cursor.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/project/jni/sdl-1.3/src/events/default_cursor.h b/project/jni/sdl-1.3/src/events/default_cursor.h index 59e7d7319..1f22d6a75 100644 --- a/project/jni/sdl-1.3/src/events/default_cursor.h +++ b/project/jni/sdl-1.3/src/events/default_cursor.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * diff --git a/project/jni/sdl-1.3/src/events/nds/SDL_ndsgesture.c b/project/jni/sdl-1.3/src/events/nds/SDL_ndsgesture.c new file mode 100644 index 000000000..c6548000b --- /dev/null +++ b/project/jni/sdl-1.3/src/events/nds/SDL_ndsgesture.c @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +/* No supported under the NDS because of math operations. */ + +#include "SDL_events.h" +#include "../SDL_events_c.h" +#include "../SDL_gesture_c.h" + +int SDL_GestureAddTouch(SDL_Touch* touch) +{ + return 0; +} + +void SDL_GestureProcessEvent(SDL_Event* event) +{ + return; +} + +/* vi: set ts=4 sw=4 expandtab: */ + diff --git a/project/jni/sdl-1.3/src/events/scancodes_darwin.h b/project/jni/sdl-1.3/src/events/scancodes_darwin.h index f328cba44..8fc4e14fa 100644 --- a/project/jni/sdl-1.3/src/events/scancodes_darwin.h +++ b/project/jni/sdl-1.3/src/events/scancodes_darwin.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /* Mac virtual key code to SDL scancode mapping table @@ -27,7 +26,7 @@ - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard */ /* *INDENT-OFF* */ -static const SDL_scancode darwin_scancode_table[] = { +static const SDL_Scancode darwin_scancode_table[] = { /* 0 */ SDL_SCANCODE_A, /* 1 */ SDL_SCANCODE_S, /* 2 */ SDL_SCANCODE_D, diff --git a/project/jni/sdl-1.3/src/events/scancodes_linux.h b/project/jni/sdl-1.3/src/events/scancodes_linux.h index c4b9419bd..16a74b94b 100644 --- a/project/jni/sdl-1.3/src/events/scancodes_linux.h +++ b/project/jni/sdl-1.3/src/events/scancodes_linux.h @@ -1,32 +1,31 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "../../include/SDL_scancode.h" -/* Linux virtual key code to SDLKey mapping table +/* Linux virtual key code to SDL_Keycode mapping table Sources: - Linux kernel source input.h */ /* *INDENT-OFF* */ -static SDL_scancode const linux_scancode_table[] = { +static SDL_Scancode const linux_scancode_table[] = { /* 0 */ SDL_SCANCODE_UNKNOWN, /* 1 */ SDL_SCANCODE_ESCAPE, /* 2 */ SDL_SCANCODE_1, diff --git a/project/jni/sdl-1.3/src/events/scancodes_win32.h b/project/jni/sdl-1.3/src/events/scancodes_windows.h similarity index 92% rename from project/jni/sdl-1.3/src/events/scancodes_win32.h rename to project/jni/sdl-1.3/src/events/scancodes_windows.h index 460ff9e76..a5223f304 100644 --- a/project/jni/sdl-1.3/src/events/scancodes_win32.h +++ b/project/jni/sdl-1.3/src/events/scancodes_windows.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "../../include/SDL_scancode.h" @@ -26,7 +25,7 @@ - msdn.microsoft.com */ /* *INDENT-OFF* */ -static const SDL_scancode win32_scancode_table[] = { +static const SDL_Scancode windows_scancode_table[] = { /* 0, 0x00 */ SDL_SCANCODE_UNKNOWN, /* 1, 0x01 */ SDL_SCANCODE_UNKNOWN, /* 2, 0x02 */ SDL_SCANCODE_UNKNOWN, diff --git a/project/jni/sdl-1.3/src/events/scancodes_xfree86.h b/project/jni/sdl-1.3/src/events/scancodes_xfree86.h index 6d9f4e61c..4ff023102 100644 --- a/project/jni/sdl-1.3/src/events/scancodes_xfree86.h +++ b/project/jni/sdl-1.3/src/events/scancodes_xfree86.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "../../include/SDL_scancode.h" @@ -26,7 +25,7 @@ - atKeyNames.h from XFree86 source code */ /* *INDENT-OFF* */ -static const SDL_scancode xfree86_scancode_table[] = { +static const SDL_Scancode xfree86_scancode_table[] = { /* 0 */ SDL_SCANCODE_UNKNOWN, /* 1 */ SDL_SCANCODE_ESCAPE, /* 2 */ SDL_SCANCODE_1, @@ -177,7 +176,7 @@ static const SDL_scancode xfree86_scancode_table[] = { }; /* for wireless usb keyboard (manufacturer TRUST) without numpad. */ -static const SDL_scancode xfree86_scancode_table2[] = { +static const SDL_Scancode xfree86_scancode_table2[] = { /* 0 */ SDL_SCANCODE_UNKNOWN, /* 1 */ SDL_SCANCODE_ESCAPE, /* 2 */ SDL_SCANCODE_1, diff --git a/project/jni/sdl-1.3/src/file/SDL_rwops.c b/project/jni/sdl-1.3/src/file/SDL_rwops.c index 99e207b4f..540c783ec 100644 --- a/project/jni/sdl-1.3/src/file/SDL_rwops.c +++ b/project/jni/sdl-1.3/src/file/SDL_rwops.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -32,6 +31,12 @@ #include "cocoa/SDL_rwopsbundlesupport.h" #endif /* __APPLE__ */ +/* +#ifdef ANDROID +#include "../core/android/SDL_android.h" +#endif +*/ + #ifdef __NDS__ /* include libfat headers for fatInitDefault(). */ #include @@ -44,8 +49,7 @@ faster, and all stdio functions anyway are embedded in coredll.dll - the main wince dll*/ -#define WINDOWS_LEAN_AND_MEAN -#include +#include "../core/windows/SDL_windows.h" #ifndef INVALID_SET_FILE_POINTER #define INVALID_SET_FILE_POINTER 0xFFFFFFFF @@ -54,7 +58,7 @@ #define READAHEAD_BUFFER_SIZE 1024 static int SDLCALL -win32_file_open(SDL_RWops * context, const char *filename, const char *mode) +windows_file_open(SDL_RWops * context, const char *filename, const char *mode) { #ifndef _WIN32_WCE UINT old_error_mode; @@ -67,10 +71,10 @@ win32_file_open(SDL_RWops * context, const char *filename, const char *mode) if (!context) return -1; /* failed (invalid call) */ - context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* mark this as unusable */ - context->hidden.win32io.buffer.data = NULL; - context->hidden.win32io.buffer.size = 0; - context->hidden.win32io.buffer.left = 0; + context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* mark this as unusable */ + context->hidden.windowsio.buffer.data = NULL; + context->hidden.windowsio.buffer.size = 0; + context->hidden.windowsio.buffer.left = 0; /* "r" = reading, file must exist */ /* "w" = writing, truncate existing, file may not exist */ @@ -90,91 +94,85 @@ win32_file_open(SDL_RWops * context, const char *filename, const char *mode) if (!r_right && !w_right) /* inconsistent mode */ return -1; /* failed (invalid call) */ - context->hidden.win32io.buffer.data = + context->hidden.windowsio.buffer.data = (char *) SDL_malloc(READAHEAD_BUFFER_SIZE); - if (!context->hidden.win32io.buffer.data) { + if (!context->hidden.windowsio.buffer.data) { SDL_OutOfMemory(); return -1; } #ifdef _WIN32_WCE { - size_t size = SDL_strlen(filename) + 1; - wchar_t *filenameW = SDL_stack_alloc(wchar_t, size); - - if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) == - 0) { - SDL_stack_free(filenameW); - SDL_free(context->hidden.win32io.buffer.data); - context->hidden.win32io.buffer.data = NULL; - SDL_SetError("Unable to convert filename to Unicode"); - return -1; - } - h = CreateFile(filenameW, (w_right | r_right), + LPTSTR tstr = WIN_UTF8ToString(filename); + h = CreateFile(tstr, (w_right | r_right), (w_right) ? 0 : FILE_SHARE_READ, NULL, (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL, NULL); - SDL_stack_free(filenameW); + SDL_free(tstr); } #else /* Do not open a dialog box if failure */ old_error_mode = SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS); - h = CreateFile(filename, (w_right | r_right), - (w_right) ? 0 : FILE_SHARE_READ, NULL, - (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL, - NULL); + { + LPTSTR tstr = WIN_UTF8ToString(filename); + h = CreateFile(tstr, (w_right | r_right), + (w_right) ? 0 : FILE_SHARE_READ, NULL, + (must_exist | truncate | a_mode), + FILE_ATTRIBUTE_NORMAL, NULL); + SDL_free(tstr); + } - /* restore old behaviour */ + /* restore old behavior */ SetErrorMode(old_error_mode); #endif /* _WIN32_WCE */ if (h == INVALID_HANDLE_VALUE) { - SDL_free(context->hidden.win32io.buffer.data); - context->hidden.win32io.buffer.data = NULL; + SDL_free(context->hidden.windowsio.buffer.data); + context->hidden.windowsio.buffer.data = NULL; SDL_SetError("Couldn't open %s", filename); return -2; /* failed (CreateFile) */ } - context->hidden.win32io.h = h; - context->hidden.win32io.append = a_mode ? SDL_TRUE : SDL_FALSE; + context->hidden.windowsio.h = h; + context->hidden.windowsio.append = a_mode ? SDL_TRUE : SDL_FALSE; return 0; /* ok */ } static long SDLCALL -win32_file_seek(SDL_RWops * context, long offset, int whence) +windows_file_seek(SDL_RWops * context, long offset, int whence) { - DWORD win32whence; + DWORD windowswhence; long file_pos; - if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE) { - SDL_SetError("win32_file_seek: invalid context/file not opened"); + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE) { + SDL_SetError("windows_file_seek: invalid context/file not opened"); return -1; } /* FIXME: We may be able to satisfy the seek within buffered data */ - if (whence == RW_SEEK_CUR && context->hidden.win32io.buffer.left) { - offset -= (long)context->hidden.win32io.buffer.left; + if (whence == RW_SEEK_CUR && context->hidden.windowsio.buffer.left) { + offset -= (long)context->hidden.windowsio.buffer.left; } - context->hidden.win32io.buffer.left = 0; + context->hidden.windowsio.buffer.left = 0; switch (whence) { case RW_SEEK_SET: - win32whence = FILE_BEGIN; + windowswhence = FILE_BEGIN; break; case RW_SEEK_CUR: - win32whence = FILE_CURRENT; + windowswhence = FILE_CURRENT; break; case RW_SEEK_END: - win32whence = FILE_END; + windowswhence = FILE_END; break; default: - SDL_SetError("win32_file_seek: Unknown value for 'whence'"); + SDL_SetError("windows_file_seek: Unknown value for 'whence'"); return -1; } file_pos = - SetFilePointer(context->hidden.win32io.h, offset, NULL, win32whence); + SetFilePointer(context->hidden.windowsio.h, offset, NULL, windowswhence); if (file_pos != INVALID_SET_FILE_POINTER) return file_pos; /* success */ @@ -184,7 +182,7 @@ win32_file_seek(SDL_RWops * context, long offset, int whence) } static size_t SDLCALL -win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) +windows_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) { size_t total_need; size_t total_read = 0; @@ -193,18 +191,18 @@ win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) total_need = size * maxnum; - if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || !total_need) return 0; - if (context->hidden.win32io.buffer.left > 0) { - void *data = (char *) context->hidden.win32io.buffer.data + - context->hidden.win32io.buffer.size - - context->hidden.win32io.buffer.left; + if (context->hidden.windowsio.buffer.left > 0) { + void *data = (char *) context->hidden.windowsio.buffer.data + + context->hidden.windowsio.buffer.size - + context->hidden.windowsio.buffer.left; read_ahead = - SDL_min(total_need, context->hidden.win32io.buffer.left); + SDL_min(total_need, context->hidden.windowsio.buffer.left); SDL_memcpy(ptr, data, read_ahead); - context->hidden.win32io.buffer.left -= read_ahead; + context->hidden.windowsio.buffer.left -= read_ahead; if (read_ahead == total_need) { return maxnum; @@ -216,19 +214,19 @@ win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) if (total_need < READAHEAD_BUFFER_SIZE) { if (!ReadFile - (context->hidden.win32io.h, context->hidden.win32io.buffer.data, + (context->hidden.windowsio.h, context->hidden.windowsio.buffer.data, READAHEAD_BUFFER_SIZE, &byte_read, NULL)) { SDL_Error(SDL_EFREAD); return 0; } read_ahead = SDL_min(total_need, (int) byte_read); - SDL_memcpy(ptr, context->hidden.win32io.buffer.data, read_ahead); - context->hidden.win32io.buffer.size = byte_read; - context->hidden.win32io.buffer.left = byte_read - read_ahead; + SDL_memcpy(ptr, context->hidden.windowsio.buffer.data, read_ahead); + context->hidden.windowsio.buffer.size = byte_read; + context->hidden.windowsio.buffer.left = byte_read - read_ahead; total_read += read_ahead; } else { if (!ReadFile - (context->hidden.win32io.h, ptr, (DWORD)total_need, &byte_read, NULL)) { + (context->hidden.windowsio.h, ptr, (DWORD)total_need, &byte_read, NULL)) { SDL_Error(SDL_EFREAD); return 0; } @@ -238,7 +236,7 @@ win32_file_read(SDL_RWops * context, void *ptr, size_t size, size_t maxnum) } static size_t SDLCALL -win32_file_write(SDL_RWops * context, const void *ptr, size_t size, +windows_file_write(SDL_RWops * context, const void *ptr, size_t size, size_t num) { @@ -248,20 +246,20 @@ win32_file_write(SDL_RWops * context, const void *ptr, size_t size, total_bytes = size * num; - if (!context || context->hidden.win32io.h == INVALID_HANDLE_VALUE + if (!context || context->hidden.windowsio.h == INVALID_HANDLE_VALUE || total_bytes <= 0 || !size) return 0; - if (context->hidden.win32io.buffer.left) { - SetFilePointer(context->hidden.win32io.h, - -(LONG)context->hidden.win32io.buffer.left, NULL, + if (context->hidden.windowsio.buffer.left) { + SetFilePointer(context->hidden.windowsio.h, + -(LONG)context->hidden.windowsio.buffer.left, NULL, FILE_CURRENT); - context->hidden.win32io.buffer.left = 0; + context->hidden.windowsio.buffer.left = 0; } /* if in append mode, we must go to the EOF before write */ - if (context->hidden.win32io.append) { - if (SetFilePointer(context->hidden.win32io.h, 0L, NULL, FILE_END) == + if (context->hidden.windowsio.append) { + if (SetFilePointer(context->hidden.windowsio.h, 0L, NULL, FILE_END) == INVALID_SET_FILE_POINTER) { SDL_Error(SDL_EFWRITE); return 0; @@ -269,7 +267,7 @@ win32_file_write(SDL_RWops * context, const void *ptr, size_t size, } if (!WriteFile - (context->hidden.win32io.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { + (context->hidden.windowsio.h, ptr, (DWORD)total_bytes, &byte_written, NULL)) { SDL_Error(SDL_EFWRITE); return 0; } @@ -279,17 +277,17 @@ win32_file_write(SDL_RWops * context, const void *ptr, size_t size, } static int SDLCALL -win32_file_close(SDL_RWops * context) +windows_file_close(SDL_RWops * context) { if (context) { - if (context->hidden.win32io.h != INVALID_HANDLE_VALUE) { - CloseHandle(context->hidden.win32io.h); - context->hidden.win32io.h = INVALID_HANDLE_VALUE; /* to be sure */ + if (context->hidden.windowsio.h != INVALID_HANDLE_VALUE) { + CloseHandle(context->hidden.windowsio.h); + context->hidden.windowsio.h = INVALID_HANDLE_VALUE; /* to be sure */ } - if (context->hidden.win32io.buffer.data) { - SDL_free(context->hidden.win32io.buffer.data); - context->hidden.win32io.buffer.data = NULL; + if (context->hidden.windowsio.buffer.data) { + SDL_free(context->hidden.windowsio.buffer.data); + context->hidden.windowsio.buffer.data = NULL; } SDL_FreeRW(context); } @@ -449,18 +447,31 @@ SDL_RWFromFile(const char *file, const char *mode) SDL_SetError("SDL_RWFromFile(): No file or no mode specified"); return NULL; } -#if defined(__WIN32__) +#if 0 && defined(__ANDROID__) rwops = SDL_AllocRW(); if (!rwops) return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ - if (win32_file_open(rwops, file, mode) < 0) { + if (Android_JNI_FileOpen(rwops, file, mode) < 0) { SDL_FreeRW(rwops); return NULL; } - rwops->seek = win32_file_seek; - rwops->read = win32_file_read; - rwops->write = win32_file_write; - rwops->close = win32_file_close; + rwops->seek = Android_JNI_FileSeek; + rwops->read = Android_JNI_FileRead; + rwops->write = Android_JNI_FileWrite; + rwops->close = Android_JNI_FileClose; + +#elif defined(__WIN32__) + rwops = SDL_AllocRW(); + if (!rwops) + return NULL; /* SDL_SetError already setup by SDL_AllocRW() */ + if (windows_file_open(rwops, file, mode) < 0) { + SDL_FreeRW(rwops); + return NULL; + } + rwops->seek = windows_file_seek; + rwops->read = windows_file_read; + rwops->write = windows_file_write; + rwops->close = windows_file_close; #elif HAVE_STDIO_H #ifdef __APPLE__ diff --git a/project/jni/sdl-1.3/src/haptic/SDL_haptic.c b/project/jni/sdl-1.3/src/haptic/SDL_haptic.c index af8c39a77..db7dd1219 100644 --- a/project/jni/sdl-1.3/src/haptic/SDL_haptic.c +++ b/project/jni/sdl-1.3/src/haptic/SDL_haptic.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2008 Edgar Simo + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -143,6 +142,7 @@ SDL_HapticOpen(int device_index) /* Initialize the haptic device */ SDL_memset(haptic, 0, (sizeof *haptic)); + haptic->rumble_id = -1; haptic->index = device_index; if (SDL_SYS_HapticOpen(haptic) < 0) { SDL_free(haptic); @@ -292,6 +292,7 @@ SDL_HapticOpenFromJoystick(SDL_Joystick * joystick) /* Initialize the haptic device */ SDL_memset(haptic, 0, sizeof(SDL_Haptic)); + haptic->rumble_id = -1; if (SDL_SYS_HapticOpenFromJoystick(haptic, joystick) < 0) { SDL_free(haptic); return NULL; @@ -706,3 +707,110 @@ SDL_HapticStopAll(SDL_Haptic * haptic) return SDL_SYS_HapticStopAll(haptic); } + +static void +SDL_HapticRumbleCreate(SDL_HapticEffect * efx) +{ + SDL_memset(efx, 0, sizeof(SDL_HapticEffect)); + efx->type = SDL_HAPTIC_SINE; + efx->periodic.period = 1000; + efx->periodic.magnitude = 0x4000; + efx->periodic.length = 5000; + efx->periodic.attack_length = 0; + efx->periodic.fade_length = 0; +} + +/* + * Checks to see if rumble is supported. + */ +int +SDL_HapticRumbleSupported(SDL_Haptic * haptic) +{ + SDL_HapticEffect efx; + + if (!ValidHaptic(haptic)) { + return -1; + } + + SDL_HapticRumbleCreate(&efx); + return SDL_HapticEffectSupported(haptic, &efx); +} + +/* + * Initializes the haptic device for simple rumble playback. + */ +int +SDL_HapticRumbleInit(SDL_Haptic * haptic) +{ + if (!ValidHaptic(haptic)) { + return -1; + } + + /* Already allocated. */ + if (haptic->rumble_id >= 0) { + return 0; + } + + /* Copy over. */ + SDL_HapticRumbleCreate(&haptic->rumble_effect); + haptic->rumble_id = SDL_HapticNewEffect(haptic, &haptic->rumble_effect); + if (haptic->rumble_id >= 0) { + return 0; + } + return -1; +} + +/* + * Runs simple rumble on a haptic device + */ +int +SDL_HapticRumblePlay(SDL_Haptic * haptic, float strength, Uint32 length) +{ + int ret; + SDL_HapticPeriodic *efx; + + if (!ValidHaptic(haptic)) { + return -1; + } + + if (haptic->rumble_id < 0) { + SDL_SetError("Haptic: Rumble effect not initialized on haptic device"); + return -1; + } + + /* Clamp strength. */ + if (strength > 1.0f) { + strength = 1.0f; + } + else if (strength < 0.0f) { + strength = 0.0f; + } + + /* New effect. */ + efx = &haptic->rumble_effect.periodic; + efx->magnitude = (Sint16)(32767.0f*strength); + efx->length = length; + ret = SDL_HapticUpdateEffect(haptic, haptic->rumble_id, &haptic->rumble_effect); + + return SDL_HapticRunEffect(haptic, haptic->rumble_id, 1); +} + +/* + * Stops the simple rumble on a haptic device. + */ +int +SDL_HapticRumbleStop(SDL_Haptic * haptic) +{ + if (!ValidHaptic(haptic)) { + return -1; + } + + if (haptic->rumble_id < 0) { + SDL_SetError("Haptic: Rumble effect not initialized on haptic device"); + return -1; + } + + return SDL_HapticStopEffect(haptic, haptic->rumble_id); +} + + diff --git a/project/jni/sdl-1.3/src/haptic/SDL_haptic_c.h b/project/jni/sdl-1.3/src/haptic/SDL_haptic_c.h index 4144a0fbc..d7e81105e 100644 --- a/project/jni/sdl-1.3/src/haptic/SDL_haptic_c.h +++ b/project/jni/sdl-1.3/src/haptic/SDL_haptic_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ extern int SDL_HapticInit(void); diff --git a/project/jni/sdl-1.3/src/haptic/SDL_syshaptic.h b/project/jni/sdl-1.3/src/haptic/SDL_syshaptic.h index 9542a0d75..b28e1a9cb 100644 --- a/project/jni/sdl-1.3/src/haptic/SDL_syshaptic.h +++ b/project/jni/sdl-1.3/src/haptic/SDL_syshaptic.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2008 Edgar Simo + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -52,6 +51,9 @@ struct _SDL_Haptic struct haptic_hwdata *hwdata; /* Driver dependent */ int ref_count; /* Count for multiple opens */ + + int rumble_id; /* ID of rumble effect for simple rumble API. */ + SDL_HapticEffect rumble_effect; /* Rumble effect. */ }; /* diff --git a/project/jni/sdl-1.3/src/haptic/darwin/SDL_syshaptic.c b/project/jni/sdl-1.3/src/haptic/darwin/SDL_syshaptic.c index c5b1e54b9..0f771d72c 100644 --- a/project/jni/sdl-1.3/src/haptic/darwin/SDL_syshaptic.c +++ b/project/jni/sdl-1.3/src/haptic/darwin/SDL_syshaptic.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2008 Edgar Simo + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -521,7 +520,7 @@ SDL_SYS_JoystickIsHaptic(SDL_Joystick * joystick) int SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { - if (IOObjectIsEqualTo((io_object_t) haptic->hwdata->device, + if (IOObjectIsEqualTo((io_object_t) ((size_t)haptic->hwdata->device), joystick->hwdata->ffservice)) return 1; return 0; @@ -534,6 +533,18 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { + int i; + for (i=0; ihwdata->ffservice)) { + haptic->index = i; + break; + } + } + if (i >= SDL_numhaptics) { + return -1; + } + return SDL_SYS_HapticOpenFromService(haptic, joystick->hwdata->ffservice); } diff --git a/project/jni/sdl-1.3/src/haptic/dummy/SDL_syshaptic.c b/project/jni/sdl-1.3/src/haptic/dummy/SDL_syshaptic.c index 3b89eda12..b940b3b96 100644 --- a/project/jni/sdl-1.3/src/haptic/dummy/SDL_syshaptic.c +++ b/project/jni/sdl-1.3/src/haptic/dummy/SDL_syshaptic.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2008 Edgar Simo + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/haptic/linux/SDL_syshaptic.c b/project/jni/sdl-1.3/src/haptic/linux/SDL_syshaptic.c index 722a8c9f9..0df86a715 100644 --- a/project/jni/sdl-1.3/src/haptic/linux/SDL_syshaptic.c +++ b/project/jni/sdl-1.3/src/haptic/linux/SDL_syshaptic.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2008 Edgar Simo + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/haptic/nds/SDL_syshaptic.c b/project/jni/sdl-1.3/src/haptic/nds/SDL_syshaptic.c index e903c3edb..d18aae27e 100644 --- a/project/jni/sdl-1.3/src/haptic/nds/SDL_syshaptic.c +++ b/project/jni/sdl-1.3/src/haptic/nds/SDL_syshaptic.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2008 Edgar Simo + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -26,21 +25,21 @@ #include "SDL_haptic.h" #include "../SDL_syshaptic.h" #include "SDL_joystick.h" -#include #include +#include #define MAX_HAPTICS 1 /* right now only the ezf3in1 (and maybe official rumble pak) are supported and there can only be one of those in at a time (in GBA slot.) */ -SDL_Haptic *nds_haptic = NULL; +static SDL_Haptic *nds_haptic = NULL; -typedef struct +struct haptic_hwdata { enum { NONE, OFFICIAL, EZF3IN1 } type; int pos; -} NDS_HapticData; +}; void @@ -165,7 +164,7 @@ SDL_SYS_HapticOpen(SDL_Haptic * haptic) return -1; } - haptic->hwdata = SDL_malloc(sizeof(NDS_HapticData)); + haptic->hwdata = SDL_malloc(sizeof(struct haptic_hwdata)); if (!haptic->hwdata) { SDL_OutOfMemory(); return -1; diff --git a/project/jni/sdl-1.3/src/haptic/win32/SDL_syshaptic.c b/project/jni/sdl-1.3/src/haptic/windows/SDL_syshaptic.c similarity index 93% rename from project/jni/sdl-1.3/src/haptic/win32/SDL_syshaptic.c rename to project/jni/sdl-1.3/src/haptic/windows/SDL_syshaptic.c index e8b1a95f1..79a9ab9b1 100644 --- a/project/jni/sdl-1.3/src/haptic/win32/SDL_syshaptic.c +++ b/project/jni/sdl-1.3/src/haptic/windows/SDL_syshaptic.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2008 Edgar Simo + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -27,7 +26,7 @@ #include "../SDL_syshaptic.h" #include "SDL_joystick.h" #include "../../joystick/SDL_sysjoystick.h" /* For the real SDL_Joystick */ -#include "../../joystick/win32/SDL_dxjoystick_c.h" /* For joystick hwdata */ +#include "../../joystick/windows/SDL_dxjoystick_c.h" /* For joystick hwdata */ #define MAX_HAPTICS 32 @@ -39,6 +38,7 @@ static struct { DIDEVICEINSTANCE instance; + char *name; SDL_Haptic *haptic; DIDEVCAPS capabilities; } SDL_hapticlist[MAX_HAPTICS]; @@ -68,6 +68,7 @@ struct haptic_hweffect /* * Internal stuff. */ +static SDL_bool coinitialized = SDL_FALSE; static LPDIRECTINPUT dinput = NULL; @@ -147,15 +148,18 @@ SDL_SYS_HapticInit(void) SDL_numhaptics = 0; - ret = CoInitialize(NULL); + ret = WIN_CoInitialize(); if (FAILED(ret)) { DI_SetError("Coinitialize", ret); return -1; } + coinitialized = SDL_TRUE; + ret = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput, (LPVOID) & dinput); if (FAILED(ret)) { + SDL_SYS_HapticQuit(); DI_SetError("CoCreateInstance", ret); return -1; } @@ -163,12 +167,14 @@ SDL_SYS_HapticInit(void) /* Because we used CoCreateInstance, we need to Initialize it, first. */ instance = GetModuleHandle(NULL); if (instance == NULL) { + SDL_SYS_HapticQuit(); SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError()); return -1; } ret = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION); if (FAILED(ret)) { + SDL_SYS_HapticQuit(); DI_SetError("Initializing DirectInput device", ret); return -1; } @@ -181,6 +187,7 @@ SDL_SYS_HapticInit(void) DIEDFL_FORCEFEEDBACK | DIEDFL_ATTACHEDONLY); if (FAILED(ret)) { + SDL_SYS_HapticQuit(); DI_SetError("Enumerating DirectInput devices", ret); return -1; } @@ -220,6 +227,9 @@ EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) return DIENUM_CONTINUE; } + /* Copy the name */ + SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName); + /* Close up device and count it. */ IDirectInputDevice_Release(device); SDL_numhaptics++; @@ -238,7 +248,7 @@ EnumHapticsCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) const char * SDL_SYS_HapticName(int index) { - return SDL_hapticlist[index].instance.tszProductName; + return SDL_hapticlist[index].name; } @@ -546,6 +556,8 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) { HRESULT ret; DIDEVICEINSTANCE hap_instance, joy_instance; + hap_instance.dwSize = sizeof(DIDEVICEINSTANCE); + joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); /* Get the device instances. */ ret = IDirectInputDevice2_GetDeviceInfo(haptic->hwdata->device, @@ -572,7 +584,27 @@ SDL_SYS_JoystickSameHaptic(SDL_Haptic * haptic, SDL_Joystick * joystick) int SDL_SYS_HapticOpenFromJoystick(SDL_Haptic * haptic, SDL_Joystick * joystick) { - int ret; + int i, ret; + HRESULT idret; + DIDEVICEINSTANCE joy_instance; + joy_instance.dwSize = sizeof(DIDEVICEINSTANCE); + + /* Since it comes from a joystick we have to try to match it with a haptic device on our haptic list. */ + for (i=0; ihwdata->InputDevice, + &joy_instance); + if (FAILED(idret)) { + return -1; + } + if (DI_GUIDIsSame(&SDL_hapticlist[i].instance.guidInstance, + &joy_instance.guidInstance)) { + haptic->index = i; + break; + } + } + if (i >= SDL_numhaptics) { + return -1; + } /* Allocate the hwdata */ haptic->hwdata = (struct haptic_hwdata *) @@ -630,8 +662,24 @@ SDL_SYS_HapticClose(SDL_Haptic * haptic) void SDL_SYS_HapticQuit(void) { - IDirectInput_Release(dinput); - dinput = NULL; + int i; + + for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) { + if (SDL_hapticlist[i].name) { + SDL_free(SDL_hapticlist[i].name); + SDL_hapticlist[i].name = NULL; + } + } + + if (dinput != NULL) { + IDirectInput_Release(dinput); + dinput = NULL; + } + + if (coinitialized) { + WIN_CoUninitialize(); + coinitialized = SDL_FALSE; + } } diff --git a/project/jni/sdl-1.3/src/joystick/SDL_joystick.c b/project/jni/sdl-1.3/src/joystick/SDL_joystick.c index 6a99c4bf9..662763b35 100644 --- a/project/jni/sdl-1.3/src/joystick/SDL_joystick.c +++ b/project/jni/sdl-1.3/src/joystick/SDL_joystick.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -26,19 +25,14 @@ #include "SDL_events.h" #include "SDL_sysjoystick.h" #include "SDL_joystick_c.h" +#include "SDL_assert.h" + #if !SDL_EVENTS_DISABLED #include "../events/SDL_events_c.h" #endif -/* This is used for Quake III Arena */ -#if SDL_EVENTS_DISABLED -#define SDL_Lock_EventThread() -#define SDL_Unlock_EventThread() -#endif - Uint8 SDL_numjoysticks = 0; SDL_Joystick **SDL_joysticks = NULL; -static SDL_Joystick *default_joystick = NULL; int SDL_JoystickInit(void) @@ -59,7 +53,6 @@ SDL_JoystickInit(void) } status = 0; } - default_joystick = NULL; return (status); } @@ -165,11 +158,9 @@ SDL_JoystickOpen(int device_index) /* Add joystick to list */ ++joystick->ref_count; - SDL_Lock_EventThread(); for (i = 0; SDL_joysticks[i]; ++i) /* Skip to next joystick */ ; SDL_joysticks[i] = joystick; - SDL_Unlock_EventThread(); return (joystick); } @@ -201,9 +192,6 @@ SDL_PrivateJoystickValid(SDL_Joystick ** joystick) { int valid; - if (*joystick == NULL) { - *joystick = default_joystick; - } if (*joystick == NULL) { SDL_SetError("Joystick hasn't been opened yet"); valid = 0; @@ -379,12 +367,6 @@ SDL_JoystickClose(SDL_Joystick * joystick) return; } - /* Lock the event queue - prevent joystick polling */ - SDL_Lock_EventThread(); - - if (joystick == default_joystick) { - default_joystick = NULL; - } SDL_SYS_JoystickClose(joystick); /* Remove joystick from list */ @@ -396,9 +378,6 @@ SDL_JoystickClose(SDL_Joystick * joystick) } } - /* Let the event thread keep running */ - SDL_Unlock_EventThread(); - /* Free the data associated with this joystick */ if (joystick->axes) { SDL_free(joystick->axes); @@ -418,10 +397,19 @@ SDL_JoystickClose(SDL_Joystick * joystick) void SDL_JoystickQuit(void) { + const int numsticks = SDL_numjoysticks; + int i; + /* Stop the event polling */ - SDL_Lock_EventThread(); SDL_numjoysticks = 0; - SDL_Unlock_EventThread(); + + for (i = numsticks; i--; ) { + SDL_Joystick *stick = SDL_joysticks[i]; + if (stick && (stick->ref_count >= 1)) { + stick->ref_count = 1; + SDL_JoystickClose(stick); + } + } /* Quit the joystick setup */ SDL_SYS_JoystickQuit(); diff --git a/project/jni/sdl-1.3/src/joystick/SDL_joystick_c.h b/project/jni/sdl-1.3/src/joystick/SDL_joystick_c.h index e0f8529e2..49b9a3655 100644 --- a/project/jni/sdl-1.3/src/joystick/SDL_joystick_c.h +++ b/project/jni/sdl-1.3/src/joystick/SDL_joystick_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/joystick/SDL_sysjoystick.h b/project/jni/sdl-1.3/src/joystick/SDL_sysjoystick.h index ddb3b84fa..5de8cc974 100644 --- a/project/jni/sdl-1.3/src/joystick/SDL_sysjoystick.h +++ b/project/jni/sdl-1.3/src/joystick/SDL_sysjoystick.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is SDL_free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/joystick/beos/SDL_bejoystick.cc b/project/jni/sdl-1.3/src/joystick/beos/SDL_bejoystick.cc index 1a214d828..d78e66fbd 100644 --- a/project/jni/sdl-1.3/src/joystick/beos/SDL_bejoystick.cc +++ b/project/jni/sdl-1.3/src/joystick/beos/SDL_bejoystick.cc @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/joystick/bsd/SDL_sysjoystick.c b/project/jni/sdl-1.3/src/joystick/bsd/SDL_sysjoystick.c index dc23073e9..782b92daf 100644 --- a/project/jni/sdl-1.3/src/joystick/bsd/SDL_sysjoystick.c +++ b/project/jni/sdl-1.3/src/joystick/bsd/SDL_sysjoystick.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -63,6 +62,9 @@ #ifndef __DragonFly__ #include #endif +#if __FreeBSD_kernel_version > 800063 +#include +#endif #include #endif @@ -78,16 +80,14 @@ #define MAX_JOY_JOYS 2 #define MAX_JOYS (MAX_UHID_JOYS + MAX_JOY_JOYS) -#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) && false -struct usb_ctl_report { - int ucr_report; - u_char ucr_data[1024]; /* filled data size will vary */ -}; -#endif struct report { +#if defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063) + struct usb_gen_descriptor *buf; /* Buffer */ +#else struct usb_ctl_report *buf; /* Buffer */ +#endif size_t size; /* Buffer size */ int rid; /* Report ID */ enum @@ -149,8 +149,10 @@ static char *joydevnames[MAX_JOYS]; static int report_alloc(struct report *, struct report_desc *, int); static void report_free(struct report *); -#if defined(USBHID_UCR_DATA) || (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) || defined(__FreeBSD_kernel__) +#if defined(USBHID_UCR_DATA) || defined(__FreeBSD_kernel__) #define REP_BUF_DATA(rep) ((rep)->buf->ucr_data) +#elif (defined(__FREEBSD__) && (__FreeBSD_kernel_version > 800063)) +#define REP_BUF_DATA(rep) ((rep)->buf->ugd_data) #else #define REP_BUF_DATA(rep) ((rep)->buf->data) #endif diff --git a/project/jni/sdl-1.3/src/joystick/darwin/SDL_sysjoystick.c b/project/jni/sdl-1.3/src/joystick/darwin/SDL_sysjoystick.c index 824917f2d..c982465b2 100644 --- a/project/jni/sdl-1.3/src/joystick/darwin/SDL_sysjoystick.c +++ b/project/jni/sdl-1.3/src/joystick/darwin/SDL_sysjoystick.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/joystick/darwin/SDL_sysjoystick_c.h b/project/jni/sdl-1.3/src/joystick/darwin/SDL_sysjoystick_c.h index 6e978458f..eeb2444e4 100644 --- a/project/jni/sdl-1.3/src/joystick/darwin/SDL_sysjoystick_c.h +++ b/project/jni/sdl-1.3/src/joystick/darwin/SDL_sysjoystick_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/joystick/dummy/SDL_sysjoystick.c b/project/jni/sdl-1.3/src/joystick/dummy/SDL_sysjoystick.c index f8e62abf5..61d19823e 100644 --- a/project/jni/sdl-1.3/src/joystick/dummy/SDL_sysjoystick.c +++ b/project/jni/sdl-1.3/src/joystick/dummy/SDL_sysjoystick.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.h b/project/jni/sdl-1.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.h index 24b4eed4e..02841e7f9 100644 --- a/project/jni/sdl-1.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.h +++ b/project/jni/sdl-1.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #import diff --git a/project/jni/sdl-1.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.m b/project/jni/sdl-1.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.m index 2b221dbba..074d27282 100644 --- a/project/jni/sdl-1.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.m +++ b/project/jni/sdl-1.3/src/joystick/iphoneos/SDLUIAccelerationDelegate.m @@ -1,24 +1,23 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - */ + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ #import "SDLUIAccelerationDelegate.h" /* needed for SDL_IPHONE_MAX_GFORCE macro */ diff --git a/project/jni/sdl-1.3/src/joystick/iphoneos/SDL_sysjoystick.m b/project/jni/sdl-1.3/src/joystick/iphoneos/SDL_sysjoystick.m index fbb6348a7..48e0f62ec 100644 --- a/project/jni/sdl-1.3/src/joystick/iphoneos/SDL_sysjoystick.m +++ b/project/jni/sdl-1.3/src/joystick/iphoneos/SDL_sysjoystick.m @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/joystick/linux/SDL_sysjoystick.c b/project/jni/sdl-1.3/src/joystick/linux/SDL_sysjoystick.c index 57ab0a3d0..51cf8a407 100644 --- a/project/jni/sdl-1.3/src/joystick/linux/SDL_sysjoystick.c +++ b/project/jni/sdl-1.3/src/joystick/linux/SDL_sysjoystick.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -413,21 +412,31 @@ SDL_SYS_JoystickInit(void) numjoysticks = 0; - /* First see if the user specified a joystick to use */ + /* First see if the user specified one or more joysticks to use */ if (SDL_getenv("SDL_JOYSTICK_DEVICE") != NULL) { - SDL_strlcpy(path, SDL_getenv("SDL_JOYSTICK_DEVICE"), sizeof(path)); - if (stat(path, &sb) == 0) { - fd = open(path, O_RDONLY, 0); - if (fd >= 0) { - /* Assume the user knows what they're doing. */ - SDL_joylist[numjoysticks].fname = SDL_strdup(path); - if (SDL_joylist[numjoysticks].fname) { - dev_nums[numjoysticks] = sb.st_rdev; - ++numjoysticks; - } - close(fd); + char *envcopy, *envpath, *delim; + envcopy = SDL_strdup(SDL_getenv("SDL_JOYSTICK_DEVICE")); + envpath = envcopy; + while (envpath != NULL) { + delim = SDL_strchr(envpath, ':'); + if (delim != NULL) { + *delim++ = '\0'; } + if (stat(envpath, &sb) == 0) { + fd = open(envpath, O_RDONLY, 0); + if (fd >= 0) { + /* Assume the user knows what they're doing. */ + SDL_joylist[numjoysticks].fname = SDL_strdup(envpath); + if (SDL_joylist[numjoysticks].fname) { + dev_nums[numjoysticks] = sb.st_rdev; + ++numjoysticks; + } + close(fd); + } + } + envpath = delim; } + SDL_free(envcopy); } for (i = 0; i < SDL_arraysize(joydev_pattern); ++i) { @@ -694,32 +703,33 @@ EV_ConfigJoystick(SDL_Joystick * joystick, int fd) ++joystick->nbuttons; } } - for (i = 0; i < ABS_MAX; ++i) { + for (i = 0; i < ABS_MISC; ++i) { /* Skip hats */ if (i == ABS_HAT0X) { i = ABS_HAT3Y; continue; } if (test_bit(i, absbit)) { - int values[6]; + struct input_absinfo absinfo; - if (ioctl(fd, EVIOCGABS(i), values) < 0) + if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0) continue; #ifdef DEBUG_INPUT_EVENTS printf("Joystick has absolute axis: %x\n", i); printf("Values = { %d, %d, %d, %d, %d }\n", - values[0], values[1], values[2], values[3], values[4]); + absinfo.value, absinfo.minimum, absinfo.maximum, + absinfo.fuzz, absinfo.flat); #endif /* DEBUG_INPUT_EVENTS */ joystick->hwdata->abs_map[i] = joystick->naxes; - if (values[1] == values[2]) { + if (absinfo.minimum == absinfo.maximum) { joystick->hwdata->abs_correct[i].used = 0; } else { joystick->hwdata->abs_correct[i].used = 1; joystick->hwdata->abs_correct[i].coef[0] = - (values[2] + values[1]) / 2 - values[4]; + (absinfo.maximum + absinfo.minimum) / 2 - absinfo.flat; joystick->hwdata->abs_correct[i].coef[1] = - (values[2] + values[1]) / 2 + values[4]; - t = ((values[2] - values[1]) / 2 - 2 * values[4]); + (absinfo.maximum + absinfo.minimum) / 2 + absinfo.flat; + t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * absinfo.flat); if (t != 0) { joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t; diff --git a/project/jni/sdl-1.3/src/joystick/linux/SDL_sysjoystick_c.h b/project/jni/sdl-1.3/src/joystick/linux/SDL_sysjoystick_c.h index a13894a2c..dda9a9c73 100644 --- a/project/jni/sdl-1.3/src/joystick/linux/SDL_sysjoystick_c.h +++ b/project/jni/sdl-1.3/src/joystick/linux/SDL_sysjoystick_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #if SDL_INPUT_LINUXEV diff --git a/project/jni/sdl-1.3/src/joystick/nds/SDL_sysjoystick.c b/project/jni/sdl-1.3/src/joystick/nds/SDL_sysjoystick.c index e885a5da0..bd8202258 100644 --- a/project/jni/sdl-1.3/src/joystick/nds/SDL_sysjoystick.c +++ b/project/jni/sdl-1.3/src/joystick/nds/SDL_sysjoystick.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -31,8 +30,8 @@ #include "SDL_error.h" #include "SDL_events.h" #include "SDL_joystick.h" -#include "SDL_sysjoystick.h" -#include "SDL_joystick_c.h" +#include "../SDL_sysjoystick.h" +#include "../SDL_joystick_c.h" #include "../../video/nds/SDL_ndsevents_c.h" diff --git a/project/jni/sdl-1.3/src/joystick/riscos/SDL_sysjoystick.c b/project/jni/sdl-1.3/src/joystick/riscos/SDL_sysjoystick.c deleted file mode 100644 index 441ce8997..000000000 --- a/project/jni/sdl-1.3/src/joystick/riscos/SDL_sysjoystick.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifdef SDL_JOYSTICK_RISCOS - -/* - RISC OS - Joystick support by Alan Buckley (alan_baa@hotmail.com) - 10 April 2003 - - Note: Currently assumes joystick is present if joystick module is loaded - and that there is one joystick with four buttons. -*/ - -/* This is the system specific header for the SDL joystick API */ - -#include "SDL_events.h" -#include "SDL_joystick.h" -#include "../SDL_sysjoystick.h" -#include "../SDL_joystick_c.h" - -#include "kernel.h" - -#define JOYSTICK_READ 0x43F40 - -struct joystick_hwdata -{ - int joystate; -}; - - -/* Function to scan the system for joysticks. - * This function should set SDL_numjoysticks to the number of available - * joysticks. Joystick 0 should be the system default joystick. - * It should return number of joysticks, or -1 on an unrecoverable fatal error. - */ -int -SDL_SYS_JoystickInit(void) -{ - _kernel_swi_regs regs; - - /* Try to read joystick 0 */ - regs.r[0] = 0; - if (_kernel_swi(JOYSTICK_READ, ®s, ®s) == NULL) { - /* Switch works so assume we've got a joystick */ - return 1; - } - /* Switch fails so it looks like there's no joystick here */ - - return (0); -} - -/* Function to get the device-dependent name of a joystick */ -const char * -SDL_SYS_JoystickName(int index) -{ - if (index == 0) { - return "RISC OS Joystick 0"; - } - - SDL_SetError("No joystick available with that index"); - return (NULL); -} - -/* Function to open a joystick for use. - The joystick to open is specified by the index field of the joystick. - This should fill the nbuttons and naxes fields of the joystick structure. - It returns 0, or -1 if there is an error. - */ -int -SDL_SYS_JoystickOpen(SDL_Joystick * joystick) -{ - _kernel_swi_regs regs; - - if (!(joystick->hwdata = SDL_malloc(sizeof(struct joystick_hwdata)))) - return -1; - - regs.r[0] = joystick->index; - - /* Don't know how to get exact count of buttons so assume max of 4 for now */ - joystick->nbuttons = 4; - - joystick->nhats = 0; - joystick->nballs = 0; - joystick->naxes = 2; - joystick->hwdata->joystate = 0; - - return 0; - -} - -/* Function to update the state of a joystick - called as a device poll. - * This function shouldn't update the joystick structure directly, - * but instead should call SDL_PrivateJoystick*() to deliver events - * and update joystick device state. - */ -void -SDL_SYS_JoystickUpdate(SDL_Joystick * joystick) -{ - _kernel_swi_regs regs; - regs.r[0] = joystick->index; - - if (_kernel_swi(JOYSTICK_READ, ®s, ®s) == NULL) { - int newstate = regs.r[0]; - int oldstate = joystick->hwdata->joystate; - if (newstate != oldstate) { - if ((newstate & 0xFF) != (oldstate & 0xFF)) { - int y = regs.r[0] & 0xFF; - /* Convert to signed values */ - if (y >= 128) - y -= 256; - SDL_PrivateJoystickAxis(joystick, 1, -y * 256); /* Up and down opposite to result in SDL */ - } - if ((newstate & 0xFF00) != (oldstate & 0xFF00)) { - int x = (regs.r[0] & 0xFF00) >> 8; - if (x >= 128) - x -= 256; - SDL_PrivateJoystickAxis(joystick, 0, x * 256); - } - - if ((newstate & 0xFF0000) != (oldstate & 0xFF0000)) { - int buttons = (regs.r[0] & 0xFF0000) >> 16; - int oldbuttons = (oldstate & 0xFF0000) >> 16; - int i; - for (i = 0; i < joystick->nbuttons; i++) { - if ((buttons & (1 << i)) != (oldbuttons & (1 << i))) { - if (buttons & (1 << i)) - SDL_PrivateJoystickButton(joystick, i, - SDL_PRESSED); - else - SDL_PrivateJoystickButton(joystick, i, - SDL_RELEASED); - } - } - } - joystick->hwdata->joystate = newstate; - } - } - - return; -} - -/* Function to close a joystick after use */ -void -SDL_SYS_JoystickClose(SDL_Joystick * joystick) -{ - if (joystick->hwdata) - SDL_free(joystick->hwdata); - return; -} - -/* Function to perform any system-specific joystick related cleanup */ -void -SDL_SYS_JoystickQuit(void) -{ - SDL_numjoysticks = 0; - - return; -} - -#endif /* SDL_JOYSTICK_RISCOS */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/joystick/win32/SDL_dxjoystick.c b/project/jni/sdl-1.3/src/joystick/windows/SDL_dxjoystick.c similarity index 95% rename from project/jni/sdl-1.3/src/joystick/win32/SDL_dxjoystick.c rename to project/jni/sdl-1.3/src/joystick/windows/SDL_dxjoystick.c index d9ddaa3b2..6d9b44ff8 100644 --- a/project/jni/sdl-1.3/src/joystick/win32/SDL_dxjoystick.c +++ b/project/jni/sdl-1.3/src/joystick/windows/SDL_dxjoystick.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -58,11 +57,13 @@ extern HWND SDL_HelperWindow; /* local variables */ +static SDL_bool coinitialized = SDL_FALSE; static LPDIRECTINPUT dinput = NULL; extern HRESULT(WINAPI * DInputCreate) (HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT * ppDI, LPUNKNOWN punkOuter); static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS]; /* array to hold joystick ID values */ +static char *SYS_JoystickNames[MAX_JOYSTICKS]; static int SYS_NumJoysticks; static HINSTANCE DInputDLL = NULL; @@ -284,16 +285,19 @@ SDL_SYS_JoystickInit(void) SYS_NumJoysticks = 0; - result = CoInitialize(NULL); + result = WIN_CoInitialize(); if (FAILED(result)) { SetDIerror("CoInitialize", result); return (-1); } + coinitialized = SDL_TRUE; + result = CoCreateInstance(&CLSID_DirectInput, NULL, CLSCTX_INPROC_SERVER, &IID_IDirectInput, (LPVOID)&dinput); if (FAILED(result)) { + SDL_SYS_JoystickQuit(); SetDIerror("CoCreateInstance", result); return (-1); } @@ -301,6 +305,7 @@ SDL_SYS_JoystickInit(void) /* Because we used CoCreateInstance, we need to Initialize it, first. */ instance = GetModuleHandle(NULL); if (instance == NULL) { + SDL_SYS_JoystickQuit(); SDL_SetError("GetModuleHandle() failed with error code %d.", GetLastError()); return (-1); @@ -308,6 +313,7 @@ SDL_SYS_JoystickInit(void) result = IDirectInput_Initialize(dinput, instance, DIRECTINPUT_VERSION); if (FAILED(result)) { + SDL_SYS_JoystickQuit(); SetDIerror("IDirectInput::Initialize", result); return (-1); } @@ -326,6 +332,7 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) { SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance, sizeof(DIDEVICEINSTANCE)); + SYS_JoystickNames[SYS_NumJoysticks] = WIN_StringToUTF8(pdidInstance->tszProductName); SYS_NumJoysticks++; if (SYS_NumJoysticks >= MAX_JOYSTICKS) @@ -338,8 +345,7 @@ EnumJoysticksCallback(const DIDEVICEINSTANCE * pdidInstance, VOID * pContext) const char * SDL_SYS_JoystickName(int index) { - /***-> test for invalid index ? */ - return (SYS_Joystick[index].tszProductName); + return SYS_JoystickNames[index]; } /* Function to open a joystick for use. @@ -793,8 +799,24 @@ SDL_SYS_JoystickClose(SDL_Joystick * joystick) void SDL_SYS_JoystickQuit(void) { - IDirectInput_Release(dinput); - dinput = NULL; + int i; + + for (i = 0; i < SDL_arraysize(SYS_JoystickNames); ++i) { + if (SYS_JoystickNames[i]) { + SDL_free(SYS_JoystickNames[i]); + SYS_JoystickNames[i] = NULL; + } + } + + if (dinput != NULL) { + IDirectInput_Release(dinput); + dinput = NULL; + } + + if (coinitialized) { + WIN_CoUninitialize(); + coinitialized = SDL_FALSE; + } } #endif /* SDL_JOYSTICK_DINPUT */ diff --git a/project/jni/sdl-1.3/src/joystick/win32/SDL_dxjoystick_c.h b/project/jni/sdl-1.3/src/joystick/windows/SDL_dxjoystick_c.h similarity index 55% rename from project/jni/sdl-1.3/src/joystick/win32/SDL_dxjoystick_c.h rename to project/jni/sdl-1.3/src/joystick/windows/SDL_dxjoystick_c.h index 847b168b6..8a6952bd9 100644 --- a/project/jni/sdl-1.3/src/joystick/win32/SDL_dxjoystick_c.h +++ b/project/jni/sdl-1.3/src/joystick/windows/SDL_dxjoystick_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -33,8 +32,7 @@ * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and * let it return 0 events. */ -#define WIN32_LEAN_AND_MEAN -#include +#include "../../core/windows/SDL_windows.h" #define DIRECTINPUT_VERSION 0x0700 /* Need version 7 for force feedback. */ #include diff --git a/project/jni/sdl-1.3/src/joystick/win32/SDL_mmjoystick.c b/project/jni/sdl-1.3/src/joystick/windows/SDL_mmjoystick.c similarity index 91% rename from project/jni/sdl-1.3/src/joystick/win32/SDL_mmjoystick.c rename to project/jni/sdl-1.3/src/joystick/windows/SDL_mmjoystick.c index ad0592c22..49b9b174f 100644 --- a/project/jni/sdl-1.3/src/joystick/win32/SDL_mmjoystick.c +++ b/project/jni/sdl-1.3/src/joystick/windows/SDL_mmjoystick.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -25,8 +24,7 @@ /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */ -#define WIN32_LEAN_AND_MEAN -#include +#include "../../core/windows/SDL_windows.h" #include #include @@ -65,7 +63,7 @@ struct joystick_hwdata } transaxis[6]; }; -/* Convert a win32 Multimedia API return code to a text message */ +/* Convert a Windows Multimedia API return code to a text message */ static void SetMMerror(char *function, int code); diff --git a/project/jni/sdl-1.3/src/libm/e_atan2.c b/project/jni/sdl-1.3/src/libm/e_atan2.c index f6974bd12..3f1ee5771 100644 --- a/project/jni/sdl-1.3/src/libm/e_atan2.c +++ b/project/jni/sdl-1.3/src/libm/e_atan2.c @@ -36,7 +36,7 @@ * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" static const double diff --git a/project/jni/sdl-1.3/src/libm/e_log.c b/project/jni/sdl-1.3/src/libm/e_log.c index 47e8ea452..da64138cd 100644 --- a/project/jni/sdl-1.3/src/libm/e_log.c +++ b/project/jni/sdl-1.3/src/libm/e_log.c @@ -66,7 +66,7 @@ static const char rcsid[] = * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/project/jni/sdl-1.3/src/libm/e_pow.c b/project/jni/sdl-1.3/src/libm/e_pow.c index f90652c65..9145c4b57 100644 --- a/project/jni/sdl-1.3/src/libm/e_pow.c +++ b/project/jni/sdl-1.3/src/libm/e_pow.c @@ -59,7 +59,7 @@ static char rcsid[] = "$NetBSD: e_pow.c,v 1.9 1995/05/12 04:57:32 jtc Exp $"; * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(scalbn) diff --git a/project/jni/sdl-1.3/src/libm/e_rem_pio2.c b/project/jni/sdl-1.3/src/libm/e_rem_pio2.c index 3578a0fad..a8ffe3142 100644 --- a/project/jni/sdl-1.3/src/libm/e_rem_pio2.c +++ b/project/jni/sdl-1.3/src/libm/e_rem_pio2.c @@ -21,7 +21,7 @@ static const char rcsid[] = * use __kernel_rem_pio2() */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(fabs) diff --git a/project/jni/sdl-1.3/src/libm/e_sqrt.c b/project/jni/sdl-1.3/src/libm/e_sqrt.c index 3c4b25ea5..b8b8bec6f 100644 --- a/project/jni/sdl-1.3/src/libm/e_sqrt.c +++ b/project/jni/sdl-1.3/src/libm/e_sqrt.c @@ -85,7 +85,7 @@ static const char rcsid[] = *--------------- */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/project/jni/sdl-1.3/src/libm/k_cos.c b/project/jni/sdl-1.3/src/libm/k_cos.c index ab2637eb7..64c50e3fb 100644 --- a/project/jni/sdl-1.3/src/libm/k_cos.c +++ b/project/jni/sdl-1.3/src/libm/k_cos.c @@ -50,7 +50,7 @@ static const char rcsid[] = * thus, reducing the rounding error in the subtraction. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/project/jni/sdl-1.3/src/libm/k_rem_pio2.c b/project/jni/sdl-1.3/src/libm/k_rem_pio2.c index 42db4a898..f881d35d6 100644 --- a/project/jni/sdl-1.3/src/libm/k_rem_pio2.c +++ b/project/jni/sdl-1.3/src/libm/k_rem_pio2.c @@ -131,7 +131,7 @@ static const char rcsid[] = * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(scalbn) diff --git a/project/jni/sdl-1.3/src/libm/k_sin.c b/project/jni/sdl-1.3/src/libm/k_sin.c index 250ee6eca..60881575a 100644 --- a/project/jni/sdl-1.3/src/libm/k_sin.c +++ b/project/jni/sdl-1.3/src/libm/k_sin.c @@ -43,7 +43,7 @@ static const char rcsid[] = * sin(x) = x + (S1*x + (x *(r-y/2)+y)) */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/project/jni/sdl-1.3/src/libm/math.h b/project/jni/sdl-1.3/src/libm/math_libm.h similarity index 50% rename from project/jni/sdl-1.3/src/libm/math.h rename to project/jni/sdl-1.3/src/libm/math_libm.h index 75e1a1459..6c1f8e9d7 100644 --- a/project/jni/sdl-1.3/src/libm/math.h +++ b/project/jni/sdl-1.3/src/libm/math_libm.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #include "SDL_stdinc.h" @@ -29,6 +28,7 @@ #else #define atan SDL_atan #endif +double atan(double x); #ifndef HAVE_ATAN2 #define __ieee754_atan2 SDL_atan2 @@ -39,24 +39,28 @@ #else #define copysign SDL_copysign #endif +double copysign(double x, double y); #ifdef HAVE_COS #define cos SDL_uclibc_cos #else #define cos SDL_cos #endif +double cos(double x); #ifdef HAVE_FABS #define fabs SDL_uclibc_fabs #else #define fabs SDL_fabs #endif +double fabs(double x); #ifdef HAVE_FLOOR #define floor SDL_uclibc_floor #else #define floor SDL_floor #endif +double floor(double x); #ifndef HAVE_LOG #define __ieee754_log SDL_log @@ -71,12 +75,14 @@ #else #define scalbn SDL_scalbn #endif +double scalbn(double x, int n); #ifdef HAVE_SIN #define sin SDL_uclibc_sin #else #define sin SDL_sin #endif +double sin(double x); #ifndef HAVE_SQRT #define __ieee754_sqrt SDL_sqrt diff --git a/project/jni/sdl-1.3/src/libm/math_private.h b/project/jni/sdl-1.3/src/libm/math_private.h index 63c98bf61..500e7da96 100644 --- a/project/jni/sdl-1.3/src/libm/math_private.h +++ b/project/jni/sdl-1.3/src/libm/math_private.h @@ -19,7 +19,7 @@ /*#include */ #include "SDL_endian.h" -#include +/*#include */ #define attribute_hidden #define libm_hidden_proto(x) diff --git a/project/jni/sdl-1.3/src/libm/s_atan.c b/project/jni/sdl-1.3/src/libm/s_atan.c index 08cfb08e8..f664f0eb3 100644 --- a/project/jni/sdl-1.3/src/libm/s_atan.c +++ b/project/jni/sdl-1.3/src/libm/s_atan.c @@ -29,7 +29,7 @@ * to produce the hexadecimal values shown. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" static const double atanhi[] = { diff --git a/project/jni/sdl-1.3/src/libm/s_copysign.c b/project/jni/sdl-1.3/src/libm/s_copysign.c index 65e719007..afd43e9a7 100644 --- a/project/jni/sdl-1.3/src/libm/s_copysign.c +++ b/project/jni/sdl-1.3/src/libm/s_copysign.c @@ -21,7 +21,7 @@ static const char rcsid[] = * with the sign bit of y. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(copysign) diff --git a/project/jni/sdl-1.3/src/libm/s_cos.c b/project/jni/sdl-1.3/src/libm/s_cos.c index 9a568fca2..66b156c9f 100644 --- a/project/jni/sdl-1.3/src/libm/s_cos.c +++ b/project/jni/sdl-1.3/src/libm/s_cos.c @@ -46,7 +46,7 @@ static const char rcsid[] = * TRIG(x) returns trig(x) nearly rounded */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(cos) diff --git a/project/jni/sdl-1.3/src/libm/s_fabs.c b/project/jni/sdl-1.3/src/libm/s_fabs.c index dba666cbc..5cf0c3977 100644 --- a/project/jni/sdl-1.3/src/libm/s_fabs.c +++ b/project/jni/sdl-1.3/src/libm/s_fabs.c @@ -19,7 +19,7 @@ static const char rcsid[] = * fabs(x) returns the absolute value of x. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(fabs) diff --git a/project/jni/sdl-1.3/src/libm/s_floor.c b/project/jni/sdl-1.3/src/libm/s_floor.c index d6b8f177e..b553d3038 100644 --- a/project/jni/sdl-1.3/src/libm/s_floor.c +++ b/project/jni/sdl-1.3/src/libm/s_floor.c @@ -24,7 +24,7 @@ static const char rcsid[] = * Inexact flag raised if x not equal to floor(x). */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" #ifdef __STDC__ diff --git a/project/jni/sdl-1.3/src/libm/s_scalbn.c b/project/jni/sdl-1.3/src/libm/s_scalbn.c index e90631da6..74b979445 100644 --- a/project/jni/sdl-1.3/src/libm/s_scalbn.c +++ b/project/jni/sdl-1.3/src/libm/s_scalbn.c @@ -22,7 +22,7 @@ static const char rcsid[] = * exponentiation or a multiplication. */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(copysign) diff --git a/project/jni/sdl-1.3/src/libm/s_sin.c b/project/jni/sdl-1.3/src/libm/s_sin.c index 1b22f8813..771176619 100644 --- a/project/jni/sdl-1.3/src/libm/s_sin.c +++ b/project/jni/sdl-1.3/src/libm/s_sin.c @@ -46,7 +46,7 @@ static const char rcsid[] = * TRIG(x) returns trig(x) nearly rounded */ -#include "math.h" +#include "math_libm.h" #include "math_private.h" libm_hidden_proto(sin) diff --git a/project/jni/sdl-1.3/src/loadso/beos/SDL_sysloadso.c b/project/jni/sdl-1.3/src/loadso/beos/SDL_sysloadso.c index 1811104b4..ea58428aa 100644 --- a/project/jni/sdl-1.3/src/loadso/beos/SDL_sysloadso.c +++ b/project/jni/sdl-1.3/src/loadso/beos/SDL_sysloadso.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/loadso/dlopen/SDL_sysloadso.c b/project/jni/sdl-1.3/src/loadso/dlopen/SDL_sysloadso.c index 79d912af7..908e677a2 100644 --- a/project/jni/sdl-1.3/src/loadso/dlopen/SDL_sysloadso.c +++ b/project/jni/sdl-1.3/src/loadso/dlopen/SDL_sysloadso.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/loadso/dummy/SDL_sysloadso.c b/project/jni/sdl-1.3/src/loadso/dummy/SDL_sysloadso.c index f9d31bd50..155288935 100644 --- a/project/jni/sdl-1.3/src/loadso/dummy/SDL_sysloadso.c +++ b/project/jni/sdl-1.3/src/loadso/dummy/SDL_sysloadso.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/loadso/macosx/SDL_dlcompat.c b/project/jni/sdl-1.3/src/loadso/macosx/SDL_dlcompat.c deleted file mode 100644 index 42e6afa1a..000000000 --- a/project/jni/sdl-1.3/src/loadso/macosx/SDL_dlcompat.c +++ /dev/null @@ -1,1391 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifdef SDL_LOADSO_DLCOMPAT - -/* Please note that dlcompat apparently ships in current Mac OS X versions - * as a system library that provides compatibility with the Unix "dlopen" - * interface. In order to allow SDL to work on older OS X releases and also - * not conflict with the system lib on newer versions, we include dlcompat - * in SDL and change the symbols to prevent symbol clash with any existing - * system libraries. --ryan. - */ - -/* here is the dlcompat license: */ - -/* -Copyright (c) 2002 Jorge Acereda & - Peter O'Gorman - -Portions may be copyright others, see the AUTHORS file included with this -distribution. - -Maintained by Peter O'Gorman - -Bug Reports and other queries should go to - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "SDL_stdinc.h" - -/* Just playing to see if it would compile with the freebsd headers, it does, - * but because of the different values for RTLD_LOCAL etc, it would break binary - * compat... oh well - */ -#ifndef __BSD_VISIBLE -#define __BSD_VISIBLE 1 -#endif - -/*include "dlfcn.h"*/ -#ifdef __cplusplus -extern "C" -{ -#endif - -#if defined (__GNUC__) && __GNUC__ > 3 -#define dl_restrict __restrict -#else -#define dl_restrict -#endif - -#if 0 -#ifndef _POSIX_SOURCE -/* - * Structure filled in by dladdr(). - */ - typedef struct SDL_OSX_dl_info - { - const char *dli_fname; /* Pathname of shared object */ - void *dli_fbase; /* Base address of shared object */ - const char *dli_sname; /* Name of nearest symbol */ - void *dli_saddr; /* Address of nearest symbol */ - } SDL_OSX_Dl_info; - - static int SDL_OSX_dladdr(const void *dl_restrict, - SDL_OSX_Dl_info * dl_restrict); -#endif /* ! _POSIX_SOURCE */ -#endif /* 0 */ - - static int SDL_OSX_dlclose(void *handle); - static const char *SDL_OSX_dlerror(void); - static void *SDL_OSX_dlopen(const char *path, int mode); - static void *SDL_OSX_dlsym(void *dl_restrict handle, - const char *dl_restrict symbol); - -#define RTLD_LAZY 0x1 -#define RTLD_NOW 0x2 -#define RTLD_LOCAL 0x4 -#define RTLD_GLOBAL 0x8 - -#ifndef _POSIX_SOURCE -#define RTLD_NOLOAD 0x10 -#define RTLD_NODELETE 0x80 - -/* - * Special handle arguments for SDL_OSX_dlsym(). - */ -#define RTLD_NEXT ((void *) -1) /* Search subsequent objects. */ -#define RTLD_DEFAULT ((void *) -2) /* Use default search algorithm. */ -#endif /* ! _POSIX_SOURCE */ - -#ifdef __cplusplus -} -#endif - -#ifndef dl_restrict -#define dl_restrict __restrict -#endif -/* This is not available on 10.1 */ -#ifndef LC_LOAD_WEAK_DYLIB -#define LC_LOAD_WEAK_DYLIB (0x18 | LC_REQ_DYLD) -#endif - -/* With this stuff here, this thing may actually compile/run on 10.0 systems - * Not that I have a 10.0 system to test it on anylonger - */ -#ifndef LC_REQ_DYLD -#define LC_REQ_DYLD 0x80000000 -#endif -#ifndef NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED -#define NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED 0x4 -#endif -#ifndef NSADDIMAGE_OPTION_RETURN_ON_ERROR -#define NSADDIMAGE_OPTION_RETURN_ON_ERROR 0x1 -#endif -#ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_BIND -#define NSLOOKUPSYMBOLINIMAGE_OPTION_BIND 0x0 -#endif -#ifndef NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR -#define NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR 0x4 -#endif -/* These symbols will be looked for in dyld */ -static const struct mach_header *(*dyld_NSAddImage) (const char *, - unsigned long) = 0; -static int (*dyld_NSIsSymbolNameDefinedInImage) (const struct mach_header *, - const char *) = 0; -static NSSymbol(*dyld_NSLookupSymbolInImage) (const struct mach_header *, - const char *, unsigned long) = - 0; - -/* Define this to make dlcompat reuse data block. This way in theory we save - * a little bit of overhead. However we then couldn't correctly catch excess - * calls to SDL_OSX_dlclose(). Hence we don't use this feature - */ -#undef REUSE_STATUS - -/* Size of the internal error message buffer (used by dlerror()) */ -#define ERR_STR_LEN 251 - -/* Maximum number of search paths supported by getSearchPath */ -#define MAX_SEARCH_PATHS 32 - - -#define MAGIC_DYLIB_OFI ((NSObjectFileImage) 'DYOF') -#define MAGIC_DYLIB_MOD ((NSModule) 'DYMO') - -/* internal flags */ -#define DL_IN_LIST 0x01 - -/* our mutex */ -static pthread_mutex_t dlcompat_mutex; -/* Our thread specific storage - */ -static pthread_key_t dlerror_key; - -struct dlthread -{ - int lockcnt; - unsigned char errset; - char errstr[ERR_STR_LEN]; -}; - -/* This is our central data structure. Whenever a module is loaded via - * SDL_OSX_dlopen(), we create such a struct. - */ -struct dlstatus -{ - struct dlstatus *next; /* pointer to next element in the linked list */ - NSModule module; - const struct mach_header *lib; - int refs; /* reference count */ - int mode; /* mode in which this module was loaded */ - dev_t device; - ino_t inode; - int flags; /* Any internal flags we may need */ -}; - -/* Head node of the dlstatus list */ -static struct dlstatus mainStatus = - { 0, MAGIC_DYLIB_MOD, NULL, -1, RTLD_GLOBAL, 0, 0, 0 }; -static struct dlstatus *stqueue = &mainStatus; - - -/* Storage for the last error message (used by dlerror()) */ -/* static char err_str[ERR_STR_LEN]; */ -/* static int err_filled = 0; */ - -/* Prototypes to internal functions */ -static void debug(const char *fmt, ...); -static void error(const char *str, ...); -static const char *safegetenv(const char *s); -static const char *searchList(void); -static const char *getSearchPath(int i); -static const char *getFullPath(int i, const char *file); -static const struct stat *findFile(const char *file, const char **fullPath); -static int isValidStatus(struct dlstatus *status); -static inline int isFlagSet(int mode, int flag); -static struct dlstatus *lookupStatus(const struct stat *sbuf); -static void insertStatus(struct dlstatus *dls, const struct stat *sbuf); -static int promoteLocalToGlobal(struct dlstatus *dls); -static void *reference(struct dlstatus *dls, int mode); -static void *dlsymIntern(struct dlstatus *dls, const char *symbol, - int canSetError); -static struct dlstatus *allocStatus(void); -static struct dlstatus *loadModule(const char *path, const struct stat *sbuf, - int mode); -static NSSymbol search_linked_libs(const struct mach_header *mh, - const char *symbol); -static const char *get_lib_name(const struct mach_header *mh); -static const struct mach_header *get_mach_header_from_NSModule(NSModule mod); -static void dlcompat_init_func(void); -static inline void dlcompat_init_check(void); -static inline void dolock(void); -static inline void dounlock(void); -static void dlerrorfree(void *data); -static void resetdlerror(void); -static const struct mach_header *my_find_image(const char *name); -static const struct mach_header *image_for_address(const void *address); -static inline char *dyld_error_str(void); - -#if FINK_BUILD -/* Two Global Functions */ -static void *dlsym_prepend_underscore(void *handle, const char *symbol); -static void *dlsym_auto_underscore(void *handle, const char *symbol); - -/* And their _intern counterparts */ -static void *dlsym_prepend_underscore_intern(void *handle, - const char *symbol); -static void *dlsym_auto_underscore_intern(void *handle, const char *symbol); -#endif - -/* Functions */ - -static void -debug(const char *fmt, ...) -{ -#if DEBUG > 1 - va_list arg; - va_start(arg, fmt); - fprintf(stderr, "DLDEBUG: "); - vfprintf(stderr, fmt, arg); - fprintf(stderr, "\n"); - fflush(stderr); - va_end(arg); -#endif -} - -static void -error(const char *str, ...) -{ - va_list arg; - struct dlthread *tss; - char *err_str; - va_start(arg, str); - tss = pthread_getspecific(dlerror_key); - err_str = tss->errstr; - SDL_strlcpy(err_str, "dlcompat: ", ERR_STR_LEN); - vsnprintf(err_str + 10, ERR_STR_LEN - 10, str, arg); - va_end(arg); - debug("ERROR: %s\n", err_str); - tss->errset = 1; -} - -static void -warning(const char *str) -{ -#if DEBUG > 0 - fprintf(stderr, "WARNING: dlcompat: %s\n", str); -#endif -} - -static const char * -safegetenv(const char *s) -{ - const char *ss = SDL_getenv(s); - return ss ? ss : ""; -} - -/* because this is only used for debugging and error reporting functions, we - * don't really care about how elegant it is... it could use the load - * commands to find the install name of the library, but... - */ -static const char * -get_lib_name(const struct mach_header *mh) -{ - unsigned long count = _dyld_image_count(); - unsigned long i; - const char *val = NULL; - if (mh) { - for (i = 0; i < count; i++) { - if (mh == _dyld_get_image_header(i)) { - val = _dyld_get_image_name(i); - break; - } - } - } - return val; -} - -/* Returns the mach_header for the module bu going through all the loaded images - * and finding the one with the same name as the module. There really ought to be - * an api for doing this, would be faster, but there isn't one right now - */ -static const struct mach_header * -get_mach_header_from_NSModule(NSModule mod) -{ - const char *mod_name = NSNameOfModule(mod); - const struct mach_header *mh = NULL; - unsigned long count = _dyld_image_count(); - unsigned long i; - debug("Module name: %s", mod_name); - for (i = 0; i < count; i++) { - if (!SDL_strcmp(mod_name, _dyld_get_image_name(i))) { - mh = _dyld_get_image_header(i); - break; - } - } - return mh; -} - - -/* Compute and return a list of all directories that we should search when - * trying to locate a module. We first look at the values of LD_LIBRARY_PATH - * and DYLD_LIBRARY_PATH, and then finally fall back to looking into - * /usr/lib and /lib. Since both of the environments variables can contain a - * list of colon seperated paths, we simply concat them and the two other paths - * into one big string, which we then can easily parse. - * Splitting this string into the actual path list is done by getSearchPath() - */ -static const char * -searchList() -{ - size_t buf_size; - static char *buf = NULL; - const char *ldlp = safegetenv("LD_LIBRARY_PATH"); - const char *dyldlp = safegetenv("DYLD_LIBRARY_PATH"); - const char *stdpath = SDL_getenv("DYLD_FALLBACK_LIBRARY_PATH"); - if (!stdpath) - stdpath = "/usr/local/lib:/lib:/usr/lib"; - if (!buf) { - buf_size = - SDL_strlen(ldlp) + SDL_strlen(dyldlp) + SDL_strlen(stdpath) + 4; - buf = SDL_malloc(buf_size); - SDL_snprintf(buf, buf_size, "%s%s%s%s%s%c", dyldlp, - (dyldlp[0] ? ":" : ""), ldlp, (ldlp[0] ? ":" : ""), - stdpath, '\0'); - } - return buf; -} - -/* Returns the ith search path from the list as computed by searchList() */ -static const char * -getSearchPath(int i) -{ - static const char *list = 0; - static char **path = (char **) 0; - static int end = 0; - static int numsize = MAX_SEARCH_PATHS; - static char **tmp; - /* So we can call SDL_free() in the "destructor" we use i=-1 to return the alloc'd array */ - if (i == -1) { - return (const char *) path; - } - if (!path) { - path = (char **) SDL_calloc(MAX_SEARCH_PATHS, sizeof(char **)); - } - if (!list && !end) - list = searchList(); - if (i >= (numsize)) { - debug("Increasing size for long PATH"); - tmp = - (char **) SDL_calloc((MAX_SEARCH_PATHS + numsize), - sizeof(char **)); - if (tmp) { - SDL_memcpy(tmp, path, sizeof(char **) * numsize); - SDL_free(path); - path = tmp; - numsize += MAX_SEARCH_PATHS; - } else { - return 0; - } - } - - while (!path[i] && !end) { - path[i] = strsep((char **) &list, ":"); - - if (path[i][0] == 0) - path[i] = 0; - end = (list == 0); - } - return path[i]; -} - -static const char * -getFullPath(int i, const char *file) -{ - static char buf[PATH_MAX]; - const char *path = getSearchPath(i); - if (path) { - SDL_snprintf(buf, PATH_MAX, "%s/%s", path, file); - } - return path ? buf : 0; -} - -/* Given a file name, try to determine the full path for that file. Starts - * its search in the current directory, and then tries all paths in the - * search list in the order they are specified there. - */ -static const struct stat * -findFile(const char *file, const char **fullPath) -{ - int i = 0; - static struct stat sbuf; - char *fileName; - debug("finding file %s", file); - *fullPath = file; - if (0 == stat(file, &sbuf)) - return &sbuf; - if (SDL_strchr(file, '/')) - return 0; /* If the path had a / we don't look in env var places */ - fileName = NULL; - if (!fileName) - fileName = (char *) file; - while ((*fullPath = getFullPath(i++, fileName))) { - if (0 == stat(*fullPath, &sbuf)) - return &sbuf; - } - ; - return 0; -} - -/* Determine whether a given dlstatus is valid or not */ -static int -isValidStatus(struct dlstatus *status) -{ - /* Walk the list to verify status is contained in it */ - struct dlstatus *dls = stqueue; - while (dls && status != dls) - dls = dls->next; - if (dls == 0) - error("invalid handle"); - else if ((dls->module == 0) || (dls->refs == 0)) - error("handle to closed library"); - else - return TRUE; - return FALSE; -} - -static inline int -isFlagSet(int mode, int flag) -{ - return (mode & flag) == flag; -} - -static struct dlstatus * -lookupStatus(const struct stat *sbuf) -{ - struct dlstatus *dls = stqueue; - debug("looking for status"); - while (dls && ( /* isFlagSet(dls->mode, RTLD_UNSHARED) */ 0 - || sbuf->st_dev != dls->device - || sbuf->st_ino != dls->inode)) - dls = dls->next; - return dls; -} - -static void -insertStatus(struct dlstatus *dls, const struct stat *sbuf) -{ - debug("inserting status"); - dls->inode = sbuf->st_ino; - dls->device = sbuf->st_dev; - dls->refs = 0; - dls->mode = 0; - if ((dls->flags & DL_IN_LIST) == 0) { - dls->next = stqueue; - stqueue = dls; - dls->flags |= DL_IN_LIST; - } -} - -static struct dlstatus * -allocStatus() -{ - struct dlstatus *dls; -#ifdef REUSE_STATUS - dls = stqueue; - while (dls && dls->module) - dls = dls->next; - if (!dls) -#endif - dls = SDL_calloc(sizeof(*dls), 1); - return dls; -} - -static int -promoteLocalToGlobal(struct dlstatus *dls) -{ - static int (*p) (NSModule module) = 0; - debug("promoting"); - if (!p) - _dyld_func_lookup("__dyld_NSMakePrivateModulePublic", (void **) &p); - return (dls->module == MAGIC_DYLIB_MOD) || (p && p(dls->module)); -} - -static void * -reference(struct dlstatus *dls, int mode) -{ - if (dls) { - if (dls->module == MAGIC_DYLIB_MOD && isFlagSet(mode, RTLD_LOCAL)) { - warning("trying to open a .dylib with RTLD_LOCAL"); - error("unable to open a .dylib with RTLD_LOCAL"); - return NULL; - } - if (isFlagSet(mode, RTLD_GLOBAL) && !isFlagSet(dls->mode, RTLD_GLOBAL) - && !promoteLocalToGlobal(dls)) { - error("unable to promote local module to global"); - return NULL; - } - dls->mode |= mode; - dls->refs++; - } else - debug("reference called with NULL argument"); - - return dls; -} - -static const struct mach_header * -my_find_image(const char *name) -{ - const struct mach_header *mh = 0; - const char *id = NULL; - int i = _dyld_image_count(); - int j; - mh = (struct mach_header *) - dyld_NSAddImage(name, NSADDIMAGE_OPTION_RETURN_ONLY_IF_LOADED | - NSADDIMAGE_OPTION_RETURN_ON_ERROR); - if (!mh) { - for (j = 0; j < i; j++) { - id = _dyld_get_image_name(j); - if (!SDL_strcmp(id, name)) { - mh = _dyld_get_image_header(j); - break; - } - } - } - return mh; -} - -/* - * dyld adds libraries by first adding the directly dependant libraries in link order, and - * then adding the dependencies for those libraries, so we should do the same... but we don't - * bother adding the extra dependencies, if the symbols are neither in the loaded image nor - * any of it's direct dependencies, then it probably isn't there. - */ -static NSSymbol -search_linked_libs(const struct mach_header *mh, const char *symbol) -{ - unsigned int n; - struct load_command *lc = 0; - struct mach_header *wh; - NSSymbol nssym = 0; - if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage - && dyld_NSLookupSymbolInImage) { - lc = (struct load_command *) ((char *) mh + - sizeof(struct mach_header)); - for (n = 0; n < mh->ncmds; - n++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { - if ((LC_LOAD_DYLIB == lc->cmd) - || (LC_LOAD_WEAK_DYLIB == lc->cmd)) { - if ((wh = (struct mach_header *) - my_find_image((char - *) (((struct dylib_command *) lc)->dylib. - name.offset + (char *) lc)))) { - if (dyld_NSIsSymbolNameDefinedInImage(wh, symbol)) { - nssym = dyld_NSLookupSymbolInImage(wh, - symbol, - NSLOOKUPSYMBOLINIMAGE_OPTION_BIND - | - NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); - break; - } - } - } - } - if ((!nssym) && NSIsSymbolNameDefined(symbol)) { - /* I've never seen this debug message... */ - debug("Symbol \"%s\" is defined but was not found", symbol); - } - } - return nssym; -} - -/* Up to the caller to SDL_free() returned string */ -static inline char * -dyld_error_str() -{ - NSLinkEditErrors dylder; - int dylderno; - const char *dylderrstr; - const char *dyldfile; - char *retStr = NULL; - NSLinkEditError(&dylder, &dylderno, &dyldfile, &dylderrstr); - if (dylderrstr && *dylderrstr) { - retStr = SDL_strdup(dylderrstr); - } - return retStr; -} - -static void * -dlsymIntern(struct dlstatus *dls, const char *symbol, int canSetError) -{ - NSSymbol nssym = 0; -#ifdef __GCC__ - void *caller = __builtin_return_address(1); /* Be *very* careful about inlining */ -#else - void *caller = NULL; -#endif - const struct mach_header *caller_mh = 0; - char *savedErrorStr = NULL; - resetdlerror(); -#ifndef RTLD_SELF -#define RTLD_SELF ((void *) -3) -#endif - if (NULL == dls) - dls = RTLD_SELF; - if ((RTLD_NEXT == dls) || (RTLD_SELF == dls)) { - if (dyld_NSIsSymbolNameDefinedInImage && dyld_NSLookupSymbolInImage - && caller) { - caller_mh = image_for_address(caller); - if (RTLD_SELF == dls) { - /* FIXME: We should be using the NSModule api, if SELF is an MH_BUNDLE - * But it appears to work anyway, and looking at the code in dyld_libfuncs.c - * this is acceptable. - */ - if (dyld_NSIsSymbolNameDefinedInImage(caller_mh, symbol)) { - nssym = dyld_NSLookupSymbolInImage(caller_mh, - symbol, - NSLOOKUPSYMBOLINIMAGE_OPTION_BIND - | - NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); - } - } - if (!nssym) { - if (RTLD_SELF == dls) - savedErrorStr = dyld_error_str(); - nssym = search_linked_libs(caller_mh, symbol); - } - } else { - if (canSetError) - error("RTLD_SELF and RTLD_NEXT are not supported"); - return NULL; - } - } - if (!nssym) { - - if (RTLD_DEFAULT == dls) { - dls = &mainStatus; - } - if (!isValidStatus(dls)) - return NULL; - - if (dls->module != MAGIC_DYLIB_MOD) { - nssym = NSLookupSymbolInModule(dls->module, symbol); - if (!nssym && NSIsSymbolNameDefined(symbol)) { - debug("Searching dependencies"); - savedErrorStr = dyld_error_str(); - nssym = - search_linked_libs(get_mach_header_from_NSModule - (dls->module), symbol); - } - } else if (dls->lib && dyld_NSIsSymbolNameDefinedInImage - && dyld_NSLookupSymbolInImage) { - if (dyld_NSIsSymbolNameDefinedInImage(dls->lib, symbol)) { - nssym = dyld_NSLookupSymbolInImage(dls->lib, - symbol, - NSLOOKUPSYMBOLINIMAGE_OPTION_BIND - | - NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR); - } else if (NSIsSymbolNameDefined(symbol)) { - debug("Searching dependencies"); - savedErrorStr = dyld_error_str(); - nssym = search_linked_libs(dls->lib, symbol); - } - } else if (dls->module == MAGIC_DYLIB_MOD) { - /* Global context, use NSLookupAndBindSymbol */ - if (NSIsSymbolNameDefined(symbol)) { - /* There doesn't seem to be a return on error option for this call??? - this is potentially broken, if binding fails, it will improperly - exit the application. */ - nssym = NSLookupAndBindSymbol(symbol); - } else { - if (savedErrorStr) - SDL_free(savedErrorStr); - savedErrorStr = SDL_malloc(256); - SDL_snprintf(savedErrorStr, 256, - "Symbol \"%s\" not in global context", symbol); - } - } - } - /* Error reporting */ - if (!nssym) { - if (!savedErrorStr || !SDL_strlen(savedErrorStr)) { - if (savedErrorStr) - SDL_free(savedErrorStr); - savedErrorStr = SDL_malloc(256); - SDL_snprintf(savedErrorStr, 256, "Symbol \"%s\" not found", - symbol); - } - if (canSetError) { - error(savedErrorStr); - } else { - debug(savedErrorStr); - } - if (savedErrorStr) - SDL_free(savedErrorStr); - return NULL; - } - return NSAddressOfSymbol(nssym); -} - -static struct dlstatus * -loadModule(const char *path, const struct stat *sbuf, int mode) -{ - NSObjectFileImage ofi = 0; - NSObjectFileImageReturnCode ofirc; - struct dlstatus *dls; - NSLinkEditErrors ler; - int lerno; - const char *errstr; - const char *file; - void (*init) (void); - - ofirc = NSCreateObjectFileImageFromFile(path, &ofi); - switch (ofirc) { - case NSObjectFileImageSuccess: - break; - case NSObjectFileImageInappropriateFile: - if (dyld_NSAddImage && dyld_NSIsSymbolNameDefinedInImage - && dyld_NSLookupSymbolInImage) { - if (isFlagSet(mode, RTLD_LOCAL)) { - warning("trying to open a .dylib with RTLD_LOCAL"); - error("unable to open this file with RTLD_LOCAL"); - return NULL; - } - } else { - error("opening this file is unsupported on this system"); - return NULL; - } - break; - case NSObjectFileImageFailure: - error("object file setup failure"); - return NULL; - case NSObjectFileImageArch: - error("no object for this architecture"); - return NULL; - case NSObjectFileImageFormat: - error("bad object file format"); - return NULL; - case NSObjectFileImageAccess: - error("can't read object file"); - return NULL; - default: - error("unknown error from NSCreateObjectFileImageFromFile()"); - return NULL; - } - dls = lookupStatus(sbuf); - if (!dls) { - dls = allocStatus(); - } - if (!dls) { - error("unable to allocate memory"); - return NULL; - } - // dls->lib = 0; - if (ofirc == NSObjectFileImageInappropriateFile) { - if ((dls->lib = - dyld_NSAddImage(path, NSADDIMAGE_OPTION_RETURN_ON_ERROR))) { - debug("Dynamic lib loaded at %ld", dls->lib); - ofi = MAGIC_DYLIB_OFI; - dls->module = MAGIC_DYLIB_MOD; - ofirc = NSObjectFileImageSuccess; - /* Although it is possible with a bit of work to modify this so it works and - functions with RTLD_NOW, I don't deem it necessary at the moment */ - } - if (!(dls->module)) { - NSLinkEditError(&ler, &lerno, &file, &errstr); - if (!errstr || (!SDL_strlen(errstr))) - error("Can't open this file type"); - else - error(errstr); - if ((dls->flags & DL_IN_LIST) == 0) { - SDL_free(dls); - } - return NULL; - } - } else { - dls->module = NSLinkModule(ofi, path, - NSLINKMODULE_OPTION_RETURN_ON_ERROR | - NSLINKMODULE_OPTION_PRIVATE | - (isFlagSet(mode, RTLD_NOW) ? - NSLINKMODULE_OPTION_BINDNOW : 0)); - NSDestroyObjectFileImage(ofi); - if (dls->module) { - dls->lib = get_mach_header_from_NSModule(dls->module); - } - } - if (!dls->module) { - NSLinkEditError(&ler, &lerno, &file, &errstr); - if ((dls->flags & DL_IN_LIST) == 0) { - SDL_free(dls); - } - error(errstr); - return NULL; - } - - insertStatus(dls, sbuf); - dls = reference(dls, mode); - if ((init = dlsymIntern(dls, "__init", 0))) { - debug("calling _init()"); - init(); - } - return dls; -} - -inline static void -dlcompat_init_check(void) -{ - static pthread_mutex_t l = PTHREAD_MUTEX_INITIALIZER; - static int init_done = 0; - - pthread_mutex_lock(&l); - if (!init_done) { - dlcompat_init_func(); - init_done = 1; - } - pthread_mutex_unlock(&l); -} - -static void -dlcompat_init_func(void) -{ - _dyld_func_lookup("__dyld_NSAddImage", (void **) &dyld_NSAddImage); - _dyld_func_lookup("__dyld_NSIsSymbolNameDefinedInImage", - (void **) &dyld_NSIsSymbolNameDefinedInImage); - _dyld_func_lookup("__dyld_NSLookupSymbolInImage", - (void **) &dyld_NSLookupSymbolInImage); - if (pthread_mutex_init(&dlcompat_mutex, NULL)) - exit(1); - if (pthread_key_create(&dlerror_key, &dlerrorfree)) - exit(1); -} - -static void -resetdlerror() -{ - struct dlthread *tss; - tss = pthread_getspecific(dlerror_key); - tss->errset = 0; -} - -static void -dlerrorfree(void *data) -{ - SDL_free(data); -} - -/* We kind of want a recursive lock here, but meet a little trouble - * because they are not available pre OS X 10.2, so we fake it - * using thread specific storage to keep a lock count - */ -static inline void -dolock(void) -{ - int err = 0; - struct dlthread *tss; - dlcompat_init_check(); - tss = pthread_getspecific(dlerror_key); - if (!tss) { - tss = SDL_malloc(sizeof(struct dlthread)); - tss->lockcnt = 0; - tss->errset = 0; - if (pthread_setspecific(dlerror_key, tss)) { - fprintf(stderr, "dlcompat: pthread_setspecific failed\n"); - exit(1); - } - } - if (!tss->lockcnt) - err = pthread_mutex_lock(&dlcompat_mutex); - tss->lockcnt = tss->lockcnt + 1; - if (err) - exit(err); -} - -static inline void -dounlock(void) -{ - int err = 0; - struct dlthread *tss; - tss = pthread_getspecific(dlerror_key); - tss->lockcnt = tss->lockcnt - 1; - if (!tss->lockcnt) - err = pthread_mutex_unlock(&dlcompat_mutex); - if (err) - exit(err); -} - -static void * -SDL_OSX_dlopen(const char *path, int mode) -{ - const struct stat *sbuf; - struct dlstatus *dls; - const char *fullPath; - - dolock(); - resetdlerror(); - if (!path) { - dls = &mainStatus; - goto dlopenok; - } - if (!(sbuf = findFile(path, &fullPath))) { - error("file \"%s\" not found", path); - goto dlopenerror; - } - /* Now checks that it hasn't been closed already */ - if ((dls = lookupStatus(sbuf)) && (dls->refs > 0)) { - /* debug("status found"); */ - dls = reference(dls, mode); - goto dlopenok; - } -#ifdef RTLD_NOLOAD - if (isFlagSet(mode, RTLD_NOLOAD)) { - error("no existing handle and RTLD_NOLOAD specified"); - goto dlopenerror; - } -#endif - if (isFlagSet(mode, RTLD_LAZY) && isFlagSet(mode, RTLD_NOW)) { - error("how can I load something both RTLD_LAZY and RTLD_NOW?"); - goto dlopenerror; - } - dls = loadModule(fullPath, sbuf, mode); - - dlopenok: - dounlock(); - return (void *) dls; - dlopenerror: - dounlock(); - return NULL; -} - -#if !FINK_BUILD -static void * -SDL_OSX_dlsym(void *dl_restrict handle, const char *dl_restrict symbol) -{ - int sym_len = SDL_strlen(symbol); - void *value = NULL; - char *malloc_sym = NULL; - dolock(); - malloc_sym = SDL_malloc(sym_len + 2); - if (malloc_sym) { - SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); - value = dlsymIntern(handle, malloc_sym, 1); - SDL_free(malloc_sym); - } else { - error("Unable to allocate memory"); - goto dlsymerror; - } - dounlock(); - return value; - dlsymerror: - dounlock(); - return NULL; -} -#endif - -#if FINK_BUILD - -static void * -dlsym_prepend_underscore(void *handle, const char *symbol) -{ - void *answer; - dolock(); - answer = dlsym_prepend_underscore_intern(handle, symbol); - dounlock(); - return answer; -} - -static void * -dlsym_prepend_underscore_intern(void *handle, const char *symbol) -{ -/* - * A quick and easy way for porting packages which call dlsym(handle,"sym") - * If the porter adds -Ddlsym=dlsym_prepend_underscore to the CFLAGS then - * this function will be called, and will add the required underscore. - * - * Note that I haven't figured out yet which should be "standard", prepend - * the underscore always, or not at all. These global functions need to go away - * for opendarwin. - */ - int sym_len = SDL_strlen(symbol); - void *value = NULL; - char *malloc_sym = NULL; - malloc_sym = SDL_malloc(sym_len + 2); - if (malloc_sym) { - SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); - value = dlsymIntern(handle, malloc_sym, 1); - SDL_free(malloc_sym); - } else { - error("Unable to allocate memory"); - } - return value; -} - -static void * -dlsym_auto_underscore(void *handle, const char *symbol) -{ - void *answer; - dolock(); - answer = dlsym_auto_underscore_intern(handle, symbol); - dounlock(); - return answer; - -} - -static void * -dlsym_auto_underscore_intern(void *handle, const char *symbol) -{ - struct dlstatus *dls = handle; - void *addr = 0; - addr = dlsymIntern(dls, symbol, 0); - if (!addr) - addr = dlsym_prepend_underscore_intern(handle, symbol); - return addr; -} - - -static void * -SDL_OSX_dlsym(void *dl_restrict handle, const char *dl_restrict symbol) -{ - struct dlstatus *dls = handle; - void *addr = 0; - dolock(); - addr = dlsymIntern(dls, symbol, 1); - dounlock(); - return addr; -} -#endif - -static int -SDL_OSX_dlclose(void *handle) -{ - struct dlstatus *dls = handle; - dolock(); - resetdlerror(); - if (!isValidStatus(dls)) { - goto dlcloseerror; - } - if (dls->module == MAGIC_DYLIB_MOD) { - const char *name; - if (!dls->lib) { - name = "global context"; - } else { - name = get_lib_name(dls->lib); - } - warning("trying to close a .dylib!"); - error("Not closing \"%s\" - dynamic libraries cannot be closed", - name); - goto dlcloseerror; - } - if (!dls->module) { - error("module already closed"); - goto dlcloseerror; - } - - if (dls->refs == 1) { - unsigned long options = 0; - void (*fini) (void); - if ((fini = dlsymIntern(dls, "__fini", 0))) { - debug("calling _fini()"); - fini(); - } - options |= NSUNLINKMODULE_OPTION_RESET_LAZY_REFERENCES; -#ifdef RTLD_NODELETE - if (isFlagSet(dls->mode, RTLD_NODELETE)) - options |= NSUNLINKMODULE_OPTION_KEEP_MEMORY_MAPPED; -#endif - if (!NSUnLinkModule(dls->module, options)) { - error("unable to unlink module"); - goto dlcloseerror; - } - dls->refs--; - dls->module = 0; - /* Note: the dlstatus struct dls is neither removed from the list - * nor is the memory it occupies freed. This shouldn't pose a - * problem in mostly all cases, though. - */ - } - dounlock(); - return 0; - dlcloseerror: - dounlock(); - return 1; -} - -static const char * -SDL_OSX_dlerror(void) -{ - struct dlthread *tss; - const char *err_str = NULL; - dlcompat_init_check(); - tss = pthread_getspecific(dlerror_key); - if (tss != NULL && tss->errset != 0) { - tss->errset = 0; - err_str = tss->errstr; - } - return (err_str); -} - -/* Given an address, return the mach_header for the image containing it - * or zero if the given address is not contained in any loaded images. - */ -static const struct mach_header * -image_for_address(const void *address) -{ - unsigned long i; - unsigned long j; - unsigned long count = _dyld_image_count(); - const struct mach_header *mh = 0; - struct load_command *lc = 0; - unsigned long addr = 0; - for (i = 0; i < count; i++) { - addr = (unsigned long) address - _dyld_get_image_vmaddr_slide(i); - mh = _dyld_get_image_header(i); - if (mh) { - lc = (struct load_command *) ((char *) mh + - sizeof(struct mach_header)); - for (j = 0; j < mh->ncmds; - j++, lc = - (struct load_command *) ((char *) lc + lc->cmdsize)) { - if (LC_SEGMENT == lc->cmd && - addr >= ((struct segment_command *) lc)->vmaddr && - addr < - ((struct segment_command *) lc)->vmaddr + - ((struct segment_command *) lc)->vmsize) { - goto image_found; - } - } - } - mh = 0; - } - image_found: - return mh; -} - -#if 0 /* unused */ -static int -SDL_OSX_dladdr(const void *dl_restrict p, SDL_OSX_Dl_info * dl_restrict info) -{ -/* - FIXME: USe the routine image_for_address. -*/ - unsigned long i; - unsigned long j; - unsigned long count = _dyld_image_count(); - struct mach_header *mh = 0; - struct load_command *lc = 0; - unsigned long addr = NULL; - unsigned long table_off = (unsigned long) 0; - int found = 0; - if (!info) - return 0; - dolock(); - resetdlerror(); - info->dli_fname = 0; - info->dli_fbase = 0; - info->dli_sname = 0; - info->dli_saddr = 0; -/* Some of this was swiped from code posted by Douglas Davidson - * to darwin-development AT lists DOT apple DOT com and slightly modified - */ - for (i = 0; i < count; i++) { - addr = (unsigned long) p - _dyld_get_image_vmaddr_slide(i); - mh = _dyld_get_image_header(i); - if (mh) { - lc = (struct load_command *) ((char *) mh + - sizeof(struct mach_header)); - for (j = 0; j < mh->ncmds; - j++, lc = - (struct load_command *) ((char *) lc + lc->cmdsize)) { - if (LC_SEGMENT == lc->cmd && - addr >= ((struct segment_command *) lc)->vmaddr && - addr < - ((struct segment_command *) lc)->vmaddr + - ((struct segment_command *) lc)->vmsize) { - info->dli_fname = _dyld_get_image_name(i); - info->dli_fbase = (void *) mh; - found = 1; - break; - } - } - if (found) - break; - } - } - if (!found) { - dounlock(); - return 0; - } - lc = (struct load_command *) ((char *) mh + sizeof(struct mach_header)); - for (j = 0; j < mh->ncmds; - j++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { - if (LC_SEGMENT == lc->cmd) { - if (!SDL_strcmp - (((struct segment_command *) lc)->segname, "__LINKEDIT")) - break; - } - } - table_off = - ((unsigned long) ((struct segment_command *) lc)->vmaddr) - - ((unsigned long) ((struct segment_command *) lc)->fileoff) + - _dyld_get_image_vmaddr_slide(i); - debug("table off %x", table_off); - - lc = (struct load_command *) ((char *) mh + sizeof(struct mach_header)); - for (j = 0; j < mh->ncmds; - j++, lc = (struct load_command *) ((char *) lc + lc->cmdsize)) { - if (LC_SYMTAB == lc->cmd) { - - struct nlist *symtable = - (struct nlist *) (((struct symtab_command *) lc)->symoff + - table_off); - unsigned long numsyms = ((struct symtab_command *) lc)->nsyms; - struct nlist *nearest = NULL; - unsigned long diff = 0xffffffff; - unsigned long strtable = - (unsigned long) (((struct symtab_command *) lc)->stroff + - table_off); - debug("symtable %x", symtable); - for (i = 0; i < numsyms; i++) { - /* Ignore the following kinds of Symbols */ - if ((!symtable->n_value) /* Undefined */ - ||(symtable->n_type >= N_PEXT) /* Debug symbol */ - ||(!(symtable->n_type & N_EXT)) /* Local Symbol */ - ) { - symtable++; - continue; - } - if ((addr >= symtable->n_value) - && (diff >= (symtable->n_value - addr))) { - diff = (unsigned long) symtable->n_value - addr; - nearest = symtable; - } - symtable++; - } - if (nearest) { - info->dli_saddr = nearest->n_value + ((void *) p - addr); - info->dli_sname = (char *) (strtable + nearest->n_un.n_strx); - } - } - } - dounlock(); - return 1; -} -#endif - -/* - * Implement the dlfunc() interface, which behaves exactly the same as - * dlsym() except that it returns a function pointer instead of a data - * pointer. This can be used by applications to avoid compiler warnings - * about undefined behavior, and is intended as prior art for future - * POSIX standardization. This function requires that all pointer types - * have the same representation, which is true on all platforms FreeBSD - * runs on, but is not guaranteed by the C standard. - */ -#if 0 -static dlfunc_t -SDL_OSX_dlfunc(void *dl_restrict handle, const char *dl_restrict symbol) -{ - union - { - void *d; - dlfunc_t f; - } rv; - int sym_len = SDL_strlen(symbol); - char *malloc_sym = NULL; - dolock(); - malloc_sym = SDL_malloc(sym_len + 2); - if (malloc_sym) { - SDL_snprintf(malloc_sym, sym_len + 2, "_%s", symbol); - rv.d = dlsymIntern(handle, malloc_sym, 1); - SDL_free(malloc_sym); - } else { - error("Unable to allocate memory"); - goto dlfuncerror; - } - dounlock(); - return rv.f; - dlfuncerror: - dounlock(); - return NULL; -} -#endif - - - -/* dlcompat ends, here's the SDL interface... --ryan. */ - - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent library loading routines */ - -#include "SDL_loadso.h" - -void * -SDL_LoadObject(const char *sofile) -{ - void *handle = SDL_OSX_dlopen(sofile, RTLD_NOW); - const char *loaderror = SDL_OSX_dlerror(); - if (handle == NULL) { - SDL_SetError("Failed loading %s: %s", sofile, loaderror); - } - return (handle); -} - -void * -SDL_LoadFunction(void *handle, const char *name) -{ - void *symbol = SDL_OSX_dlsym(handle, name); - if (symbol == NULL) { - SDL_SetError("Failed loading %s: %s", name, SDL_OSX_dlerror()); - } - return (symbol); -} - -void -SDL_UnloadObject(void *handle) -{ - if (handle != NULL) { - SDL_OSX_dlclose(handle); - } -} - -#endif /* SDL_LOADSO_DLCOMPAT */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/loadso/win32/SDL_sysloadso.c b/project/jni/sdl-1.3/src/loadso/win32/SDL_sysloadso.c deleted file mode 100644 index ad8179802..000000000 --- a/project/jni/sdl-1.3/src/loadso/win32/SDL_sysloadso.c +++ /dev/null @@ -1,145 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifdef SDL_LOADSO_WIN32 - -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* System dependent library loading routines */ - -#define WIN32_LEAN_AND_MEAN -#include - -#include "SDL_loadso.h" - -void * -SDL_LoadObject(const char *sofile) -{ - void *handle = NULL; - const char *loaderror = "Unknown error"; - -#if defined(_WIN32_WCE) - char errbuf[512]; - - wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); - wchar_t *sofile_t = SDL_malloc((MAX_PATH + 1) * sizeof(wchar_t)); - - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t, - MAX_PATH); - handle = (void *) LoadLibrary(sofile_t); - - /* Generate an error message if all loads failed */ - if (handle == NULL) { - FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM), - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - errbuf_t, SDL_arraysize(errbuf), NULL); - WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); - loaderror = errbuf; - } - - SDL_free(sofile_t); - SDL_free(errbuf_t); - -#else /*if defined(__WIN32__) */ - char errbuf[512]; - - handle = (void *) LoadLibrary(sofile); - - /* Generate an error message if all loads failed */ - if (handle == NULL) { - FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM), - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - errbuf, SDL_arraysize(errbuf), NULL); - loaderror = errbuf; - } -#endif - - if (handle == NULL) { - SDL_SetError("Failed loading %s: %s", sofile, loaderror); - } - return (handle); -} - -void * -SDL_LoadFunction(void *handle, const char *name) -{ - void *symbol = NULL; - const char *loaderror = "Unknown error"; - -#if defined(_WIN32_WCE) - char errbuf[512]; - int length = SDL_strlen(name); - - wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t)); - wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t)); - - MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length + 1); - - symbol = (void *) GetProcAddress((HMODULE) handle, name_t); - if (symbol == NULL) { - FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM), - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - errbuf_t, SDL_arraysize(errbuf), NULL); - WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL); - loaderror = errbuf; - } - - SDL_free(name_t); - SDL_free(errbuf_t); - -#else /*if defined(WIN32) */ - char errbuf[512]; - - symbol = (void *) GetProcAddress((HMODULE) handle, name); - if (symbol == NULL) { - FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS | - FORMAT_MESSAGE_FROM_SYSTEM), - NULL, GetLastError(), - MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), - errbuf, SDL_arraysize(errbuf), NULL); - loaderror = errbuf; - } -#endif - - if (symbol == NULL) { - SDL_SetError("Failed loading %s: %s", name, loaderror); - } - return (symbol); -} - -void -SDL_UnloadObject(void *handle) -{ - if (handle != NULL) { - FreeLibrary((HMODULE) handle); - } -} - -#endif /* SDL_LOADSO_WIN32 */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/loadso/windows/SDL_sysloadso.c b/project/jni/sdl-1.3/src/loadso/windows/SDL_sysloadso.c new file mode 100644 index 000000000..cd5d1012a --- /dev/null +++ b/project/jni/sdl-1.3/src/loadso/windows/SDL_sysloadso.c @@ -0,0 +1,79 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef SDL_LOADSO_WINDOWS + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* System dependent library loading routines */ + +#include "../../core/windows/SDL_windows.h" + +#include "SDL_loadso.h" + +void * +SDL_LoadObject(const char *sofile) +{ + LPTSTR tstr = WIN_UTF8ToString(sofile); + void *handle = (void *) LoadLibrary(tstr); + SDL_free(tstr); + + /* Generate an error message if all loads failed */ + if (handle == NULL) { + char errbuf[512]; + SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); + SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf)); + WIN_SetError(errbuf); + } + return handle; +} + +void * +SDL_LoadFunction(void *handle, const char *name) +{ +#ifdef _WIN32_WCE + LPTSTR tstr = WIN_UTF8ToString(name); + void *symbol = (void *) GetProcAddress((HMODULE) handle, tstr); + SDL_free(tstr); +#else + void *symbol = (void *) GetProcAddress((HMODULE) handle, name); +#endif + + if (symbol == NULL) { + char errbuf[512]; + SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf)); + SDL_strlcat(errbuf, name, SDL_arraysize(errbuf)); + WIN_SetError(errbuf); + } + return symbol; +} + +void +SDL_UnloadObject(void *handle) +{ + if (handle != NULL) { + FreeLibrary((HMODULE) handle); + } +} + +#endif /* SDL_LOADSO_WINDOWS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/main/beos/SDL_BApp.h b/project/jni/sdl-1.3/src/main/beos/SDL_BApp.h new file mode 100644 index 000000000..9f9d5a25f --- /dev/null +++ b/project/jni/sdl-1.3/src/main/beos/SDL_BApp.h @@ -0,0 +1,380 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#ifndef SDL_BAPP_H +#define SDL_BAPP_H + +#include +#include + +#include "../../video/bwindow/SDL_bkeyboard.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "SDL_config.h" + +#include "SDL_video.h" + +/* Local includes */ +#include "../../events/SDL_events_c.h" +#include "../../video/bwindow/SDL_bkeyboard.h" +#include "../../video/bwindow/SDL_bframebuffer.h" + +#ifdef __cplusplus +} +#endif + +#include + + + + +/* Forward declarations */ +class SDL_BWin; + +/* Message constants */ +enum ToSDL { + /* Intercepted by BWindow on its way to BView */ + BAPP_MOUSE_MOVED, + BAPP_MOUSE_BUTTON, + BAPP_MOUSE_WHEEL, + BAPP_KEY, + BAPP_REPAINT, /* from _UPDATE_ */ + /* From BWindow */ + BAPP_MAXIMIZE, /* from B_ZOOM */ + BAPP_MINIMIZE, + BAPP_RESTORE, /* TODO: IMPLEMENT! */ + BAPP_SHOW, + BAPP_HIDE, + BAPP_MOUSE_FOCUS, /* caused by MOUSE_MOVE */ + BAPP_KEYBOARD_FOCUS, /* from WINDOW_ACTIVATED */ + BAPP_WINDOW_CLOSE_REQUESTED, + BAPP_WINDOW_MOVED, + BAPP_WINDOW_RESIZED, + BAPP_SCREEN_CHANGED +}; + + + +/* Create a descendant of BApplication */ +class SDL_BApp : public BApplication { +public: + SDL_BApp(const char* signature) : + BApplication(signature) { + _current_context = NULL; + } + + + virtual ~SDL_BApp() { + } + + + + /* Event-handling functions */ + virtual void MessageReceived(BMessage* message) { + /* Sort out SDL-related messages */ + switch ( message->what ) { + case BAPP_MOUSE_MOVED: + _HandleMouseMove(message); + break; + + case BAPP_MOUSE_BUTTON: + _HandleMouseButton(message); + break; + + case BAPP_MOUSE_WHEEL: + _HandleMouseWheel(message); + break; + + case BAPP_KEY: + _HandleKey(message); + break; + + case BAPP_REPAINT: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_EXPOSED); + break; + + case BAPP_MAXIMIZE: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MAXIMIZED); + break; + + case BAPP_MINIMIZE: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_MINIMIZED); + break; + + case BAPP_SHOW: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_SHOWN); + break; + + case BAPP_HIDE: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_HIDDEN); + break; + + case BAPP_MOUSE_FOCUS: + _HandleMouseFocus(message); + break; + + case BAPP_KEYBOARD_FOCUS: + _HandleKeyboardFocus(message); + break; + + case BAPP_WINDOW_CLOSE_REQUESTED: + _HandleBasicWindowEvent(message, SDL_WINDOWEVENT_CLOSE); + break; + + case BAPP_WINDOW_MOVED: + _HandleWindowMoved(message); + break; + + case BAPP_WINDOW_RESIZED: + _HandleWindowResized(message); + break; + + case BAPP_SCREEN_CHANGED: + /* TODO: Handle screen resize or workspace change */ + break; + + default: + BApplication::MessageReceived(message); + break; + } + } + + /* Window creation/destruction methods */ + int32 GetID(SDL_Window *win) { + int32 i; + for(i = 0; i < _GetNumWindowSlots(); ++i) { + if( GetSDLWindow(i) == NULL ) { + _SetSDLWindow(win, i); + return i; + } + } + + /* Expand the vector if all slots are full */ + if( i == _GetNumWindowSlots() ) { + _PushBackWindow(win); + return i; + } + + /* TODO: error handling */ + return 0; + } + + /* FIXME: Bad coding practice, but I can't include SDL_BWin.h here. Is + there another way to do this? */ + void ClearID(SDL_BWin *bwin); /* Defined in SDL_BeApp.cc */ + + + SDL_Window *GetSDLWindow(int32 winID) { + return _window_map[winID]; + } + + void SetCurrentContext(BGLView *newContext) { + if(_current_context) + _current_context->UnlockGL(); + _current_context = newContext; + _current_context->LockGL(); + } +private: + /* Event management */ + void _HandleBasicWindowEvent(BMessage *msg, int32 sdlEventType) { + SDL_Window *win; + int32 winID; + if( + !_GetWinID(msg, &winID) + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendWindowEvent(win, sdlEventType, 0, 0); + } + + void _HandleMouseMove(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 x = 0, y = 0; + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("x", &x) != B_OK || /* x movement */ + msg->FindInt32("y", &y) != B_OK /* y movement */ + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendMouseMotion(win, 0, x, y); + + /* Tell the application that the mouse passed over, redraw needed */ + BE_UpdateWindowFramebuffer(NULL,win,NULL,-1); + } + + void _HandleMouseButton(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 button, state; /* left/middle/right, pressed/released */ + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("button-id", &button) != B_OK || + msg->FindInt32("button-state", &state) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendMouseButton(win, state, button); + } + + void _HandleMouseWheel(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 xTicks, yTicks; + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("xticks", &xTicks) != B_OK || + msg->FindInt32("yticks", &yTicks) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendMouseWheel(win, xTicks, yTicks); + } + + void _HandleKey(BMessage *msg) { + int32 scancode, state; /* scancode, pressed/released */ + if( + msg->FindInt32("key-state", &state) != B_OK || + msg->FindInt32("key-scancode", &scancode) != B_OK + ) { + return; + } + + /* Make sure this isn't a repeated event (key pressed and held) */ + if(state == SDL_PRESSED && BE_GetKeyState(scancode) == SDL_PRESSED) { + return; + } + BE_SetKeyState(scancode, state); + SDL_SendKeyboardKey(state, BE_GetScancodeFromBeKey(scancode)); + } + + void _HandleMouseFocus(BMessage *msg) { + SDL_Window *win; + int32 winID; + bool bSetFocus; /* If false, lose focus */ + if( + !_GetWinID(msg, &winID) || + msg->FindBool("focusGained", &bSetFocus) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + if(bSetFocus) { + SDL_SetMouseFocus(win); + } else if(SDL_GetMouseFocus() == win) { + /* Only lose all focus if this window was the current focus */ + SDL_SetMouseFocus(NULL); + } + } + + void _HandleKeyboardFocus(BMessage *msg) { + SDL_Window *win; + int32 winID; + bool bSetFocus; /* If false, lose focus */ + if( + !_GetWinID(msg, &winID) || + msg->FindBool("focusGained", &bSetFocus) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + if(bSetFocus) { + SDL_SetKeyboardFocus(win); + } else if(SDL_GetKeyboardFocus() == win) { + /* Only lose all focus if this window was the current focus */ + SDL_SetKeyboardFocus(NULL); + } + } + + void _HandleWindowMoved(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 xPos, yPos; + /* Get the window id and new x/y position of the window */ + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("window-x", &xPos) != B_OK || + msg->FindInt32("window-y", &yPos) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendWindowEvent(win, SDL_WINDOWEVENT_MOVED, xPos, yPos); + } + + void _HandleWindowResized(BMessage *msg) { + SDL_Window *win; + int32 winID; + int32 w, h; + /* Get the window id ]and new x/y position of the window */ + if( + !_GetWinID(msg, &winID) || + msg->FindInt32("window-w", &w) != B_OK || + msg->FindInt32("window-h", &h) != B_OK + ) { + return; + } + win = GetSDLWindow(winID); + SDL_SendWindowEvent(win, SDL_WINDOWEVENT_RESIZED, w, h); + } + + bool _GetWinID(BMessage *msg, int32 *winID) { + return msg->FindInt32("window-id", winID) == B_OK; + } + + + + /* Vector functions: Wraps vector stuff in case we need to change + implementation */ + void _SetSDLWindow(SDL_Window *win, int32 winID) { + _window_map[winID] = win; + } + + int32 _GetNumWindowSlots() { + return _window_map.size(); + } + + + void _PopBackWindow() { + _window_map.pop_back(); + } + + void _PushBackWindow(SDL_Window *win) { + _window_map.push_back(win); + } + + + /* Members */ + vector _window_map; /* Keeps track of SDL_Windows by index-id*/ + + display_mode *_saved_mode; + BGLView *_current_context; +}; + +#endif diff --git a/project/jni/sdl-1.3/src/main/beos/SDL_BeApp.cc b/project/jni/sdl-1.3/src/main/beos/SDL_BeApp.cc index 2bf322595..33a7330be 100644 --- a/project/jni/sdl-1.3/src/main/beos/SDL_BeApp.cc +++ b/project/jni/sdl-1.3/src/main/beos/SDL_BeApp.cc @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#ifdef __BEOS__ + /* Handle the BeApp specific portions of the application */ #include @@ -28,11 +29,17 @@ #include #include +#include "SDL_BApp.h" /* SDL_BApp class definition */ #include "SDL_BeApp.h" #include "SDL_thread.h" #include "SDL_timer.h" #include "SDL_error.h" +#include "../../video/bwindow/SDL_BWin.h" + +#ifdef __cplusplus +extern "C" { +#endif /* Flag to tell whether or not the Be application is active or not */ int SDL_BeAppActive = 0; static SDL_Thread *SDL_AppThread = NULL; @@ -42,7 +49,7 @@ StartBeApp(void *unused) { BApplication *App; - App = new BApplication("application/x-SDL-executable"); + App = new SDL_BApp("application/x-SDL-executable"); App->Run(); delete App; @@ -55,7 +62,7 @@ SDL_InitBeApp(void) { /* Create the BApplication that handles appserver interaction */ if (SDL_BeAppActive <= 0) { - SDL_AppThread = SDL_CreateThread(StartBeApp, NULL); + SDL_AppThread = SDL_CreateThread(StartBeApp, "SDLApplication", NULL); if (SDL_AppThread == NULL) { SDL_SetError("Couldn't create BApplication thread"); return (-1); @@ -111,4 +118,20 @@ SDL_QuitBeApp(void) } } +#ifdef __cplusplus +} +#endif + +/* SDL_BApp functions */ +void SDL_BApp::ClearID(SDL_BWin *bwin) { + _SetSDLWindow(NULL, bwin->GetID()); + int32 i = _GetNumWindowSlots() - 1; + while(i >= 0 && GetSDLWindow(i) == NULL) { + _PopBackWindow(); + --i; + } +} + +#endif /* __BEOS__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/main/beos/SDL_BeApp.h b/project/jni/sdl-1.3/src/main/beos/SDL_BeApp.h index 7733d4a71..7d95e32be 100644 --- a/project/jni/sdl-1.3/src/main/beos/SDL_BeApp.h +++ b/project/jni/sdl-1.3/src/main/beos/SDL_BeApp.h @@ -1,26 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" + +#ifdef __cplusplus +extern "C" { +#endif /* Handle the BeApp specific portions of the application */ /* Initialize the Be Application, if it's not already started */ @@ -32,3 +35,7 @@ extern void SDL_QuitBeApp(void); /* Flag to tell whether the app is active or not */ extern int SDL_BeAppActive; /* vi: set ts=4 sw=4 expandtab: */ + +#ifdef __cplusplus +} +#endif diff --git a/project/jni/sdl-1.3/src/main/win32/SDL_win32_main.c b/project/jni/sdl-1.3/src/main/windows/SDL_windows_main.c similarity index 98% rename from project/jni/sdl-1.3/src/main/win32/SDL_win32_main.c rename to project/jni/sdl-1.3/src/main/windows/SDL_windows_main.c index ef50d5d2c..4d60e2d4e 100644 --- a/project/jni/sdl-1.3/src/main/win32/SDL_win32_main.c +++ b/project/jni/sdl-1.3/src/main/windows/SDL_windows_main.c @@ -3,6 +3,9 @@ The WinMain function -- calls your program's main() function */ +#include "SDL_config.h" + +#ifdef __WIN32__ #include #include @@ -202,4 +205,6 @@ WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPTSTR szCmdLine, int sw) return 0; } +#endif /* __WIN32__ */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/main/win32/version.rc b/project/jni/sdl-1.3/src/main/windows/version.rc similarity index 100% rename from project/jni/sdl-1.3/src/main/win32/version.rc rename to project/jni/sdl-1.3/src/main/windows/version.rc diff --git a/project/jni/sdl-1.3/src/power/SDL_power.c b/project/jni/sdl-1.3/src/power/SDL_power.c index d62fa4e9a..024f7df7e 100644 --- a/project/jni/sdl-1.3/src/power/SDL_power.c +++ b/project/jni/sdl-1.3/src/power/SDL_power.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #include "SDL_power.h" diff --git a/project/jni/sdl-1.3/src/power/beos/SDL_syspower.c b/project/jni/sdl-1.3/src/power/beos/SDL_syspower.c index c6741417d..eb49628b5 100644 --- a/project/jni/sdl-1.3/src/power/beos/SDL_syspower.c +++ b/project/jni/sdl-1.3/src/power/beos/SDL_syspower.c @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_BEOS +#if SDL_POWER_BEOS #include #include @@ -51,7 +50,8 @@ SDL_GetPowerInfo_BeOS(SDL_PowerState * state, int *seconds, int *percent) uint8 battery_flags; uint8 battery_life; uint32 battery_time; - + int rc; + if (fd == -1) { return SDL_FALSE; /* maybe some other method will work? */ } @@ -78,7 +78,7 @@ SDL_GetPowerInfo_BeOS(SDL_PowerState * state, int *seconds, int *percent) if (battery_status == 0xFF) { battery_flags = 0xFF; } else { - battery_flags = (1 << status.battery_status); + battery_flags = (1 << battery_status); } } diff --git a/project/jni/sdl-1.3/src/power/linux/SDL_syspower.c b/project/jni/sdl-1.3/src/power/linux/SDL_syspower.c index 1052ed19f..2e409488c 100644 --- a/project/jni/sdl-1.3/src/power/linux/SDL_syspower.c +++ b/project/jni/sdl-1.3/src/power/linux/SDL_syspower.c @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_LINUX +#if SDL_POWER_LINUX #include #include @@ -129,7 +128,6 @@ check_proc_acpi_battery(const char * node, SDL_bool * have_battery, char *val = NULL; SDL_bool charge = SDL_FALSE; SDL_bool choose = SDL_FALSE; - SDL_bool is_ac = SDL_FALSE; int maximum = -1; int remaining = -1; int secs = -1; @@ -215,13 +213,6 @@ check_proc_acpi_ac_adapter(const char * node, SDL_bool * have_ac) char *ptr = NULL; char *key = NULL; char *val = NULL; - SDL_bool charge = SDL_FALSE; - SDL_bool choose = SDL_FALSE; - SDL_bool is_ac = SDL_FALSE; - int maximum = -1; - int remaining = -1; - int secs = -1; - int pct = -1; if (!load_acpi_file(base, node, "state", state, sizeof (state))) { return; diff --git a/project/jni/sdl-1.3/src/power/macosx/SDL_syspower.c b/project/jni/sdl-1.3/src/power/macosx/SDL_syspower.c index 6161db2da..b76b5c650 100644 --- a/project/jni/sdl-1.3/src/power/macosx/SDL_syspower.c +++ b/project/jni/sdl-1.3/src/power/macosx/SDL_syspower.c @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_MACOSX +#if SDL_POWER_MACOSX #include #include diff --git a/project/jni/sdl-1.3/src/power/nds/SDL_syspower.c b/project/jni/sdl-1.3/src/power/nds/SDL_syspower.c index 65e8e8190..e0a92f235 100644 --- a/project/jni/sdl-1.3/src/power/nds/SDL_syspower.c +++ b/project/jni/sdl-1.3/src/power/nds/SDL_syspower.c @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_NINTENDODS +#if SDL_POWER_NINTENDODS #include "SDL_power.h" diff --git a/project/jni/sdl-1.3/src/power/uikit/SDL_syspower.h b/project/jni/sdl-1.3/src/power/uikit/SDL_syspower.h new file mode 100644 index 000000000..2bec9e171 --- /dev/null +++ b/project/jni/sdl-1.3/src/power/uikit/SDL_syspower.h @@ -0,0 +1,32 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_POWER_UIKIT + +#include "SDL_power.h" + +void SDL_UIKit_UpdateBatteryMonitoring(void); +SDL_bool SDL_GetPowerInfo_UIKit(SDL_PowerState * state, int *seconds, int *percent); + +#endif /* SDL_POWER_UIKIT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/power/uikit/SDL_syspower.m b/project/jni/sdl-1.3/src/power/uikit/SDL_syspower.m index b38858a28..2766ef5dd 100644 --- a/project/jni/sdl-1.3/src/power/uikit/SDL_syspower.m +++ b/project/jni/sdl-1.3/src/power/uikit/SDL_syspower.m @@ -1,34 +1,34 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_UIKIT +#if SDL_POWER_UIKIT #import #include "SDL_power.h" #include "SDL_timer.h" #include "SDL_assert.h" +#include "SDL_syspower.h" // turn off the battery monitor if it's been more than X ms since last check. static const int BATTERY_MONITORING_TIMEOUT = 3000; diff --git a/project/jni/sdl-1.3/src/power/windows/SDL_syspower.c b/project/jni/sdl-1.3/src/power/windows/SDL_syspower.c index af007d4d8..0d75a2bcc 100644 --- a/project/jni/sdl-1.3/src/power/windows/SDL_syspower.c +++ b/project/jni/sdl-1.3/src/power/windows/SDL_syspower.c @@ -1,42 +1,49 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef SDL_POWER_DISABLED -#ifdef SDL_POWER_WINDOWS +#if SDL_POWER_WINDOWS -#define WIN32_LEAN_AND_MEAN -#include +#include "../../core/windows/SDL_windows.h" #include "SDL_power.h" SDL_bool SDL_GetPowerInfo_Windows(SDL_PowerState * state, int *seconds, int *percent) { +#ifdef _WIN32_WCE + SYSTEM_POWER_STATUS_EX status; +#else SYSTEM_POWER_STATUS status; +#endif SDL_bool need_details = SDL_FALSE; /* This API should exist back to Win95 and Windows CE. */ - if (!GetSystemPowerStatus(&status)) { +#ifdef _WIN32_WCE + if (!GetSystemPowerStatusEx(&status, FALSE)) +#else + if (!GetSystemPowerStatus(&status)) +#endif + { /* !!! FIXME: push GetLastError() into SDL_GetError() */ *state = SDL_POWERSTATE_UNKNOWN; } else if (status.BatteryFlag == 0xFF) { /* unknown state */ diff --git a/project/jni/sdl-1.3/src/render/SDL_render.c b/project/jni/sdl-1.3/src/render/SDL_render.c new file mode 100644 index 000000000..4209953e2 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/SDL_render.c @@ -0,0 +1,1221 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* The SDL 2D rendering system */ + +#include "SDL_hints.h" +#include "SDL_log.h" +#include "SDL_render.h" +#include "SDL_sysrender.h" +#include "software/SDL_render_sw_c.h" +#include + + +#define SDL_WINDOWRENDERDATA "_SDL_WindowRenderData" + +#define CHECK_RENDERER_MAGIC(renderer, retval) \ + if (!renderer || renderer->magic != &renderer_magic) { \ + SDL_SetError("Invalid renderer"); \ + return retval; \ + } + +#define CHECK_TEXTURE_MAGIC(texture, retval) \ + if (!texture || texture->magic != &texture_magic) { \ + SDL_SetError("Invalid texture"); \ + return retval; \ + } + + +static const SDL_RenderDriver *render_drivers[] = { +#if !SDL_RENDER_DISABLED +#if SDL_VIDEO_RENDER_D3D + &D3D_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_OGL + &GL_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_OGL_ES2 + &GLES2_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_OGL_ES + &GLES_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_DIRECTFB + &DirectFB_RenderDriver, +#endif +#if SDL_VIDEO_RENDER_NDS + &NDS_RenderDriver, +#endif + &SW_RenderDriver +#endif /* !SDL_RENDER_DISABLED */ +}; +static char renderer_magic; +static char texture_magic; + +int +SDL_GetNumRenderDrivers(void) +{ + return SDL_arraysize(render_drivers); +} + +int +SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info) +{ + if (index < 0 || index >= SDL_GetNumRenderDrivers()) { + SDL_SetError("index must be in the range of 0 - %d", + SDL_GetNumRenderDrivers() - 1); + return -1; + } + *info = render_drivers[index]->info; + return 0; +} + +static int +SDL_RendererEventWatch(void *userdata, SDL_Event *event) +{ + SDL_Renderer *renderer = (SDL_Renderer *)userdata; + + if (event->type == SDL_WINDOWEVENT) { + SDL_Window *window = SDL_GetWindowFromID(event->window.windowID); + if (window == renderer->window) { + if (renderer->WindowEvent) { + renderer->WindowEvent(renderer, &event->window); + } + + if (event->window.event == SDL_WINDOWEVENT_SIZE_CHANGED) { + /* Try to keep the previous viewport centered */ + int w, h; + SDL_Rect viewport; + + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_RendererEventWatch(): window %p", window); + SDL_GetWindowSize(window, &w, &h); + viewport.x = (w - renderer->viewport.w) / 2; + viewport.y = (h - renderer->viewport.h) / 2; + viewport.w = renderer->viewport.w; + viewport.h = renderer->viewport.h; + SDL_RenderSetViewport(renderer, &viewport); + } else if (event->window.event == SDL_WINDOWEVENT_MINIMIZED) { + renderer->minimized = SDL_TRUE; + } else if (event->window.event == SDL_WINDOWEVENT_RESTORED) { + renderer->minimized = SDL_FALSE; + } + } + } + return 0; +} + +SDL_Renderer * +SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) +{ + SDL_Renderer *renderer = NULL; + int n = SDL_GetNumRenderDrivers(); + const char *hint; + + if (!window) { + SDL_SetError("Invalid window"); + return NULL; + } + + if (SDL_GetRenderer(window)) { + SDL_SetError("Renderer already associated with window"); + return NULL; + } + + hint = SDL_GetHint(SDL_HINT_RENDER_VSYNC); + if (hint) { + if (*hint == '0') { + flags &= ~SDL_RENDERER_PRESENTVSYNC; + } else { + flags |= SDL_RENDERER_PRESENTVSYNC; + } + } + + if (index < 0) { + hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER); + if (hint) { + for (index = 0; index < n; ++index) { + const SDL_RenderDriver *driver = render_drivers[index]; + + if (SDL_strcasecmp(hint, driver->info.name) == 0) { + /* Create a new renderer instance */ + renderer = driver->CreateRenderer(window, flags); + break; + } + } + } + + if (!renderer) { + for (index = 0; index < n; ++index) { + const SDL_RenderDriver *driver = render_drivers[index]; + + if ((driver->info.flags & flags) == flags) { + /* Create a new renderer instance */ + renderer = driver->CreateRenderer(window, flags); + if (renderer) { + /* Yay, we got one! */ + break; + } + } + } + } + if (index == n) { + SDL_SetError("Couldn't find matching render driver"); + return NULL; + } + } else { + if (index >= SDL_GetNumRenderDrivers()) { + SDL_SetError("index must be -1 or in the range of 0 - %d", + SDL_GetNumRenderDrivers() - 1); + return NULL; + } + /* Create a new renderer instance */ + renderer = render_drivers[index]->CreateRenderer(window, flags); + } + + if (renderer) { + renderer->magic = &renderer_magic; + renderer->window = window; + + if (SDL_GetWindowFlags(window) & SDL_WINDOW_MINIMIZED) { + renderer->minimized = SDL_TRUE; + } else { + renderer->minimized = SDL_FALSE; + } + + SDL_SetWindowData(window, SDL_WINDOWRENDERDATA, renderer); + + SDL_RenderSetViewport(renderer, NULL); + + SDL_AddEventWatch(SDL_RendererEventWatch, renderer); + + SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, + "Created renderer: %s", renderer->info.name); + } + return renderer; +} + +SDL_Renderer * +SDL_CreateSoftwareRenderer(SDL_Surface * surface) +{ +#if !SDL_RENDER_DISABLED + SDL_Renderer *renderer; + + renderer = SW_CreateRendererForSurface(surface); + + if (renderer) { + renderer->magic = &renderer_magic; + + SDL_RenderSetViewport(renderer, NULL); + } + return renderer; +#else + SDL_SetError("SDL not built with rendering support"); + return NULL; +#endif /* !SDL_RENDER_DISABLED */ +} + +SDL_Renderer * +SDL_GetRenderer(SDL_Window * window) +{ + return (SDL_Renderer *)SDL_GetWindowData(window, SDL_WINDOWRENDERDATA); +} + +int +SDL_GetRendererInfo(SDL_Renderer * renderer, SDL_RendererInfo * info) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + *info = renderer->info; + return 0; +} + +static SDL_bool +IsSupportedFormat(SDL_Renderer * renderer, Uint32 format) +{ + Uint32 i; + + for (i = 0; i < renderer->info.num_texture_formats; ++i) { + if (renderer->info.texture_formats[i] == format) { + return SDL_TRUE; + } + } + return SDL_FALSE; +} + +static Uint32 +GetClosestSupportedFormat(SDL_Renderer * renderer, Uint32 format) +{ + Uint32 i; + + if (SDL_ISPIXELFORMAT_FOURCC(format)) { + /* Look for an exact match */ + for (i = 0; i < renderer->info.num_texture_formats; ++i) { + if (renderer->info.texture_formats[i] == format) { + return renderer->info.texture_formats[i]; + } + } + } else { + SDL_bool hasAlpha = SDL_ISPIXELFORMAT_ALPHA(format); + + /* We just want to match the first format that has the same channels */ + for (i = 0; i < renderer->info.num_texture_formats; ++i) { + if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) && + SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == hasAlpha) { + return renderer->info.texture_formats[i]; + } + } + } + return renderer->info.texture_formats[0]; +} + +SDL_Texture * +SDL_CreateTexture(SDL_Renderer * renderer, Uint32 format, int access, int w, int h) +{ + SDL_Texture *texture; + + CHECK_RENDERER_MAGIC(renderer, NULL); + + if (!format) { + format = renderer->info.texture_formats[0]; + } + if (SDL_ISPIXELFORMAT_INDEXED(format)) { + SDL_SetError("Palettized textures are not supported"); + return NULL; + } + if (w <= 0 || h <= 0) { + SDL_SetError("Texture dimensions can't be 0"); + return NULL; + } + texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); + if (!texture) { + SDL_OutOfMemory(); + return NULL; + } + texture->magic = &texture_magic; + texture->format = format; + texture->access = access; + texture->w = w; + texture->h = h; + texture->r = 255; + texture->g = 255; + texture->b = 255; + texture->a = 255; + texture->renderer = renderer; + texture->next = renderer->textures; + if (renderer->textures) { + renderer->textures->prev = texture; + } + renderer->textures = texture; + + if (IsSupportedFormat(renderer, format)) { + if (renderer->CreateTexture(renderer, texture) < 0) { + SDL_DestroyTexture(texture); + return 0; + } + } else { + texture->native = SDL_CreateTexture(renderer, + GetClosestSupportedFormat(renderer, format), + access, w, h); + if (!texture->native) { + SDL_DestroyTexture(texture); + return NULL; + } + + if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { + texture->yuv = SDL_SW_CreateYUVTexture(format, w, h); + if (!texture->yuv) { + SDL_DestroyTexture(texture); + return NULL; + } + } else if (access == SDL_TEXTUREACCESS_STREAMING) { + /* The pitch is 4 byte aligned */ + texture->pitch = (((w * SDL_BYTESPERPIXEL(format)) + 3) & ~3); + texture->pixels = SDL_calloc(1, texture->pitch * h); + if (!texture->pixels) { + SDL_DestroyTexture(texture); + return NULL; + } + } + } + return texture; +} + +SDL_Texture * +SDL_CreateTextureFromSurface(SDL_Renderer * renderer, SDL_Surface * surface) +{ + const SDL_PixelFormat *fmt; + SDL_bool needAlpha; + Uint32 i; + Uint32 format; + SDL_Texture *texture; + + CHECK_RENDERER_MAGIC(renderer, NULL); + + if (!surface) { + SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface"); + return NULL; + } + + /* See what the best texture format is */ + fmt = surface->format; + if (fmt->Amask || SDL_GetColorKey(surface, NULL) == 0) { + needAlpha = SDL_TRUE; + } else { + needAlpha = SDL_FALSE; + } + format = renderer->info.texture_formats[0]; + for (i = 0; i < renderer->info.num_texture_formats; ++i) { + if (!SDL_ISPIXELFORMAT_FOURCC(renderer->info.texture_formats[i]) && + SDL_ISPIXELFORMAT_ALPHA(renderer->info.texture_formats[i]) == needAlpha) { + format = renderer->info.texture_formats[i]; + break; + } + } + + texture = SDL_CreateTexture(renderer, format, SDL_TEXTUREACCESS_STATIC, + surface->w, surface->h); + if (!texture) { + return NULL; + } + + if (format == surface->format->format) { + if (SDL_MUSTLOCK(surface)) { + SDL_LockSurface(surface); + SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch); + SDL_UnlockSurface(surface); + } else { + SDL_UpdateTexture(texture, NULL, surface->pixels, surface->pitch); + } + } else { + SDL_PixelFormat *dst_fmt; + SDL_Surface *temp = NULL; + + /* Set up a destination surface for the texture update */ + dst_fmt = SDL_AllocFormat(format); + temp = SDL_ConvertSurface(surface, dst_fmt, 0); + SDL_FreeFormat(dst_fmt); + if (temp) { + SDL_UpdateTexture(texture, NULL, temp->pixels, temp->pitch); + SDL_FreeSurface(temp); + } else { + SDL_DestroyTexture(texture); + return NULL; + } + } + + { + Uint8 r, g, b, a; + SDL_BlendMode blendMode; + + SDL_GetSurfaceColorMod(surface, &r, &g, &b); + SDL_SetTextureColorMod(texture, r, g, b); + + SDL_GetSurfaceAlphaMod(surface, &a); + SDL_SetTextureAlphaMod(texture, a); + + if (SDL_GetColorKey(surface, NULL) == 0) { + /* We converted to a texture with alpha format */ + SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); + } else { + SDL_GetSurfaceBlendMode(surface, &blendMode); + SDL_SetTextureBlendMode(texture, blendMode); + } + } + return texture; +} + +int +SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, + int *w, int *h) +{ + CHECK_TEXTURE_MAGIC(texture, -1); + + if (format) { + *format = texture->format; + } + if (access) { + *access = texture->access; + } + if (w) { + *w = texture->w; + } + if (h) { + *h = texture->h; + } + return 0; +} + +int +SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + + renderer = texture->renderer; + if (r < 255 || g < 255 || b < 255) { + texture->modMode |= SDL_TEXTUREMODULATE_COLOR; + } else { + texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR; + } + texture->r = r; + texture->g = g; + texture->b = b; + if (texture->native) { + return SDL_SetTextureColorMod(texture->native, r, g, b); + } else if (renderer->SetTextureColorMod) { + return renderer->SetTextureColorMod(renderer, texture); + } else { + return 0; + } +} + +int +SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, + Uint8 * b) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + + renderer = texture->renderer; + if (r) { + *r = texture->r; + } + if (g) { + *g = texture->g; + } + if (b) { + *b = texture->b; + } + return 0; +} + +int +SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + + renderer = texture->renderer; + if (alpha < 255) { + texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; + } else { + texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA; + } + texture->a = alpha; + if (texture->native) { + return SDL_SetTextureAlphaMod(texture->native, alpha); + } else if (renderer->SetTextureAlphaMod) { + return renderer->SetTextureAlphaMod(renderer, texture); + } else { + return 0; + } +} + +int +SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha) +{ + CHECK_TEXTURE_MAGIC(texture, -1); + + if (alpha) { + *alpha = texture->a; + } + return 0; +} + +int +SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, -1); + + renderer = texture->renderer; + texture->blendMode = blendMode; + if (texture->native) { + return SDL_SetTextureBlendMode(texture->native, blendMode); + } else if (renderer->SetTextureBlendMode) { + return renderer->SetTextureBlendMode(renderer, texture); + } else { + return 0; + } +} + +int +SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode) +{ + CHECK_TEXTURE_MAGIC(texture, -1); + + if (blendMode) { + *blendMode = texture->blendMode; + } + return 0; +} + +static int +SDL_UpdateTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, + const void *pixels, int pitch) +{ + SDL_Texture *native = texture->native; + SDL_Rect full_rect; + + if (SDL_SW_UpdateYUVTexture(texture->yuv, rect, pixels, pitch) < 0) { + return -1; + } + + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + /* We can lock the texture and copy to it */ + void *native_pixels; + int native_pitch; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return -1; + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, native_pixels, native_pitch); + SDL_UnlockTexture(native); + } else { + /* Use a temporary buffer for updating */ + void *temp_pixels; + int temp_pitch; + + temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + SDL_OutOfMemory(); + return -1; + } + SDL_SW_CopyYUVToRGB(texture->yuv, rect, native->format, + rect->w, rect->h, temp_pixels, temp_pitch); + SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); + SDL_free(temp_pixels); + } + return 0; +} + +static int +SDL_UpdateTextureNative(SDL_Texture * texture, const SDL_Rect * rect, + const void *pixels, int pitch) +{ + SDL_Texture *native = texture->native; + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + /* We can lock the texture and copy to it */ + void *native_pixels; + int native_pitch; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return -1; + } + SDL_ConvertPixels(rect->w, rect->h, + texture->format, pixels, pitch, + native->format, native_pixels, native_pitch); + SDL_UnlockTexture(native); + } else { + /* Use a temporary buffer for updating */ + void *temp_pixels; + int temp_pitch; + + temp_pitch = (((rect->w * SDL_BYTESPERPIXEL(native->format)) + 3) & ~3); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + SDL_OutOfMemory(); + return -1; + } + SDL_ConvertPixels(rect->w, rect->h, + texture->format, pixels, pitch, + native->format, temp_pixels, temp_pitch); + SDL_UpdateTexture(native, rect, temp_pixels, temp_pitch); + SDL_free(temp_pixels); + } + return 0; +} + +int +SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, + const void *pixels, int pitch) +{ + SDL_Renderer *renderer; + SDL_Rect full_rect; + + CHECK_TEXTURE_MAGIC(texture, -1); + + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + } + + if (texture->yuv) { + return SDL_UpdateTextureYUV(texture, rect, pixels, pitch); + } else if (texture->native) { + return SDL_UpdateTextureNative(texture, rect, pixels, pitch); + } else { + renderer = texture->renderer; + return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch); + } +} + +static int +SDL_LockTextureYUV(SDL_Texture * texture, const SDL_Rect * rect, + void **pixels, int *pitch) +{ + return SDL_SW_LockYUVTexture(texture->yuv, rect, pixels, pitch); +} + +static int +SDL_LockTextureNative(SDL_Texture * texture, const SDL_Rect * rect, + void **pixels, int *pitch) +{ + texture->locked_rect = *rect; + *pixels = (void *) ((Uint8 *) texture->pixels + + rect->y * texture->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = texture->pitch; + return 0; +} + +int +SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, + void **pixels, int *pitch) +{ + SDL_Renderer *renderer; + SDL_Rect full_rect; + + CHECK_TEXTURE_MAGIC(texture, -1); + + if (texture->access != SDL_TEXTUREACCESS_STREAMING) { + SDL_SetError("SDL_LockTexture(): texture must be streaming"); + return -1; + } + + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = texture->w; + full_rect.h = texture->h; + rect = &full_rect; + } + + if (texture->yuv) { + return SDL_LockTextureYUV(texture, rect, pixels, pitch); + } else if (texture->native) { + return SDL_LockTextureNative(texture, rect, pixels, pitch); + } else { + renderer = texture->renderer; + return renderer->LockTexture(renderer, texture, rect, pixels, pitch); + } +} + +static void +SDL_UnlockTextureYUV(SDL_Texture * texture) +{ + SDL_Texture *native = texture->native; + void *native_pixels; + int native_pitch; + SDL_Rect rect; + + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + + if (SDL_LockTexture(native, &rect, &native_pixels, &native_pitch) < 0) { + return; + } + SDL_SW_CopyYUVToRGB(texture->yuv, &rect, native->format, + rect.w, rect.h, native_pixels, native_pitch); + SDL_UnlockTexture(native); +} + +static void +SDL_UnlockTextureNative(SDL_Texture * texture) +{ + SDL_Texture *native = texture->native; + void *native_pixels; + int native_pitch; + const SDL_Rect *rect = &texture->locked_rect; + const void* pixels = (void *) ((Uint8 *) texture->pixels + + rect->y * texture->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + int pitch = texture->pitch; + + if (SDL_LockTexture(native, rect, &native_pixels, &native_pitch) < 0) { + return; + } + SDL_ConvertPixels(rect->w, rect->h, + texture->format, pixels, pitch, + native->format, native_pixels, native_pitch); + SDL_UnlockTexture(native); +} + +void +SDL_UnlockTexture(SDL_Texture * texture) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, ); + + if (texture->access != SDL_TEXTUREACCESS_STREAMING) { + return; + } + if (texture->yuv) { + SDL_UnlockTextureYUV(texture); + } else if (texture->native) { + SDL_UnlockTextureNative(texture); + } else { + renderer = texture->renderer; + renderer->UnlockTexture(renderer, texture); + } +} + +int +SDL_RenderSetViewport(SDL_Renderer * renderer, const SDL_Rect * rect) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (rect) { + renderer->viewport = *rect; + } else { + renderer->viewport.x = 0; + renderer->viewport.y = 0; + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_RenderSetViewport(): window %p", renderer->window); + if (renderer->window) { + SDL_GetWindowSize(renderer->window, + &renderer->viewport.w, &renderer->viewport.h); + } else { + /* This will be filled in by UpdateViewport() */ + renderer->viewport.w = 0; + renderer->viewport.h = 0; + } + } + return renderer->UpdateViewport(renderer); +} + +void +SDL_RenderGetViewport(SDL_Renderer * renderer, SDL_Rect * rect) +{ + CHECK_RENDERER_MAGIC(renderer, ); + + *rect = renderer->viewport; +} + +int +SDL_SetRenderDrawColor(SDL_Renderer * renderer, + Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + renderer->r = r; + renderer->g = g; + renderer->b = b; + renderer->a = a; + return 0; +} + +int +SDL_GetRenderDrawColor(SDL_Renderer * renderer, + Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (r) { + *r = renderer->r; + } + if (g) { + *g = renderer->g; + } + if (b) { + *b = renderer->b; + } + if (a) { + *a = renderer->a; + } + return 0; +} + +int +SDL_SetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode blendMode) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + renderer->blendMode = blendMode; + return 0; +} + +int +SDL_GetRenderDrawBlendMode(SDL_Renderer * renderer, SDL_BlendMode *blendMode) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + *blendMode = renderer->blendMode; + return 0; +} + +int +SDL_RenderClear(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } + return renderer->RenderClear(renderer); +} + +int +SDL_RenderDrawPoint(SDL_Renderer * renderer, int x, int y) +{ + SDL_Point point; + + point.x = x; + point.y = y; + return SDL_RenderDrawPoints(renderer, &point, 1); +} + +int +SDL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, int count) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!points) { + SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points"); + return -1; + } + if (count < 1) { + return 0; + } + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } + return renderer->RenderDrawPoints(renderer, points, count); +} + +int +SDL_RenderDrawLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) +{ + SDL_Point points[2]; + + points[0].x = x1; + points[0].y = y1; + points[1].x = x2; + points[1].y = y2; + return SDL_RenderDrawLines(renderer, points, 2); +} + +int +SDL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, int count) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!points) { + SDL_SetError("SDL_RenderDrawLines(): Passed NULL points"); + return -1; + } + if (count < 2) { + return 0; + } + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } + return renderer->RenderDrawLines(renderer, points, count); +} + +int +SDL_RenderDrawRect(SDL_Renderer * renderer, const SDL_Rect * rect) +{ + SDL_Rect full_rect; + SDL_Point points[5]; + + CHECK_RENDERER_MAGIC(renderer, -1); + + /* If 'rect' == NULL, then outline the whole surface */ + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = renderer->viewport.w; + full_rect.h = renderer->viewport.h; + rect = &full_rect; + } + + points[0].x = rect->x; + points[0].y = rect->y; + points[1].x = rect->x+rect->w-1; + points[1].y = rect->y; + points[2].x = rect->x+rect->w-1; + points[2].y = rect->y+rect->h-1; + points[3].x = rect->x; + points[3].y = rect->y+rect->h-1; + points[4].x = rect->x; + points[4].y = rect->y; + return SDL_RenderDrawLines(renderer, points, 5); +} + +int +SDL_RenderDrawRects(SDL_Renderer * renderer, + const SDL_Rect * rects, int count) +{ + int i; + + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!rects) { + SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects"); + return -1; + } + if (count < 1) { + return 0; + } + + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } + for (i = 0; i < count; ++i) { + if (SDL_RenderDrawRect(renderer, &rects[i]) < 0) { + return -1; + } + } + return 0; +} + +int +SDL_RenderFillRect(SDL_Renderer * renderer, const SDL_Rect * rect) +{ + SDL_Rect full_rect; + + CHECK_RENDERER_MAGIC(renderer, -1); + + /* If 'rect' == NULL, then outline the whole surface */ + if (!rect) { + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = renderer->viewport.w; + full_rect.h = renderer->viewport.h; + rect = &full_rect; + } + return SDL_RenderFillRects(renderer, rect, 1); +} + +int +SDL_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, int count) +{ + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!rects) { + SDL_SetError("SDL_RenderFillRects(): Passed NULL rects"); + return -1; + } + if (count < 1) { + return 0; + } + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } + return renderer->RenderFillRects(renderer, rects, count); +} + +int +SDL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect) +{ + SDL_Window *window; + SDL_Rect real_srcrect; + SDL_Rect real_dstrect; + + CHECK_RENDERER_MAGIC(renderer, -1); + CHECK_TEXTURE_MAGIC(texture, -1); + + if (renderer != texture->renderer) { + SDL_SetError("Texture was not created with this renderer"); + return -1; + } + window = renderer->window; + + real_srcrect.x = 0; + real_srcrect.y = 0; + real_srcrect.w = texture->w; + real_srcrect.h = texture->h; + if (srcrect) { + if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) { + return 0; + } + } + + real_dstrect.x = 0; + real_dstrect.y = 0; + real_dstrect.w = renderer->viewport.w; + real_dstrect.h = renderer->viewport.h; + if (dstrect) { + if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) { + return 0; + } + /* Clip srcrect by the same amount as dstrect was clipped */ + if (dstrect->w != real_dstrect.w) { + int deltax = (real_dstrect.x - dstrect->x); + int deltaw = (real_dstrect.w - dstrect->w); + real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w; + real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w; + } + if (dstrect->h != real_dstrect.h) { + int deltay = (real_dstrect.y - dstrect->y); + int deltah = (real_dstrect.h - dstrect->h); + real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h; + real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h; + } + } + + if (texture->native) { + texture = texture->native; + } + + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return 0; + } + return renderer->RenderCopy(renderer, texture, &real_srcrect, + &real_dstrect); +} + +int +SDL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch) +{ + SDL_Window *window; + SDL_Rect real_rect; + + CHECK_RENDERER_MAGIC(renderer, -1); + + if (!renderer->RenderReadPixels) { + SDL_Unsupported(); + return -1; + } + window = renderer->window; + + if (!format) { + format = SDL_GetWindowPixelFormat(window); + } + + real_rect.x = renderer->viewport.x; + real_rect.y = renderer->viewport.y; + real_rect.w = renderer->viewport.w; + real_rect.h = renderer->viewport.h; + if (rect) { + if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { + return 0; + } + if (real_rect.y > rect->y) { + pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y); + } + if (real_rect.x > rect->x) { + int bpp = SDL_BYTESPERPIXEL(format); + pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x); + } + } + + return renderer->RenderReadPixels(renderer, &real_rect, + format, pixels, pitch); +} + +void +SDL_RenderPresent(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, ); + + /* Don't draw while we're minimized */ + if (renderer->minimized) { + return; + } + renderer->RenderPresent(renderer); +} + +void +SDL_DestroyTexture(SDL_Texture * texture) +{ + SDL_Renderer *renderer; + + CHECK_TEXTURE_MAGIC(texture, ); + texture->magic = NULL; + + renderer = texture->renderer; + if (texture->next) { + texture->next->prev = texture->prev; + } + if (texture->prev) { + texture->prev->next = texture->next; + } else { + renderer->textures = texture->next; + } + + if (texture->native) { + SDL_DestroyTexture(texture->native); + } + if (texture->yuv) { + SDL_SW_DestroyYUVTexture(texture->yuv); + } + if (texture->pixels) { + SDL_free(texture->pixels); + } + + renderer->DestroyTexture(renderer, texture); + SDL_free(texture); +} + +void +SDL_DestroyRenderer(SDL_Renderer * renderer) +{ + CHECK_RENDERER_MAGIC(renderer, ); + + SDL_DelEventWatch(SDL_RendererEventWatch, renderer); + + /* Free existing textures for this renderer */ + while (renderer->textures) { + SDL_DestroyTexture(renderer->textures); + } + + SDL_SetWindowData(renderer->window, SDL_WINDOWRENDERDATA, NULL); + + /* It's no longer magical... */ + renderer->magic = NULL; + + /* Free the renderer instance */ + renderer->DestroyRenderer(renderer); +} + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/SDL_sysrender.h b/project/jni/sdl-1.3/src/render/SDL_sysrender.h new file mode 100644 index 000000000..368dfc4e3 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/SDL_sysrender.h @@ -0,0 +1,151 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_sysrender_h +#define _SDL_sysrender_h + +#include "SDL_render.h" +#include "SDL_events.h" +#include "SDL_yuv_sw_c.h" + +/* The SDL 2D rendering system */ + +typedef struct SDL_RenderDriver SDL_RenderDriver; + +/* Define the SDL texture structure */ +struct SDL_Texture +{ + const void *magic; + Uint32 format; /**< The pixel format of the texture */ + int access; /**< SDL_TextureAccess */ + int w; /**< The width of the texture */ + int h; /**< The height of the texture */ + int modMode; /**< The texture modulation mode */ + SDL_BlendMode blendMode; /**< The texture blend mode */ + Uint8 r, g, b, a; /**< Texture modulation values */ + + SDL_Renderer *renderer; + + /* Support for formats not supported directly by the renderer */ + SDL_Texture *native; + SDL_SW_YUVTexture *yuv; + void *pixels; + int pitch; + SDL_Rect locked_rect; + + void *driverdata; /**< Driver specific texture representation */ + + SDL_Texture *prev; + SDL_Texture *next; +}; + +/* Define the SDL renderer structure */ +struct SDL_Renderer +{ + const void *magic; + + void (*WindowEvent) (SDL_Renderer * renderer, const SDL_WindowEvent *event); + int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture); + int (*SetTextureColorMod) (SDL_Renderer * renderer, + SDL_Texture * texture); + int (*SetTextureAlphaMod) (SDL_Renderer * renderer, + SDL_Texture * texture); + int (*SetTextureBlendMode) (SDL_Renderer * renderer, + SDL_Texture * texture); + int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); + int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); + void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); + int (*UpdateViewport) (SDL_Renderer * renderer); + int (*RenderClear) (SDL_Renderer * renderer); + int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points, + int count); + int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points, + int count); + int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect * rects, + int count); + int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect); + int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch); + void (*RenderPresent) (SDL_Renderer * renderer); + void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture); + + void (*DestroyRenderer) (SDL_Renderer * renderer); + + /* The current renderer info */ + SDL_RendererInfo info; + + /* The window associated with the renderer */ + SDL_Window *window; + SDL_bool minimized; + + /* The drawable area within the window */ + SDL_Rect viewport; + + /* The list of textures */ + SDL_Texture *textures; + + Uint8 r, g, b, a; /**< Color for drawing operations values */ + SDL_BlendMode blendMode; /**< The drawing blend mode */ + + void *driverdata; +}; + +/* Define the SDL render driver structure */ +struct SDL_RenderDriver +{ + SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags); + + /* Info about the renderer capabilities */ + SDL_RendererInfo info; +}; + +#if !SDL_RENDER_DISABLED + +#if SDL_VIDEO_RENDER_D3D +extern SDL_RenderDriver D3D_RenderDriver; +#endif +#if SDL_VIDEO_RENDER_OGL +extern SDL_RenderDriver GL_RenderDriver; +#endif +#if SDL_VIDEO_RENDER_OGL_ES2 +extern SDL_RenderDriver GLES2_RenderDriver; +#endif +#if SDL_VIDEO_RENDER_OGL_ES +extern SDL_RenderDriver GLES_RenderDriver; +#endif +#if SDL_VIDEO_RENDER_DIRECTFB +extern SDL_RenderDriver DirectFB_RenderDriver; +#endif +#if SDL_VIDEO_RENDER_NDS +extern SDL_RenderDriver NDS_RenderDriver; +#endif +extern SDL_RenderDriver SW_RenderDriver; + +#endif /* !SDL_RENDER_DISABLED */ + +#endif /* _SDL_sysrender_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_yuv_mmx.c b/project/jni/sdl-1.3/src/render/SDL_yuv_mmx.c similarity index 95% rename from project/jni/sdl-1.3/src/video/SDL_yuv_mmx.c rename to project/jni/sdl-1.3/src/render/SDL_yuv_mmx.c index e190e6bdf..4f9a9d369 100644 --- a/project/jni/sdl-1.3/src/video/SDL_yuv_mmx.c +++ b/project/jni/sdl-1.3/src/render/SDL_yuv_mmx.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/SDL_yuv_sw.c b/project/jni/sdl-1.3/src/render/SDL_yuv_sw.c similarity index 97% rename from project/jni/sdl-1.3/src/video/SDL_yuv_sw.c rename to project/jni/sdl-1.3/src/render/SDL_yuv_sw.c index 333b44e59..a42b62c0b 100644 --- a/project/jni/sdl-1.3/src/video/SDL_yuv_sw.c +++ b/project/jni/sdl-1.3/src/render/SDL_yuv_sw.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -1127,7 +1126,8 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, ("YV12 and IYUV textures only support full surface updates"); return -1; } - SDL_memcpy(swdata->pixels, pixels, swdata->h * swdata->w * 2); + SDL_memcpy(swdata->pixels, pixels, + (swdata->h * swdata->w) + (swdata->h * swdata->w) / 2); break; case SDL_PIXELFORMAT_YUY2: case SDL_PIXELFORMAT_UYVY: @@ -1155,7 +1155,7 @@ SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, - int markDirty, void **pixels, int *pitch) + void **pixels, int *pitch) { switch (swdata->format) { case SDL_PIXELFORMAT_YV12: diff --git a/project/jni/sdl-1.3/src/video/SDL_yuv_sw_c.h b/project/jni/sdl-1.3/src/render/SDL_yuv_sw_c.h similarity index 64% rename from project/jni/sdl-1.3/src/video/SDL_yuv_sw_c.h rename to project/jni/sdl-1.3/src/render/SDL_yuv_sw_c.h index c8865f1f6..94c91af99 100644 --- a/project/jni/sdl-1.3/src/video/SDL_yuv_sw_c.h +++ b/project/jni/sdl-1.3/src/render/SDL_yuv_sw_c.h @@ -1,28 +1,26 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #include "SDL_video.h" -#include "SDL_sysvideo.h" /* This is the software implementation of the YUV texture support */ @@ -60,7 +58,7 @@ int SDL_SW_QueryYUVTexturePixels(SDL_SW_YUVTexture * swdata, void **pixels, int SDL_SW_UpdateYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, const void *pixels, int pitch); int SDL_SW_LockYUVTexture(SDL_SW_YUVTexture * swdata, const SDL_Rect * rect, - int markDirty, void **pixels, int *pitch); + void **pixels, int *pitch); void SDL_SW_UnlockYUVTexture(SDL_SW_YUVTexture * swdata); int SDL_SW_CopyYUVToRGB(SDL_SW_YUVTexture * swdata, const SDL_Rect * srcrect, Uint32 target_format, int w, int h, void *pixels, diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_d3drender.c b/project/jni/sdl-1.3/src/render/direct3d/SDL_render_d3d.c similarity index 53% rename from project/jni/sdl-1.3/src/video/win32/SDL_d3drender.c rename to project/jni/sdl-1.3/src/render/direct3d/SDL_render_d3d.c index 53b5e8a7c..974796a15 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_d3drender.c +++ b/project/jni/sdl-1.3/src/render/direct3d/SDL_render_d3d.c @@ -1,30 +1,39 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#if SDL_VIDEO_RENDER_D3D +#if SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED -#include "SDL_win32video.h" -#include "../SDL_yuv_sw_c.h" + +#include "../../core/windows/SDL_windows.h" + +#include "SDL_hints.h" +#include "SDL_loadso.h" +#include "SDL_syswm.h" +#include "../SDL_sysrender.h" + +#if SDL_VIDEO_RENDER_D3D +#define D3D_DEBUG_INFO +#include +#endif #ifdef ASSEMBLE_SHADER /////////////////////////////////////////////////////////////////////////// @@ -80,58 +89,28 @@ HRESULT WINAPI /* Direct3D renderer implementation */ -#if 1 /* This takes more memory but you won't lose your texture data */ -#define D3DPOOL_SDL D3DPOOL_MANAGED -#define SDL_MEMORY_POOL_MANAGED -#else -#define D3DPOOL_SDL D3DPOOL_DEFAULT -#define SDL_MEMORY_POOL_DEFAULT -#endif - static SDL_Renderer *D3D_CreateRenderer(SDL_Window * window, Uint32 flags); -static int D3D_DisplayModeChanged(SDL_Renderer * renderer); +static void D3D_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); static int D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int D3D_QueryTexturePixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int D3D_SetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); -static int D3D_GetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors); -static int D3D_SetTextureColorMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int D3D_SetTextureAlphaMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int D3D_SetTextureBlendMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int D3D_SetTextureScaleMode(SDL_Renderer * renderer, - SDL_Texture * texture); static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch); + const SDL_Rect * rect, void **pixels, int *pitch); static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static void D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects); +static int D3D_UpdateViewport(SDL_Renderer * renderer); +static int D3D_RenderClear(SDL_Renderer * renderer); static int D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, int count); static int D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, int count); -static int D3D_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); static int D3D_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); + const SDL_Rect * rects, int count); static int D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect); static int D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 format, void * pixels, int pitch); -static int D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch); static void D3D_RenderPresent(SDL_Renderer * renderer); static void D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); @@ -141,44 +120,35 @@ static void D3D_DestroyRenderer(SDL_Renderer * renderer); SDL_RenderDriver D3D_RenderDriver = { D3D_CreateRenderer, { - "d3d", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC | - SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | - SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | - SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), - (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | - SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST), - 0, - {0}, + "direct3d", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), + 1, + {SDL_PIXELFORMAT_ARGB8888}, 0, 0} }; typedef struct { + void* d3dDLL; IDirect3D9 *d3d; IDirect3DDevice9 *device; UINT adapter; D3DPRESENT_PARAMETERS pparams; - LPDIRECT3DPIXELSHADER9 ps_mask; + SDL_bool updateSize; SDL_bool beginScene; + D3DTEXTUREFILTERTYPE scaleMode; } D3D_RenderData; typedef struct { - SDL_SW_YUVTexture *yuv; - Uint32 format; IDirect3DTexture9 *texture; + D3DTEXTUREFILTERTYPE scaleMode; } D3D_TextureData; typedef struct { float x, y, z; - float rhw; DWORD color; float u, v; } Vertex; @@ -266,176 +236,114 @@ static D3DFORMAT PixelFormatToD3DFMT(Uint32 format) { switch (format) { - case SDL_PIXELFORMAT_INDEX8: - return D3DFMT_P8; - case SDL_PIXELFORMAT_RGB332: - return D3DFMT_R3G3B2; - case SDL_PIXELFORMAT_RGB444: - return D3DFMT_X4R4G4B4; - case SDL_PIXELFORMAT_RGB555: - return D3DFMT_X1R5G5B5; - case SDL_PIXELFORMAT_ARGB4444: - return D3DFMT_A4R4G4B4; - case SDL_PIXELFORMAT_ARGB1555: - return D3DFMT_A1R5G5B5; case SDL_PIXELFORMAT_RGB565: return D3DFMT_R5G6B5; case SDL_PIXELFORMAT_RGB888: return D3DFMT_X8R8G8B8; case SDL_PIXELFORMAT_ARGB8888: return D3DFMT_A8R8G8B8; - case SDL_PIXELFORMAT_ARGB2101010: - return D3DFMT_A2R10G10B10; - case SDL_PIXELFORMAT_YV12: - return MAKEFOURCC('Y','V','1','2'); - case SDL_PIXELFORMAT_IYUV: - return MAKEFOURCC('I','4','2','0'); - case SDL_PIXELFORMAT_UYVY: - return D3DFMT_UYVY; - case SDL_PIXELFORMAT_YUY2: - return D3DFMT_YUY2; default: return D3DFMT_UNKNOWN; } } -static UINT D3D_FindAdapter(IDirect3D9 * d3d, SDL_VideoDisplay * display) +static Uint32 +D3DFMTToPixelFormat(D3DFORMAT format) { - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; - UINT adapter, count; - - count = IDirect3D9_GetAdapterCount(d3d); - for (adapter = 0; adapter < count; ++adapter) { - HRESULT result; - D3DADAPTER_IDENTIFIER9 info; - char *name; - - result = IDirect3D9_GetAdapterIdentifier(d3d, adapter, 0, &info); - if (FAILED(result)) { - continue; - } - name = WIN_StringToUTF8(displaydata->DeviceName); - if (SDL_strcmp(name, info.DeviceName) == 0) { - SDL_free(name); - return adapter; - } - SDL_free(name); + switch (format) { + case D3DFMT_R5G6B5: + return SDL_PIXELFORMAT_RGB565; + case D3DFMT_X8R8G8B8: + return SDL_PIXELFORMAT_RGB888; + case D3DFMT_A8R8G8B8: + return SDL_PIXELFORMAT_ARGB8888; + default: + return SDL_PIXELFORMAT_UNKNOWN; } - - /* This should never happen, but just in case... */ - return D3DADAPTER_DEFAULT; } -static SDL_bool -D3D_IsTextureFormatAvailable(IDirect3D9 * d3d, UINT adapter, - Uint32 display_format, - Uint32 texture_format) +static int +D3D_Reset(SDL_Renderer * renderer) { + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; HRESULT result; - result = IDirect3D9_CheckDeviceFormat(d3d, adapter, - D3DDEVTYPE_HAL, - PixelFormatToD3DFMT(display_format), - 0, - D3DRTYPE_TEXTURE, - PixelFormatToD3DFMT - (texture_format)); - return FAILED(result) ? SDL_FALSE : SDL_TRUE; -} - -static void -UpdateYUVTextureData(SDL_Texture * texture) -{ - D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; - SDL_Rect rect; - RECT d3drect; - D3DLOCKED_RECT locked; - HRESULT result; - - d3drect.left = 0; - d3drect.right = texture->w; - d3drect.top = 0; - d3drect.bottom = texture->h; - - result = - IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); + result = IDirect3DDevice9_Reset(data->device, &data->pparams); if (FAILED(result)) { - return; - } - - rect.x = 0; - rect.y = 0; - rect.w = texture->w; - rect.h = texture->h; - SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, - texture->h, locked.pBits, locked.Pitch); - - IDirect3DTexture9_UnlockRect(data->texture, 0); -} - -void -D3D_AddRenderDriver(_THIS) -{ - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_RendererInfo *info = &D3D_RenderDriver.info; - - if (data->d3d) { - int i, j; - int formats[] = { - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB332, - SDL_PIXELFORMAT_RGB444, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ARGB2101010, - }; - - for (i = 0; i < _this->num_displays; ++i) { - SDL_VideoDisplay *display = &_this->displays[i]; - SDL_DisplayMode *mode = &display->desktop_mode; - UINT adapter = D3D_FindAdapter(data->d3d, display); - - /* Get the matching D3D adapter for this display */ - info->num_texture_formats = 0; - for (j = 0; j < SDL_arraysize(formats); ++j) { - if (D3D_IsTextureFormatAvailable - (data->d3d, adapter, mode->format, formats[j])) { - info->texture_formats[info->num_texture_formats++] = - formats[j]; - } - } - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_YV12; - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_IYUV; - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_YUY2; - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_UYVY; - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_YVYU; - - SDL_AddRenderDriver(display, &D3D_RenderDriver); + if (result == D3DERR_DEVICELOST) { + /* Don't worry about it, we'll reset later... */ + return 0; + } else { + D3D_SetError("Reset()", result); + return -1; } } + IDirect3DDevice9_SetVertexShader(data->device, NULL); + IDirect3DDevice9_SetFVF(data->device, + D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); + IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, + D3DCULL_NONE); + IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); + return 0; +} + +static int +D3D_ActivateRenderer(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + HRESULT result; + + if (data->updateSize) { + SDL_Window *window = renderer->window; + int w, h; + + SDL_GetWindowSize(window, &w, &h); + data->pparams.BackBufferWidth = w; + data->pparams.BackBufferHeight = h; + if (SDL_GetWindowFlags(window) & SDL_WINDOW_FULLSCREEN) { + data->pparams.BackBufferFormat = + PixelFormatToD3DFMT(SDL_GetWindowPixelFormat(window)); + } else { + data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; + } + if (D3D_Reset(renderer) < 0) { + return -1; + } + D3D_UpdateViewport(renderer); + + data->updateSize = SDL_FALSE; + } + if (data->beginScene) { + result = IDirect3DDevice9_BeginScene(data->device); + if (result == D3DERR_DEVICELOST) { + if (D3D_Reset(renderer) < 0) { + return -1; + } + result = IDirect3DDevice9_BeginScene(data->device); + } + if (FAILED(result)) { + D3D_SetError("BeginScene()", result); + return -1; + } + data->beginScene = SDL_FALSE; + } + return 0; } SDL_Renderer * D3D_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_VideoDisplay *display = window->display; - SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata; - SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; SDL_Renderer *renderer; D3D_RenderData *data; + SDL_SysWMinfo windowinfo; HRESULT result; D3DPRESENT_PARAMETERS pparams; IDirect3DSwapChain9 *chain; D3DCAPS9 caps; + Uint32 window_flags; + int w, h; + SDL_DisplayMode fullscreen_mode; + D3DMATRIX matrix; renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); if (!renderer) { @@ -445,69 +353,77 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) data = (D3D_RenderData *) SDL_calloc(1, sizeof(*data)); if (!data) { - D3D_DestroyRenderer(renderer); + SDL_free(renderer); SDL_OutOfMemory(); return NULL; } - data->d3d = videodata->d3d; - videodata->render = RENDER_D3D; + data->d3dDLL = SDL_LoadObject("D3D9.DLL"); + if (data->d3dDLL) { + IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); - renderer->DisplayModeChanged = D3D_DisplayModeChanged; + D3DCreate = + (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL, + "Direct3DCreate9"); + if (D3DCreate) { + data->d3d = D3DCreate(D3D_SDK_VERSION); + } + if (!data->d3d) { + SDL_UnloadObject(data->d3dDLL); + data->d3dDLL = NULL; + } + } + if (!data->d3d) { + SDL_free(renderer); + SDL_free(data); + SDL_SetError("Unable to create Direct3D interface"); + return NULL; + } + + renderer->WindowEvent = D3D_WindowEvent; renderer->CreateTexture = D3D_CreateTexture; - renderer->QueryTexturePixels = D3D_QueryTexturePixels; - renderer->SetTexturePalette = D3D_SetTexturePalette; - renderer->GetTexturePalette = D3D_GetTexturePalette; - renderer->SetTextureColorMod = D3D_SetTextureColorMod; - renderer->SetTextureAlphaMod = D3D_SetTextureAlphaMod; - renderer->SetTextureBlendMode = D3D_SetTextureBlendMode; - renderer->SetTextureScaleMode = D3D_SetTextureScaleMode; renderer->UpdateTexture = D3D_UpdateTexture; renderer->LockTexture = D3D_LockTexture; renderer->UnlockTexture = D3D_UnlockTexture; - renderer->DirtyTexture = D3D_DirtyTexture; + renderer->UpdateViewport = D3D_UpdateViewport; + renderer->RenderClear = D3D_RenderClear; renderer->RenderDrawPoints = D3D_RenderDrawPoints; renderer->RenderDrawLines = D3D_RenderDrawLines; - renderer->RenderDrawRects = D3D_RenderDrawRects; renderer->RenderFillRects = D3D_RenderFillRects; renderer->RenderCopy = D3D_RenderCopy; renderer->RenderReadPixels = D3D_RenderReadPixels; - renderer->RenderWritePixels = D3D_RenderWritePixels; renderer->RenderPresent = D3D_RenderPresent; renderer->DestroyTexture = D3D_DestroyTexture; renderer->DestroyRenderer = D3D_DestroyRenderer; renderer->info = D3D_RenderDriver.info; - renderer->window = window; renderer->driverdata = data; renderer->info.flags = SDL_RENDERER_ACCELERATED; + SDL_VERSION(&windowinfo.version); + SDL_GetWindowWMInfo(window, &windowinfo); + + window_flags = SDL_GetWindowFlags(window); + SDL_GetWindowSize(window, &w, &h); + SDL_GetWindowDisplayMode(window, &fullscreen_mode); + SDL_zero(pparams); - pparams.BackBufferWidth = window->w; - pparams.BackBufferHeight = window->h; - if (window->flags & SDL_WINDOW_FULLSCREEN) { + pparams.hDeviceWindow = windowinfo.info.win.window; + pparams.BackBufferWidth = w; + pparams.BackBufferHeight = h; + if (window_flags & SDL_WINDOW_FULLSCREEN) { pparams.BackBufferFormat = - PixelFormatToD3DFMT(window->fullscreen_mode.format); + PixelFormatToD3DFMT(fullscreen_mode.format); } else { pparams.BackBufferFormat = D3DFMT_UNKNOWN; } - if (flags & SDL_RENDERER_PRESENTFLIP2) { - pparams.BackBufferCount = 2; - pparams.SwapEffect = D3DSWAPEFFECT_FLIP; - } else if (flags & SDL_RENDERER_PRESENTFLIP3) { - pparams.BackBufferCount = 3; - pparams.SwapEffect = D3DSWAPEFFECT_FLIP; - } else if (flags & SDL_RENDERER_PRESENTCOPY) { - pparams.BackBufferCount = 1; - pparams.SwapEffect = D3DSWAPEFFECT_COPY; - } else { - pparams.BackBufferCount = 1; - pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; - } - if (window->flags & SDL_WINDOW_FULLSCREEN) { + pparams.BackBufferCount = 1; + pparams.SwapEffect = D3DSWAPEFFECT_DISCARD; + + if (window_flags & SDL_WINDOW_FULLSCREEN) { pparams.Windowed = FALSE; pparams.FullScreen_RefreshRateInHz = - window->fullscreen_mode.refresh_rate; + fullscreen_mode.refresh_rate; } else { pparams.Windowed = TRUE; pparams.FullScreen_RefreshRateInHz = 0; @@ -518,13 +434,13 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) pparams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; } - data->adapter = D3D_FindAdapter(videodata->d3d, display); - IDirect3D9_GetDeviceCaps(videodata->d3d, data->adapter, - D3DDEVTYPE_HAL, &caps); + /* FIXME: Which adapter? */ + data->adapter = D3DADAPTER_DEFAULT; + IDirect3D9_GetDeviceCaps(data->d3d, data->adapter, D3DDEVTYPE_HAL, &caps); - result = IDirect3D9_CreateDevice(videodata->d3d, data->adapter, + result = IDirect3D9_CreateDevice(data->d3d, data->adapter, D3DDEVTYPE_HAL, - windowdata->hwnd, + pparams.hDeviceWindow, (caps. DevCaps & D3DDEVCAPS_HWTRANSFORMANDLIGHT) ? @@ -537,6 +453,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) return NULL; } data->beginScene = SDL_TRUE; + data->scaleMode = D3DTEXF_FORCE_DWORD; /* Get presentation parameters to fill info */ result = IDirect3DDevice9_GetSwapChain(data->device, 0, &chain); @@ -553,24 +470,6 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) return NULL; } IDirect3DSwapChain9_Release(chain); - switch (pparams.SwapEffect) { - case D3DSWAPEFFECT_COPY: - renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; - break; - case D3DSWAPEFFECT_FLIP: - switch (pparams.BackBufferCount) { - case 2: - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; - break; - case 3: - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; - break; - } - break; - case D3DSWAPEFFECT_DISCARD: - renderer->info.flags |= SDL_RENDERER_PRESENTDISCARD; - break; - } if (pparams.PresentationInterval == D3DPRESENT_INTERVAL_ONE) { renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; } @@ -583,7 +482,7 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) /* Set up parameters for rendering */ IDirect3DDevice9_SetVertexShader(data->device, NULL); IDirect3DDevice9_SetFVF(data->device, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); + D3DFVF_XYZ | D3DFVF_DIFFUSE | D3DFVF_TEX1); IDirect3DDevice9_SetRenderState(data->device, D3DRS_ZENABLE, D3DZB_FALSE); IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, D3DCULL_NONE); @@ -608,89 +507,51 @@ D3D_CreateRenderer(SDL_Window * window, Uint32 flags) IDirect3DDevice9_SetTextureStageState(data->device, 1, D3DTSS_ALPHAOP, D3DTOP_DISABLE); - { -#ifdef ASSEMBLE_SHADER - const char *shader_text = -"ps_1_1\n" -"def c0, 0, 0, 0, 0.496\n" -"def c1, 0, 0, 0, 1\n" -"def c2, 0, 0, 0, -1\n" -"tex t0\n" -"mul r1, t0, v0\n" -"add r0, r1, c0\n" -"cnd r0, r0.a, c1, c2\n" -"add r0, r0, r1\n"; - LPD3DXBUFFER pCode; // buffer with the assembled shader code - LPD3DXBUFFER pErrorMsgs; // buffer with error messages - LPDWORD shader_data; - DWORD shader_size; - result = D3DXAssembleShader( shader_text, SDL_strlen(shader_text), NULL, NULL, 0, &pCode, &pErrorMsgs ); - if (FAILED(result)) { - D3D_SetError("D3DXAssembleShader()", result); - } - shader_data = (DWORD*)pCode->lpVtbl->GetBufferPointer(pCode); - shader_size = pCode->lpVtbl->GetBufferSize(pCode); -#else - const DWORD shader_data[] = { - 0xffff0101,0x00000051,0xa00f0000,0x00000000,0x00000000,0x00000000, - 0x3efdf3b6,0x00000051,0xa00f0001,0x00000000,0x00000000,0x00000000, - 0x3f800000,0x00000051,0xa00f0002,0x00000000,0x00000000,0x00000000, - 0xbf800000,0x00000042,0xb00f0000,0x00000005,0x800f0001,0xb0e40000, - 0x90e40000,0x00000002,0x800f0000,0x80e40001,0xa0e40000,0x00000050, - 0x800f0000,0x80ff0000,0xa0e40001,0xa0e40002,0x00000002,0x800f0000, - 0x80e40000,0x80e40001,0x0000ffff - }; -#endif - result = IDirect3DDevice9_CreatePixelShader(data->device, shader_data, &data->ps_mask); - if (FAILED(result)) { - D3D_SetError("CreatePixelShader()", result); - } - } + /* Set an identity world and view matrix */ + matrix.m[0][0] = 1.0f; + matrix.m[0][1] = 0.0f; + matrix.m[0][2] = 0.0f; + matrix.m[0][3] = 0.0f; + matrix.m[1][0] = 0.0f; + matrix.m[1][1] = 1.0f; + matrix.m[1][2] = 0.0f; + matrix.m[1][3] = 0.0f; + matrix.m[2][0] = 0.0f; + matrix.m[2][1] = 0.0f; + matrix.m[2][2] = 1.0f; + matrix.m[2][3] = 0.0f; + matrix.m[3][0] = 0.0f; + matrix.m[3][1] = 0.0f; + matrix.m[3][2] = 0.0f; + matrix.m[3][3] = 1.0f; + IDirect3DDevice9_SetTransform(data->device, D3DTS_WORLD, &matrix); + IDirect3DDevice9_SetTransform(data->device, D3DTS_VIEW, &matrix); return renderer; } -static int -D3D_Reset(SDL_Renderer * renderer) +static void +D3D_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - HRESULT result; - result = IDirect3DDevice9_Reset(data->device, &data->pparams); - if (FAILED(result)) { - if (result == D3DERR_DEVICELOST) { - /* Don't worry about it, we'll reset later... */ - return 0; - } else { - D3D_SetError("Reset()", result); - return -1; - } + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + data->updateSize = SDL_TRUE; } - IDirect3DDevice9_SetVertexShader(data->device, NULL); - IDirect3DDevice9_SetFVF(data->device, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, - D3DCULL_NONE); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); - return 0; } -static int -D3D_DisplayModeChanged(SDL_Renderer * renderer) +static D3DTEXTUREFILTERTYPE +GetScaleQuality(void) { - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; + const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); - data->pparams.BackBufferWidth = window->w; - data->pparams.BackBufferHeight = window->h; - if (window->flags & SDL_WINDOW_FULLSCREEN) { - data->pparams.BackBufferFormat = - PixelFormatToD3DFMT(window->fullscreen_mode.format); + if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { + return D3DTEXF_POINT; + } else if (*hint == '1' || SDL_strcasecmp(hint, "linear") == 0) { + return D3DTEXF_LINEAR; } else { - data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; + return D3DTEXF_ANISOTROPIC; } - return D3D_Reset(renderer); } static int @@ -698,9 +559,10 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - Uint32 display_format = display->current_mode.format; + D3DFORMAT display_format = renderdata->pparams.BackBufferFormat; D3D_TextureData *data; + D3DPOOL pool; + DWORD usage; HRESULT result; data = (D3D_TextureData *) SDL_calloc(1, sizeof(*data)); @@ -708,31 +570,26 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) SDL_OutOfMemory(); return -1; } + data->scaleMode = GetScaleQuality(); texture->driverdata = data; - if (SDL_ISPIXELFORMAT_FOURCC(texture->format) && - (texture->format != SDL_PIXELFORMAT_YUY2 || - !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter, - display_format, texture->format)) - && (texture->format != SDL_PIXELFORMAT_YVYU - || !D3D_IsTextureFormatAvailable(renderdata->d3d, renderdata->adapter, - display_format, texture->format))) { - data->yuv = - SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); - if (!data->yuv) { - return -1; - } - data->format = display->current_mode.format; - } else { - data->format = texture->format; +#ifdef USE_DYNAMIC_TEXTURE + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + pool = D3DPOOL_DEFAULT; + usage = D3DUSAGE_DYNAMIC; + } else +#endif + { + pool = D3DPOOL_MANAGED; + usage = 0; } result = IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, - texture->h, 1, 0, - PixelFormatToD3DFMT(data->format), - D3DPOOL_SDL, &data->texture, NULL); + texture->h, 1, usage, + PixelFormatToD3DFMT(texture->format), + pool, &data->texture, NULL); if (FAILED(result)) { D3D_SetError("CreateTexture()", result); return -1; @@ -741,219 +598,78 @@ D3D_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) return 0; } -static int -D3D_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; - - if (data->yuv) { - return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); - } else { - /* D3D textures don't have their pixels hanging out */ - return -1; - } -} - -static int -D3D_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, int ncolors) -{ - D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; - D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; - - return 0; -} - -static int -D3D_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, int ncolors) -{ - D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; - - return 0; -} - -static int -D3D_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -D3D_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -D3D_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->blendMode) { - case SDL_BLENDMODE_NONE: - case SDL_BLENDMODE_MASK: - case SDL_BLENDMODE_BLEND: - case SDL_BLENDMODE_ADD: - case SDL_BLENDMODE_MOD: - return 0; - default: - SDL_Unsupported(); - texture->blendMode = SDL_BLENDMODE_NONE; - return -1; - } -} - -static int -D3D_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: - case SDL_SCALEMODE_FAST: - case SDL_SCALEMODE_SLOW: - case SDL_SCALEMODE_BEST: - return 0; - default: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_NONE; - return -1; - } - return 0; -} - static int D3D_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch) { D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; D3D_RenderData *renderdata = (D3D_RenderData *) renderer->driverdata; + RECT d3drect; + D3DLOCKED_RECT locked; + const Uint8 *src; + Uint8 *dst; + int row, length; + HRESULT result; - if (data->yuv) { - if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) { - return -1; - } - UpdateYUVTextureData(texture); - return 0; - } else { -#ifdef SDL_MEMORY_POOL_DEFAULT - IDirect3DTexture9 *temp; - RECT d3drect; - D3DLOCKED_RECT locked; - const Uint8 *src; - Uint8 *dst; - int row, length; - HRESULT result; - - result = - IDirect3DDevice9_CreateTexture(renderdata->device, texture->w, - texture->h, 1, 0, - PixelFormatToD3DFMT(texture-> - format), - D3DPOOL_SYSTEMMEM, &temp, NULL); - if (FAILED(result)) { - D3D_SetError("CreateTexture()", result); - return -1; - } - +#ifdef USE_DYNAMIC_TEXTURE + if (texture->access == SDL_TEXTUREACCESS_STREAMING && + rect->x == 0 && rect->y == 0 && + rect->w == texture->w && rect->h == texture->h) { + result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, NULL, D3DLOCK_DISCARD); + } else +#endif + { d3drect.left = rect->x; d3drect.right = rect->x + rect->w; d3drect.top = rect->y; d3drect.bottom = rect->y + rect->h; - - result = IDirect3DTexture9_LockRect(temp, 0, &locked, &d3drect, 0); - if (FAILED(result)) { - IDirect3DTexture9_Release(temp); - D3D_SetError("LockRect()", result); - return -1; - } - - src = pixels; - dst = locked.pBits; - length = rect->w * SDL_BYTESPERPIXEL(texture->format); - for (row = 0; row < rect->h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += locked.Pitch; - } - IDirect3DTexture9_UnlockRect(temp, 0); - - result = - IDirect3DDevice9_UpdateTexture(renderdata->device, - (IDirect3DBaseTexture9 *) temp, - (IDirect3DBaseTexture9 *) - data->texture); - IDirect3DTexture9_Release(temp); - if (FAILED(result)) { - D3D_SetError("UpdateTexture()", result); - return -1; - } -#else - RECT d3drect; - D3DLOCKED_RECT locked; - const Uint8 *src; - Uint8 *dst; - int row, length; - HRESULT result; - - d3drect.left = rect->x; - d3drect.right = rect->x + rect->w; - d3drect.top = rect->y; - d3drect.bottom = rect->y + rect->h; - - result = - IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, - 0); - if (FAILED(result)) { - D3D_SetError("LockRect()", result); - return -1; - } - - src = pixels; - dst = locked.pBits; - length = rect->w * SDL_BYTESPERPIXEL(texture->format); - for (row = 0; row < rect->h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += locked.Pitch; - } - IDirect3DTexture9_UnlockRect(data->texture, 0); -#endif // SDL_MEMORY_POOL_DEFAULT - - return 0; + result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); } + + if (FAILED(result)) { + D3D_SetError("LockRect()", result); + return -1; + } + + src = pixels; + dst = locked.pBits; + length = rect->w * SDL_BYTESPERPIXEL(texture->format); + if (length == pitch && length == locked.Pitch) { + SDL_memcpy(dst, src, length*rect->h); + } else { + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += locked.Pitch; + } + } + IDirect3DTexture9_UnlockRect(data->texture, 0); + + return 0; } static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) + const SDL_Rect * rect, void **pixels, int *pitch) { D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; + RECT d3drect; + D3DLOCKED_RECT locked; + HRESULT result; - if (data->yuv) { - return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, - pitch); - } else { - RECT d3drect; - D3DLOCKED_RECT locked; - HRESULT result; + d3drect.left = rect->x; + d3drect.right = rect->x + rect->w; + d3drect.top = rect->y; + d3drect.bottom = rect->y + rect->h; - d3drect.left = rect->x; - d3drect.right = rect->x + rect->w; - d3drect.top = rect->y; - d3drect.bottom = rect->y + rect->h; - - result = - IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, - markDirty ? 0 : - D3DLOCK_NO_DIRTY_UPDATE); - if (FAILED(result)) { - D3D_SetError("LockRect()", result); - return -1; - } - *pixels = locked.pBits; - *pitch = locked.Pitch; - return 0; + result = IDirect3DTexture9_LockRect(data->texture, 0, &locked, &d3drect, 0); + if (FAILED(result)) { + D3D_SetError("LockRect()", result); + return -1; } + *pixels = locked.pBits; + *pitch = locked.Pitch; + return 0; } static void @@ -961,32 +677,94 @@ D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) { D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; - if (data->yuv) { - SDL_SW_UnlockYUVTexture(data->yuv); - UpdateYUVTextureData(texture); - } else { - IDirect3DTexture9_UnlockRect(data->texture, 0); - } + IDirect3DTexture9_UnlockRect(data->texture, 0); } -static void -D3D_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, - const SDL_Rect * rects) +static int +D3D_UpdateViewport(SDL_Renderer * renderer) { - D3D_TextureData *data = (D3D_TextureData *) texture->driverdata; - RECT d3drect; - int i; + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + D3DVIEWPORT9 viewport; + D3DMATRIX matrix; - for (i = 0; i < numrects; ++i) { - const SDL_Rect *rect = &rects[i]; + /* Set the viewport */ + viewport.X = renderer->viewport.x; + viewport.Y = renderer->viewport.y; + viewport.Width = renderer->viewport.w; + viewport.Height = renderer->viewport.h; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + IDirect3DDevice9_SetViewport(data->device, &viewport); - d3drect.left = rect->x; - d3drect.right = rect->x + rect->w; - d3drect.top = rect->y; - d3drect.bottom = rect->y + rect->h; + /* Set an orthographic projection matrix */ + matrix.m[0][0] = 2.0f / renderer->viewport.w; + matrix.m[0][1] = 0.0f; + matrix.m[0][2] = 0.0f; + matrix.m[0][3] = 0.0f; + matrix.m[1][0] = 0.0f; + matrix.m[1][1] = -2.0f / renderer->viewport.h; + matrix.m[1][2] = 0.0f; + matrix.m[1][3] = 0.0f; + matrix.m[2][0] = 0.0f; + matrix.m[2][1] = 0.0f; + matrix.m[2][2] = 1.0f; + matrix.m[2][3] = 0.0f; + matrix.m[3][0] = -1.0f; + matrix.m[3][1] = 1.0f; + matrix.m[3][2] = 0.0f; + matrix.m[3][3] = 1.0f; + IDirect3DDevice9_SetTransform(data->device, D3DTS_PROJECTION, &matrix); - IDirect3DTexture9_AddDirtyRect(data->texture, &d3drect); + return 0; +} + +static int +D3D_RenderClear(SDL_Renderer * renderer) +{ + D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; + DWORD color; + HRESULT result; + + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; } + + color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); + + /* Don't reset the viewport if we don't have to! */ + if (!renderer->viewport.x && !renderer->viewport.y && + renderer->viewport.w == data->pparams.BackBufferWidth && + renderer->viewport.h == data->pparams.BackBufferHeight) { + result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); + } else { + D3DVIEWPORT9 viewport; + + /* Clear is defined to clear the entire render target */ + viewport.X = 0; + viewport.Y = 0; + viewport.Width = data->pparams.BackBufferWidth; + viewport.Height = data->pparams.BackBufferHeight; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + IDirect3DDevice9_SetViewport(data->device, &viewport); + + result = IDirect3DDevice9_Clear(data->device, 0, NULL, D3DCLEAR_TARGET, color, 0.0f, 0); + + /* Reset the viewport */ + viewport.X = renderer->viewport.x; + viewport.Y = renderer->viewport.y; + viewport.Width = renderer->viewport.w; + viewport.Height = renderer->viewport.h; + viewport.MinZ = 0.0f; + viewport.MaxZ = 1.0f; + IDirect3DDevice9_SetViewport(data->device, &viewport); + } + + if (FAILED(result)) { + D3D_SetError("Clear()", result); + return -1; + } + return 0; } static void @@ -997,7 +775,6 @@ D3D_SetBlendMode(D3D_RenderData * data, int blendMode) IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, FALSE); break; - case SDL_BLENDMODE_MASK: case SDL_BLENDMODE_BLEND: IDirect3DDevice9_SetRenderState(data->device, D3DRS_ALPHABLENDENABLE, TRUE); @@ -1035,9 +812,8 @@ D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, int i; HRESULT result; - if (data->beginScene) { - IDirect3DDevice9_BeginScene(data->device); - data->beginScene = SDL_FALSE; + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; } D3D_SetBlendMode(data, renderer->blendMode); @@ -1057,7 +833,6 @@ D3D_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, vertices[i].x = (float) points[i].x; vertices[i].y = (float) points[i].y; vertices[i].z = 0.0f; - vertices[i].rhw = 1.0f; vertices[i].color = color; vertices[i].u = 0.0f; vertices[i].v = 0.0f; @@ -1083,9 +858,8 @@ D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, int i; HRESULT result; - if (data->beginScene) { - IDirect3DDevice9_BeginScene(data->device); - data->beginScene = SDL_FALSE; + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; } D3D_SetBlendMode(data, renderer->blendMode); @@ -1105,7 +879,6 @@ D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, vertices[i].x = (float) points[i].x; vertices[i].y = (float) points[i].y; vertices[i].z = 0.0f; - vertices[i].rhw = 1.0f; vertices[i].color = color; vertices[i].u = 0.0f; vertices[i].v = 0.0f; @@ -1116,7 +889,8 @@ D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, /* DirectX 9 has the same line rasterization semantics as GDI, so we need to close the endpoint of the line */ - if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { + if (count == 2 || + points[0].x != points[count-1].x || points[0].y != points[count-1].y) { vertices[0].x = (float) points[count-1].x; vertices[0].y = (float) points[count-1].y; result = IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_POINTLIST, 1, vertices, sizeof(*vertices)); @@ -1131,72 +905,7 @@ D3D_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, } static int -D3D_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - DWORD color; - int i; - Vertex vertices[5]; - HRESULT result; - - if (data->beginScene) { - IDirect3DDevice9_BeginScene(data->device); - data->beginScene = SDL_FALSE; - } - - D3D_SetBlendMode(data, renderer->blendMode); - - result = - IDirect3DDevice9_SetTexture(data->device, 0, - (IDirect3DBaseTexture9 *) 0); - if (FAILED(result)) { - D3D_SetError("SetTexture()", result); - return -1; - } - - color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); - - for (i = 0; i < SDL_arraysize(vertices); ++i) { - vertices[i].z = 0.0f; - vertices[i].rhw = 1.0f; - vertices[i].color = color; - vertices[i].u = 0.0f; - vertices[i].v = 0.0f; - } - - for (i = 0; i < count; ++i) { - const SDL_Rect *rect = rects[i]; - - vertices[0].x = (float) rect->x; - vertices[0].y = (float) rect->y; - - vertices[1].x = (float) rect->x+rect->w-1; - vertices[1].y = (float) rect->y; - - vertices[2].x = (float) rect->x+rect->w-1; - vertices[2].y = (float) rect->y+rect->h-1; - - vertices[3].x = (float) rect->x; - vertices[3].y = (float) rect->y+rect->h-1; - - vertices[4].x = (float) rect->x; - vertices[4].y = (float) rect->y; - - result = - IDirect3DDevice9_DrawPrimitiveUP(data->device, D3DPT_LINESTRIP, 4, - vertices, sizeof(*vertices)); - - if (FAILED(result)) { - D3D_SetError("DrawPrimitiveUP()", result); - return -1; - } - } - return 0; -} - -static int -D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, +D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; @@ -1206,9 +915,8 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, Vertex vertices[4]; HRESULT result; - if (data->beginScene) { - IDirect3DDevice9_BeginScene(data->device); - data->beginScene = SDL_FALSE; + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; } D3D_SetBlendMode(data, renderer->blendMode); @@ -1224,7 +932,7 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, color = D3DCOLOR_ARGB(renderer->a, renderer->r, renderer->g, renderer->b); for (i = 0; i < count; ++i) { - const SDL_Rect *rect = rects[i]; + const SDL_Rect *rect = &rects[i]; minx = (float) rect->x; miny = (float) rect->y; @@ -1234,7 +942,6 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, vertices[0].x = minx; vertices[0].y = miny; vertices[0].z = 0.0f; - vertices[0].rhw = 1.0f; vertices[0].color = color; vertices[0].u = 0.0f; vertices[0].v = 0.0f; @@ -1242,7 +949,6 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, vertices[1].x = maxx; vertices[1].y = miny; vertices[1].z = 0.0f; - vertices[1].rhw = 1.0f; vertices[1].color = color; vertices[1].u = 0.0f; vertices[1].v = 0.0f; @@ -1250,7 +956,6 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, vertices[2].x = maxx; vertices[2].y = maxy; vertices[2].z = 0.0f; - vertices[2].rhw = 1.0f; vertices[2].color = color; vertices[2].u = 0.0f; vertices[2].v = 0.0f; @@ -1258,7 +963,6 @@ D3D_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, vertices[3].x = minx; vertices[3].y = maxy; vertices[3].z = 0.0f; - vertices[3].rhw = 1.0f; vertices[3].color = color; vertices[3].u = 0.0f; vertices[3].v = 0.0f; @@ -1287,9 +991,8 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, Vertex vertices[4]; HRESULT result; - if (data->beginScene) { - IDirect3DDevice9_BeginScene(data->device); - data->beginScene = SDL_FALSE; + if (D3D_ActivateRenderer(renderer) < 0) { + return -1; } minx = (float) dstrect->x - 0.5f; @@ -1307,7 +1010,6 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, vertices[0].x = minx; vertices[0].y = miny; vertices[0].z = 0.0f; - vertices[0].rhw = 1.0f; vertices[0].color = color; vertices[0].u = minu; vertices[0].v = minv; @@ -1315,7 +1017,6 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, vertices[1].x = maxx; vertices[1].y = miny; vertices[1].z = 0.0f; - vertices[1].rhw = 1.0f; vertices[1].color = color; vertices[1].u = maxu; vertices[1].v = minv; @@ -1323,7 +1024,6 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, vertices[2].x = maxx; vertices[2].y = maxy; vertices[2].z = 0.0f; - vertices[2].rhw = 1.0f; vertices[2].color = color; vertices[2].u = maxu; vertices[2].v = maxv; @@ -1331,37 +1031,18 @@ D3D_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, vertices[3].x = minx; vertices[3].y = maxy; vertices[3].z = 0.0f; - vertices[3].rhw = 1.0f; vertices[3].color = color; vertices[3].u = minu; vertices[3].v = maxv; D3D_SetBlendMode(data, texture->blendMode); - if (texture->blendMode == SDL_BLENDMODE_MASK) { - shader = data->ps_mask; - } - - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: - case SDL_SCALEMODE_FAST: + if (texturedata->scaleMode != data->scaleMode) { IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, - D3DTEXF_POINT); + texturedata->scaleMode); IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, - D3DTEXF_POINT); - break; - case SDL_SCALEMODE_SLOW: - IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, - D3DTEXF_LINEAR); - IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, - D3DTEXF_LINEAR); - break; - case SDL_SCALEMODE_BEST: - IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MINFILTER, - D3DTEXF_GAUSSIANQUAD); - IDirect3DDevice9_SetSamplerState(data->device, 0, D3DSAMP_MAGFILTER, - D3DTEXF_GAUSSIANQUAD); - break; + texturedata->scaleMode); + data->scaleMode = texturedata->scaleMode; } result = @@ -1400,8 +1081,6 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, Uint32 format, void * pixels, int pitch) { D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; D3DSURFACE_DESC desc; LPDIRECT3DSURFACE9 backBuffer; LPDIRECT3DSURFACE9 surface; @@ -1451,7 +1130,7 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, } SDL_ConvertPixels(rect->w, rect->h, - display->current_mode.format, locked.pBits, locked.Pitch, + D3DFMTToPixelFormat(desc.Format), locked.pBits, locked.Pitch, format, pixels, pitch); IDirect3DSurface9_UnlockRect(surface); @@ -1462,15 +1141,6 @@ D3D_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, return 0; } -static int -D3D_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch) -{ - /* Work in progress */ - SDL_Unsupported(); - return -1; -} - static void D3D_RenderPresent(SDL_Renderer * renderer) { @@ -1504,9 +1174,6 @@ D3D_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) if (!data) { return; } - if (data->yuv) { - SDL_SW_DestroyYUVTexture(data->yuv); - } if (data->texture) { IDirect3DTexture9_Release(data->texture); } @@ -1523,11 +1190,15 @@ D3D_DestroyRenderer(SDL_Renderer * renderer) if (data->device) { IDirect3DDevice9_Release(data->device); } + if (data->d3d) { + IDirect3D9_Release(data->d3d); + SDL_UnloadObject(data->d3dDLL); + } SDL_free(data); } SDL_free(renderer); } -#endif /* SDL_VIDEO_RENDER_D3D */ +#endif /* SDL_VIDEO_RENDER_D3D && !SDL_RENDER_DISABLED */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/mmx.h b/project/jni/sdl-1.3/src/render/mmx.h similarity index 99% rename from project/jni/sdl-1.3/src/video/mmx.h rename to project/jni/sdl-1.3/src/render/mmx.h index 86190d473..3bd00ac23 100644 --- a/project/jni/sdl-1.3/src/video/mmx.h +++ b/project/jni/sdl-1.3/src/render/mmx.h @@ -293,7 +293,7 @@ mmx_ok(void) #define mmx_r2m(op, reg, mem) \ __asm__ __volatile__ (#op " %%" #reg ", %0" \ - : "=X" (mem) \ + : "=m" (mem) \ : /* nothing */ ) #define mmx_r2r(op, regs, regd) \ diff --git a/project/jni/sdl-1.3/src/render/nds/SDL_ndsrender.c b/project/jni/sdl-1.3/src/render/nds/SDL_ndsrender.c new file mode 100644 index 000000000..5edfea136 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/nds/SDL_ndsrender.c @@ -0,0 +1,361 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_RENDER_NDS + +#include +#include +#include + +#include + +#include "SDL_video.h" +#include "../../video/SDL_sysvideo.h" +#include "SDL_render.h" +#include "../SDL_sysrender.h" +#include "SDL_log.h" + +/* SDL NDS renderer implementation */ + +extern SDL_RenderDriver NDS_RenderDriver; + +typedef struct +{ + /* Whether current 3D engine is on the main or sub screen. */ + int is_sub; +} NDS_RenderData; + +typedef struct +{ + glImage image[1]; +} NDS_TextureData; + + +static int NDS_UpdateViewport(SDL_Renderer *renderer) +{ + /* Nothing to do. */ + return 0; +} + +static int +NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect) +{ + NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; + NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; + int dest_y; + + if (data->is_sub) { + dest_y = dstrect->y; + } else { + dest_y = dstrect->y-SCREEN_HEIGHT; + } + + if (texture->w == dstrect->w && texture->h == dstrect->h) { + /* No scaling */ + glSprite(dstrect->x, dest_y, GL_FLIP_NONE, txdat->image); + } else { + /* Convert the scaling proportion into a 20.12 value. */ + s32 scale_w = divf32(dstrect->w << 12, texture->w << 12); + s32 scale_h = divf32(dstrect->h << 12, texture->h << 12); + + glSpriteScaleXY(dstrect->x, dest_y, scale_w, scale_h, GL_FLIP_NONE, txdat->image); + } + + return 0; +} + +static int NDS_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + NDS_TextureData *txdat = NULL; + int i; + + SDL_Log("NDS_CreateTexture: NDS_CreateTexture.\n"); + + /* Sanity checks. */ + for (i=0; iformat == NDS_RenderDriver.info.texture_formats[i]) + break; + } + if (i == NDS_RenderDriver.info.num_texture_formats) { + SDL_SetError("Unsupported texture format (%x)", texture->format); + return -1; + } + + if (texture->w > NDS_RenderDriver.info.max_texture_width) { + SDL_SetError("Texture too large (%d)", texture->w); + return -1; + } + + if (texture->h > NDS_RenderDriver.info.max_texture_height) { + SDL_SetError("Texture too tall (%d)", texture->h); + return -1; + } + + texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData)); + txdat = (NDS_TextureData *) texture->driverdata; + if (!txdat) { + SDL_OutOfMemory(); + return -1; + } + + return 0; +} + +static void +NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + NDS_TextureData *txdat = texture->driverdata; + + /* free anything else allocated for texture */ + SDL_free(txdat); +} + +/* size is no more than 512. */ +static int get_gltexture_size(unsigned int size) +{ + if (size > 256) + return TEXTURE_SIZE_512; + else if (size > 128) + return TEXTURE_SIZE_256; + else if (size > 64) + return TEXTURE_SIZE_128; + else if (size > 32) + return TEXTURE_SIZE_64; + else if (size > 16) + return TEXTURE_SIZE_32; + else if (size > 8) + return TEXTURE_SIZE_16; + else + return TEXTURE_SIZE_8; +} + +static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; + + glLoadTileSet(txdat->image, + rect->w, rect->h, + rect->w, rect->h, + texture->format == SDL_PIXELFORMAT_ABGR1555 ? GL_RGBA : GL_RGB, + get_gltexture_size(rect->w), + get_gltexture_size(rect->h), + TEXGEN_OFF, 0, NULL, + pixels); + + return 0; +} + +static int NDS_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, + const SDL_Rect *rect, void **pixels, int *pitch) +{ + SDL_Log("enter %s (todo)\n", __func__); + + return 0; +} + +static void NDS_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + SDL_Log("enter %s\n", __func__); + /* stub! */ +} + +static int NDS_RenderClear(SDL_Renderer *renderer) +{ + glClearColor(renderer->r >> 3, + renderer->g >> 3, + renderer->b >> 3, + renderer->a >> 3); + + return 0; +} + +static void NDS_RenderPresent(SDL_Renderer * renderer) +{ + NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; + static int frame =0; + + glEnd2D(); + + glFlush(0); + + swiWaitForVBlank(); + + /* wait for capture unit to be ready */ + while(REG_DISPCAPCNT & DCAP_ENABLE); + + /* 3D engine can only work on one screen at a time. */ + data->is_sub = !data->is_sub; + if (data->is_sub) { + lcdMainOnBottom(); + vramSetBankC(VRAM_C_LCD); + vramSetBankD(VRAM_D_SUB_SPRITE); + REG_DISPCAPCNT = DCAP_BANK(2) | DCAP_ENABLE | DCAP_SIZE(3); + } else { + lcdMainOnTop(); + vramSetBankD(VRAM_D_LCD); + vramSetBankC(VRAM_C_SUB_BG); + REG_DISPCAPCNT = DCAP_BANK(3) | DCAP_ENABLE | DCAP_SIZE(3); + } + + glBegin2D(); +} + +static int NDS_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, + int count) +{ + NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; + int i; + int color = RGB15(renderer->r >> 3, + renderer->g >> 3, + renderer->b >> 3); + + for (i=0; i < count; i++) { + if (data->is_sub) { + glPutPixel(points[i].x, points[i].y, color); + } else { + glPutPixel(points[i].x, points[i].y - SCREEN_HEIGHT, color); + } + } + + return 0; +} + +static int NDS_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, + int count) +{ + NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; + int i; + int color = RGB15(renderer->r >> 3, + renderer->g >> 3, + renderer->b >> 3); + + for (i=0; i < count-1; i++) { + if (data->is_sub) { + glLine(points[i].x, points[i].y, points[i+1].x, points[i+1].y, color); + } else { + glLine(points[i].x, points[i].y - SCREEN_HEIGHT, + points[i+1].x, points[i+1].y - SCREEN_HEIGHT, color); + } + } + + return 0; +} + +static int NDS_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, + int count) +{ + NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; + int i; + int color = RGB15(renderer->r >> 3, + renderer->g >> 3, + renderer->b >> 3); + + for (i=0; iis_sub) { + glBoxFilled(rects[i].x, rects[i].y, + rects[i].x + rects[i].w, + rects[i].y + rects[i].h, color); + } else { + glBoxFilled(rects[i].x, rects[i].y - SCREEN_HEIGHT, + rects[i].x + rects[i].w, + rects[i].y + rects[i].h - SCREEN_HEIGHT, + color); + } + } + + return 0; +} + +static SDL_Renderer * +NDS_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + SDL_DisplayMode *displayMode = &display->current_mode; + SDL_Renderer *renderer; + NDS_RenderData *data; + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + + if (displayMode->format != SDL_PIXELFORMAT_ABGR1555) { + SDL_SetError("Unsupported pixel format (%x)", displayMode->format); + return NULL; + } + + if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp, + &Rmask, &Gmask, &Bmask, &Amask)) { + SDL_SetError("Unknown display format"); + return NULL; + } + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (NDS_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_free(renderer); + SDL_OutOfMemory(); + return NULL; + } + + renderer->info = NDS_RenderDriver.info; + renderer->info.flags = SDL_RENDERER_ACCELERATED; + + renderer->UpdateViewport = NDS_UpdateViewport; + renderer->CreateTexture = NDS_CreateTexture; + renderer->DestroyTexture = NDS_DestroyTexture; + renderer->RenderCopy = NDS_RenderCopy; + renderer->UpdateTexture = NDS_UpdateTexture; + renderer->LockTexture = NDS_LockTexture; + renderer->UnlockTexture = NDS_UnlockTexture; + renderer->RenderClear = NDS_RenderClear; + renderer->RenderPresent = NDS_RenderPresent; + renderer->RenderDrawPoints = NDS_RenderDrawPoints; + renderer->RenderDrawLines = NDS_RenderDrawLines; + renderer->RenderFillRects = NDS_RenderFillRects; + + renderer->driverdata = data; + + return renderer; +} + +SDL_RenderDriver NDS_RenderDriver = { + .CreateRenderer = NDS_CreateRenderer, + .info = { + .name = "nds", + .flags = SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC, + .num_texture_formats = 2, + .texture_formats = { [0] = SDL_PIXELFORMAT_ABGR1555, + [1] = SDL_PIXELFORMAT_BGR555, + }, + .max_texture_width = 512, + .max_texture_height = 512, + } +}; + +#endif /* SDL_VIDEO_RENDER_NDS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_glfuncs.h b/project/jni/sdl-1.3/src/render/opengl/SDL_glfuncs.h similarity index 99% rename from project/jni/sdl-1.3/src/video/SDL_glfuncs.h rename to project/jni/sdl-1.3/src/render/opengl/SDL_glfuncs.h index 354d146c2..b76f97145 100644 --- a/project/jni/sdl-1.3/src/video/SDL_glfuncs.h +++ b/project/jni/sdl-1.3/src/render/opengl/SDL_glfuncs.h @@ -3,6 +3,7 @@ change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild. */ #define SDL_PROC_UNUSED(ret,func,params) + SDL_PROC_UNUSED(void, glAccum, (GLenum, GLfloat)) SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum, GLclampf)) SDL_PROC_UNUSED(GLboolean, glAreTexturesResident, @@ -336,8 +337,7 @@ SDL_PROC_UNUSED(void, glRotatef, (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) SDL_PROC_UNUSED(void, glScaled, (GLdouble x, GLdouble y, GLdouble z)) SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED(void, glScissor, - (GLint x, GLint y, GLsizei width, GLsizei height)) +SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height)) SDL_PROC_UNUSED(void, glSelectBuffer, (GLsizei size, GLuint * buffer)) SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode)) SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask)) diff --git a/project/jni/sdl-1.3/src/render/opengl/SDL_render_gl.c b/project/jni/sdl-1.3/src/render/opengl/SDL_render_gl.c new file mode 100644 index 000000000..320044645 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/opengl/SDL_render_gl.c @@ -0,0 +1,1026 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED + +#include "SDL_hints.h" +#include "SDL_log.h" +#include "SDL_opengl.h" +#include "../SDL_sysrender.h" +#include "SDL_shaders_gl.h" + +#ifdef __MACOSX__ +#include +#endif + + +/* OpenGL renderer implementation */ + +/* Details on optimizing the texture path on Mac OS X: + http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/opengl_texturedata.html +*/ + +/* Used to re-create the window with OpenGL capability */ +extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); + +static const float inv255f = 1.0f / 255.0f; + +static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags); +static void GL_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int GL_UpdateViewport(SDL_Renderer * renderer); +static int GL_RenderClear(SDL_Renderer * renderer); +static int GL_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, int count); +static int GL_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, int count); +static int GL_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, int count); +static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect); +static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); +static void GL_RenderPresent(SDL_Renderer * renderer); +static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static void GL_DestroyRenderer(SDL_Renderer * renderer); + + +SDL_RenderDriver GL_RenderDriver = { + GL_CreateRenderer, + { + "opengl", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), + 1, + {SDL_PIXELFORMAT_ARGB8888}, + 0, + 0} +}; + +typedef struct +{ + SDL_GLContext context; + SDL_bool GL_ARB_texture_rectangle_supported; + struct { + GL_Shader shader; + Uint32 color; + int blendMode; + } current; + + /* OpenGL functions */ +#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; +#include "SDL_glfuncs.h" +#undef SDL_PROC + + /* Multitexture support */ + SDL_bool GL_ARB_multitexture_supported; + PFNGLACTIVETEXTUREARBPROC glActiveTextureARB; + GLint num_texture_units; + + /* Shader support */ + GL_ShaderContext *shaders; + +} GL_RenderData; + +typedef struct +{ + GLuint texture; + GLenum type; + GLfloat texw; + GLfloat texh; + GLenum format; + GLenum formattype; + void *pixels; + int pitch; + SDL_Rect locked_rect; + + /* YV12 texture support */ + SDL_bool yuv; + GLuint utexture; + GLuint vtexture; +} GL_TextureData; + + +static void +GL_SetError(const char *prefix, GLenum result) +{ + const char *error; + + switch (result) { + case GL_NO_ERROR: + error = "GL_NO_ERROR"; + break; + case GL_INVALID_ENUM: + error = "GL_INVALID_ENUM"; + break; + case GL_INVALID_VALUE: + error = "GL_INVALID_VALUE"; + break; + case GL_INVALID_OPERATION: + error = "GL_INVALID_OPERATION"; + break; + case GL_STACK_OVERFLOW: + error = "GL_STACK_OVERFLOW"; + break; + case GL_STACK_UNDERFLOW: + error = "GL_STACK_UNDERFLOW"; + break; + case GL_OUT_OF_MEMORY: + error = "GL_OUT_OF_MEMORY"; + break; + case GL_TABLE_TOO_LARGE: + error = "GL_TABLE_TOO_LARGE"; + break; + default: + error = "UNKNOWN"; + break; + } + SDL_SetError("%s: %s", prefix, error); +} + +static int +GL_LoadFunctions(GL_RenderData * data) +{ +#ifdef __SDL_NOGETPROCADDR__ +#define SDL_PROC(ret,func,params) data->func=func; +#else +#define SDL_PROC(ret,func,params) \ + do { \ + data->func = SDL_GL_GetProcAddress(#func); \ + if ( ! data->func ) { \ + SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \ + return -1; \ + } \ + } while ( 0 ); +#endif /* __SDL_NOGETPROCADDR__ */ + +#include "SDL_glfuncs.h" +#undef SDL_PROC + return 0; +} + +static SDL_GLContext SDL_CurrentContext = NULL; + +static int +GL_ActivateRenderer(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { + return -1; + } + SDL_CurrentContext = data->context; + + GL_UpdateViewport(renderer); + } + return 0; +} + +/* This is called if we need to invalidate all of the SDL OpenGL state */ +static void +GL_ResetState(SDL_Renderer *renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext == data->context) { + GL_UpdateViewport(renderer); + } else { + GL_ActivateRenderer(renderer); + } + + data->current.shader = SHADER_NONE; + data->current.color = 0; + data->current.blendMode = -1; + + data->glDisable(GL_DEPTH_TEST); + data->glDisable(GL_CULL_FACE); + /* This ended up causing video discrepancies between OpenGL and Direct3D */ + /*data->glEnable(GL_LINE_SMOOTH);*/ + + data->glMatrixMode(GL_MODELVIEW); + data->glLoadIdentity(); +} + +SDL_Renderer * +GL_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_Renderer *renderer; + GL_RenderData *data; + const char *hint; + GLint value; + Uint32 window_flags; + + window_flags = SDL_GetWindowFlags(window); + if (!(window_flags & SDL_WINDOW_OPENGL)) { + if (SDL_RecreateWindow(window, window_flags | SDL_WINDOW_OPENGL) < 0) { + return NULL; + } + } + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (GL_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + GL_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + + renderer->WindowEvent = GL_WindowEvent; + renderer->CreateTexture = GL_CreateTexture; + renderer->UpdateTexture = GL_UpdateTexture; + renderer->LockTexture = GL_LockTexture; + renderer->UnlockTexture = GL_UnlockTexture; + renderer->UpdateViewport = GL_UpdateViewport; + renderer->RenderClear = GL_RenderClear; + renderer->RenderDrawPoints = GL_RenderDrawPoints; + renderer->RenderDrawLines = GL_RenderDrawLines; + renderer->RenderFillRects = GL_RenderFillRects; + renderer->RenderCopy = GL_RenderCopy; + renderer->RenderReadPixels = GL_RenderReadPixels; + renderer->RenderPresent = GL_RenderPresent; + renderer->DestroyTexture = GL_DestroyTexture; + renderer->DestroyRenderer = GL_DestroyRenderer; + renderer->info = GL_RenderDriver.info; + renderer->info.flags = SDL_RENDERER_ACCELERATED; + renderer->driverdata = data; + + data->context = SDL_GL_CreateContext(window); + if (!data->context) { + GL_DestroyRenderer(renderer); + return NULL; + } + if (SDL_GL_MakeCurrent(window, data->context) < 0) { + GL_DestroyRenderer(renderer); + return NULL; + } + + if (GL_LoadFunctions(data) < 0) { + GL_DestroyRenderer(renderer); + return NULL; + } + +#ifdef __MACOSX__ + /* Enable multi-threaded rendering */ + /* Disabled until Ryan finishes his VBO/PBO code... + CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine); + */ +#endif + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + if (SDL_GL_GetSwapInterval() > 0) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_height = value; + + if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") + || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { + data->GL_ARB_texture_rectangle_supported = SDL_TRUE; + } + + /* Check for multitexture support */ + if (SDL_GL_ExtensionSupported("GL_ARB_multitexture")) { + data->glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) SDL_GL_GetProcAddress("glActiveTextureARB"); + if (data->glActiveTextureARB) { + data->GL_ARB_multitexture_supported = SDL_TRUE; + data->glGetIntegerv(GL_MAX_TEXTURE_UNITS_ARB, &data->num_texture_units); + } + } + + /* Check for shader support */ + hint = SDL_GetHint(SDL_HINT_RENDER_OPENGL_SHADERS); + if (!hint || *hint != '0') { + data->shaders = GL_CreateShaderContext(); + } + SDL_LogInfo(SDL_LOG_CATEGORY_RENDER, "OpenGL shaders: %s", + data->shaders ? "ENABLED" : "DISABLED"); + + /* We support YV12 textures using 3 textures and a shader */ + if (data->shaders && data->num_texture_units >= 3) { + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_YV12; + renderer->info.texture_formats[renderer->info.num_texture_formats++] = SDL_PIXELFORMAT_IYUV; + } + + /* Set up parameters for rendering */ + GL_ResetState(renderer); + + return renderer; +} + +static void +GL_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + /* Rebind the context to the window area and update matrices */ + SDL_CurrentContext = NULL; + } +} + +static __inline__ int +power_of_2(int input) +{ + int value = 1; + + while (value < input) { + value <<= 1; + } + return value; +} + +static __inline__ SDL_bool +convert_format(GL_RenderData *renderdata, Uint32 pixel_format, + GLint* internalFormat, GLenum* format, GLenum* type) +{ + switch (pixel_format) { + case SDL_PIXELFORMAT_ARGB8888: + *internalFormat = GL_RGBA8; + *format = GL_BGRA; + *type = GL_UNSIGNED_INT_8_8_8_8_REV; + break; + case SDL_PIXELFORMAT_YV12: + case SDL_PIXELFORMAT_IYUV: + *internalFormat = GL_LUMINANCE; + *format = GL_LUMINANCE; + *type = GL_UNSIGNED_BYTE; + break; + default: + return SDL_FALSE; + } + return SDL_TRUE; +} + +static GLenum +GetScaleQuality(void) +{ + const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); + + if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { + return GL_NEAREST; + } else { + return GL_LINEAR; + } +} + +static int +GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data; + GLint internalFormat; + GLenum format, type; + int texture_w, texture_h; + GLenum scaleMode; + GLenum result; + + GL_ActivateRenderer(renderer); + + if (!convert_format(renderdata, texture->format, &internalFormat, + &format, &type)) { + SDL_SetError("Texture format %s not supported by OpenGL", + SDL_GetPixelFormatName(texture->format)); + return -1; + } + + data = (GL_TextureData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_OutOfMemory(); + return -1; + } + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + size_t size; + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + size = texture->h * data->pitch; + if (texture->format == SDL_PIXELFORMAT_YV12 || + texture->format == SDL_PIXELFORMAT_IYUV) { + /* Need to add size for the U and V planes */ + size += (2 * (texture->h * data->pitch) / 4); + } + data->pixels = SDL_calloc(1, size); + if (!data->pixels) { + SDL_OutOfMemory(); + SDL_free(data); + return -1; + } + } + + texture->driverdata = data; + + renderdata->glGetError(); + renderdata->glGenTextures(1, &data->texture); + if (renderdata->GL_ARB_texture_rectangle_supported) { + data->type = GL_TEXTURE_RECTANGLE_ARB; + texture_w = texture->w; + texture_h = texture->h; + data->texw = (GLfloat) texture_w; + data->texh = (GLfloat) texture_h; + } else { + data->type = GL_TEXTURE_2D; + texture_w = power_of_2(texture->w); + texture_h = power_of_2(texture->h); + data->texw = (GLfloat) (texture->w) / texture_w; + data->texh = (GLfloat) texture->h / texture_h; + } + + data->format = format; + data->formattype = type; + scaleMode = GetScaleQuality(); + renderdata->glEnable(data->type); + renderdata->glBindTexture(data->type, data->texture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); +#ifdef __MACOSX__ +#ifndef GL_TEXTURE_STORAGE_HINT_APPLE +#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC +#endif +#ifndef STORAGE_CACHED_APPLE +#define STORAGE_CACHED_APPLE 0x85BE +#endif +#ifndef STORAGE_SHARED_APPLE +#define STORAGE_SHARED_APPLE 0x85BF +#endif + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE, + GL_STORAGE_SHARED_APPLE); + } else { + renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE, + GL_STORAGE_CACHED_APPLE); + } + if (texture->access == SDL_TEXTUREACCESS_STREAMING + && texture->format == SDL_PIXELFORMAT_ARGB8888 + && (texture->w % 8) == 0) { + renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, + (data->pitch / SDL_BYTESPERPIXEL(texture->format))); + renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, + texture_h, 0, format, type, data->pixels); + renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); + } + else +#endif + { + renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, + texture_h, 0, format, type, NULL); + } + renderdata->glDisable(data->type); + result = renderdata->glGetError(); + if (result != GL_NO_ERROR) { + GL_SetError("glTexImage2D()", result); + return -1; + } + + if (texture->format == SDL_PIXELFORMAT_YV12 || + texture->format == SDL_PIXELFORMAT_IYUV) { + data->yuv = SDL_TRUE; + + renderdata->glGenTextures(1, &data->utexture); + renderdata->glGenTextures(1, &data->vtexture); + renderdata->glEnable(data->type); + + renderdata->glBindTexture(data->type, data->utexture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w/2, + texture_h/2, 0, format, type, NULL); + + renderdata->glBindTexture(data->type, data->vtexture); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, + scaleMode); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, + GL_CLAMP_TO_EDGE); + renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, + GL_CLAMP_TO_EDGE); + renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w/2, + texture_h/2, 0, format, type, NULL); + + renderdata->glDisable(data->type); + } + return 0; +} + +static int +GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + GLenum result; + + GL_ActivateRenderer(renderer); + + renderdata->glGetError(); + renderdata->glEnable(data->type); + renderdata->glBindTexture(data->type, data->texture); + renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, + (pitch / SDL_BYTESPERPIXEL(texture->format))); + renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, + rect->h, data->format, data->formattype, + pixels); + if (data->yuv) { + const void *top; + + renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, (pitch / 2)); + + /* Skip to the top of the next texture */ + top = (const void*)((const Uint8*)pixels + (texture->h-rect->y) * pitch - rect->x); + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2); + if (texture->format == SDL_PIXELFORMAT_YV12) { + renderdata->glBindTexture(data->type, data->vtexture); + } else { + renderdata->glBindTexture(data->type, data->utexture); + } + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + rect->w/2, rect->h/2, + data->format, data->formattype, pixels); + + /* Skip to the top of the next texture */ + top = (const void*)((const Uint8*)top + (texture->h * pitch)/4); + + /* Skip to the correct offset into the next texture */ + pixels = (const void*)((const Uint8*)top + (rect->y / 2) * pitch + rect->x / 2); + if (texture->format == SDL_PIXELFORMAT_YV12) { + renderdata->glBindTexture(data->type, data->utexture); + } else { + renderdata->glBindTexture(data->type, data->vtexture); + } + renderdata->glTexSubImage2D(data->type, 0, rect->x/2, rect->y/2, + rect->w/2, rect->h/2, + data->format, data->formattype, pixels); + } + renderdata->glDisable(data->type); + result = renderdata->glGetError(); + if (result != GL_NO_ERROR) { + GL_SetError("glTexSubImage2D()", result); + return -1; + } + return 0; +} + +static int +GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + + data->locked_rect = *rect; + *pixels = + (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = data->pitch; + return 0; +} + +static void +GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + const SDL_Rect *rect; + void *pixels; + + rect = &data->locked_rect; + pixels = + (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + GL_UpdateTexture(renderer, texture, rect, pixels, data->pitch); +} + +static int +GL_UpdateViewport(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + /* We'll update the viewport after we rebind the context */ + return 0; + } + + data->glViewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + + data->glMatrixMode(GL_PROJECTION); + data->glLoadIdentity(); + data->glOrtho((GLdouble) 0, + (GLdouble) renderer->viewport.w, + (GLdouble) renderer->viewport.h, + (GLdouble) 0, 0.0, 1.0); + return 0; +} + +static void +GL_SetShader(GL_RenderData * data, GL_Shader shader) +{ + if (data->shaders && shader != data->current.shader) { + GL_SelectShader(data->shaders, shader); + data->current.shader = shader; + } +} + +static void +GL_SetColor(GL_RenderData * data, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b); + + if (color != data->current.color) { + data->glColor4f((GLfloat) r * inv255f, + (GLfloat) g * inv255f, + (GLfloat) b * inv255f, + (GLfloat) a * inv255f); + data->current.color = color; + } +} + +static void +GL_SetBlendMode(GL_RenderData * data, int blendMode) +{ + if (blendMode != data->current.blendMode) { + switch (blendMode) { + case SDL_BLENDMODE_NONE: + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + data->glDisable(GL_BLEND); + break; + case SDL_BLENDMODE_BLEND: + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + data->glEnable(GL_BLEND); + data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + case SDL_BLENDMODE_ADD: + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + data->glEnable(GL_BLEND); + data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); + break; + case SDL_BLENDMODE_MOD: + data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + data->glEnable(GL_BLEND); + data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); + break; + } + data->current.blendMode = blendMode; + } +} + +static void +GL_SetDrawingState(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + GL_ActivateRenderer(renderer); + + GL_SetColor(data, renderer->r, + renderer->g, + renderer->b, + renderer->a); + + GL_SetBlendMode(data, renderer->blendMode); + + GL_SetShader(data, SHADER_SOLID); +} + +static int +GL_RenderClear(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + GL_ActivateRenderer(renderer); + + data->glClearColor((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + data->glClear(GL_COLOR_BUFFER_BIT); + + return 0; +} + +static int +GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, + int count) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + int i; + + GL_SetDrawingState(renderer); + + data->glBegin(GL_POINTS); + for (i = 0; i < count; ++i) { + data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); + } + data->glEnd(); + + return 0; +} + +static int +GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, + int count) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + int i; + + GL_SetDrawingState(renderer); + + if (count > 2 && + points[0].x == points[count-1].x && points[0].y == points[count-1].y) { + data->glBegin(GL_LINE_LOOP); + /* GL_LINE_LOOP takes care of the final segment */ + --count; + for (i = 0; i < count; ++i) { + data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); + } + data->glEnd(); + } else { +#if defined(__APPLE__) || defined(__WIN32__) +#else + int x1, y1, x2, y2; +#endif + + data->glBegin(GL_LINE_STRIP); + for (i = 0; i < count; ++i) { + data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); + } + data->glEnd(); + + /* The line is half open, so we need one more point to complete it. + * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html + * If we have to, we can use vertical line and horizontal line textures + * for vertical and horizontal lines, and then create custom textures + * for diagonal lines and software render those. It's terrible, but at + * least it would be pixel perfect. + */ + data->glBegin(GL_POINTS); +#if defined(__APPLE__) || defined(__WIN32__) + /* Mac OS X and Windows seem to always leave the second point open */ + data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y); +#else + /* Linux seems to leave the right-most or bottom-most point open */ + x1 = points[0].x; + y1 = points[0].y; + x2 = points[count-1].x; + y2 = points[count-1].y; + + if (x1 > x2) { + data->glVertex2f(0.5f + x1, 0.5f + y1); + } else if (x2 > x1) { + data->glVertex2f(0.5f + x2, 0.5f + y2); + } else if (y1 > y2) { + data->glVertex2f(0.5f + x1, 0.5f + y1); + } else if (y2 > y1) { + data->glVertex2f(0.5f + x2, 0.5f + y2); + } +#endif + data->glEnd(); + } + + return 0; +} + +static int +GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + int i; + + GL_SetDrawingState(renderer); + + for (i = 0; i < count; ++i) { + const SDL_Rect *rect = &rects[i]; + + data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h); + } + + return 0; +} + +static int +GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; + int minx, miny, maxx, maxy; + GLfloat minu, maxu, minv, maxv; + + GL_ActivateRenderer(renderer); + + data->glEnable(texturedata->type); + if (texturedata->yuv) { + data->glActiveTextureARB(GL_TEXTURE2_ARB); + data->glBindTexture(texturedata->type, texturedata->vtexture); + + data->glActiveTextureARB(GL_TEXTURE1_ARB); + data->glBindTexture(texturedata->type, texturedata->utexture); + + data->glActiveTextureARB(GL_TEXTURE0_ARB); + } + data->glBindTexture(texturedata->type, texturedata->texture); + + if (texture->modMode) { + GL_SetColor(data, texture->r, texture->g, texture->b, texture->a); + } else { + GL_SetColor(data, 255, 255, 255, 255); + } + + GL_SetBlendMode(data, texture->blendMode); + + if (texturedata->yuv) { + GL_SetShader(data, SHADER_YV12); + } else { + GL_SetShader(data, SHADER_RGB); + } + + minx = dstrect->x; + miny = dstrect->y; + maxx = dstrect->x + dstrect->w; + maxy = dstrect->y + dstrect->h; + + minu = (GLfloat) srcrect->x / texture->w; + minu *= texturedata->texw; + maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; + maxu *= texturedata->texw; + minv = (GLfloat) srcrect->y / texture->h; + minv *= texturedata->texh; + maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; + maxv *= texturedata->texh; + + data->glBegin(GL_TRIANGLE_STRIP); + data->glTexCoord2f(minu, minv); + data->glVertex2f((GLfloat) minx, (GLfloat) miny); + data->glTexCoord2f(maxu, minv); + data->glVertex2f((GLfloat) maxx, (GLfloat) miny); + data->glTexCoord2f(minu, maxv); + data->glVertex2f((GLfloat) minx, (GLfloat) maxy); + data->glTexCoord2f(maxu, maxv); + data->glVertex2f((GLfloat) maxx, (GLfloat) maxy); + data->glEnd(); + + data->glDisable(texturedata->type); + + return 0; +} + +static int +GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + SDL_Window *window = renderer->window; + Uint32 temp_format = SDL_PIXELFORMAT_ARGB8888; + void *temp_pixels; + int temp_pitch; + GLint internalFormat; + GLenum format, type; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + GL_ActivateRenderer(renderer); + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + SDL_OutOfMemory(); + return -1; + } + + convert_format(data, temp_format, &internalFormat, &format, &type); + + SDL_GetWindowSize(window, &w, &h); + + data->glPixelStorei(GL_PACK_ALIGNMENT, 1); + data->glPixelStorei(GL_PACK_ROW_LENGTH, + (temp_pitch / SDL_BYTESPERPIXEL(temp_format))); + + data->glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, + format, type, temp_pixels); + + /* Flip the rows to be top-down */ + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_stack_alloc(Uint8, length); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_stack_free(tmp); + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + +static void +GL_RenderPresent(SDL_Renderer * renderer) +{ + GL_ActivateRenderer(renderer); + + SDL_GL_SwapWindow(renderer->window); +} + +static void +GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; + GL_TextureData *data = (GL_TextureData *) texture->driverdata; + + GL_ActivateRenderer(renderer); + + if (!data) { + return; + } + if (data->texture) { + renderdata->glDeleteTextures(1, &data->texture); + } + if (data->yuv) { + renderdata->glDeleteTextures(1, &data->utexture); + renderdata->glDeleteTextures(1, &data->vtexture); + } + if (data->pixels) { + SDL_free(data->pixels); + } + SDL_free(data); + texture->driverdata = NULL; +} + +static void +GL_DestroyRenderer(SDL_Renderer * renderer) +{ + GL_RenderData *data = (GL_RenderData *) renderer->driverdata; + + if (data) { + if (data->shaders) { + GL_DestroyShaderContext(data->shaders); + } + if (data->context) { + /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */ + SDL_GL_DeleteContext(data->context); + } + SDL_free(data); + } + SDL_free(renderer); +} + +#endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/opengl/SDL_shaders_gl.c b/project/jni/sdl-1.3/src/render/opengl/SDL_shaders_gl.c new file mode 100644 index 000000000..1bf351d72 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/opengl/SDL_shaders_gl.c @@ -0,0 +1,358 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED + +#include "SDL_stdinc.h" +#include "SDL_log.h" +#include "SDL_opengl.h" +#include "SDL_video.h" +#include "SDL_shaders_gl.h" + +/* OpenGL shader implementation */ + +/*#define DEBUG_SHADERS*/ + +typedef struct +{ + GLhandleARB program; + GLhandleARB vert_shader; + GLhandleARB frag_shader; +} GL_ShaderData; + +struct GL_ShaderContext +{ + GLenum (*glGetError)(void); + + PFNGLATTACHOBJECTARBPROC glAttachObjectARB; + PFNGLCOMPILESHADERARBPROC glCompileShaderARB; + PFNGLCREATEPROGRAMOBJECTARBPROC glCreateProgramObjectARB; + PFNGLCREATESHADEROBJECTARBPROC glCreateShaderObjectARB; + PFNGLDELETEOBJECTARBPROC glDeleteObjectARB; + PFNGLGETINFOLOGARBPROC glGetInfoLogARB; + PFNGLGETOBJECTPARAMETERIVARBPROC glGetObjectParameterivARB; + PFNGLGETUNIFORMLOCATIONARBPROC glGetUniformLocationARB; + PFNGLLINKPROGRAMARBPROC glLinkProgramARB; + PFNGLSHADERSOURCEARBPROC glShaderSourceARB; + PFNGLUNIFORM1IARBPROC glUniform1iARB; + PFNGLUNIFORM1FARBPROC glUniform1fARB; + PFNGLUSEPROGRAMOBJECTARBPROC glUseProgramObjectARB; + + SDL_bool GL_ARB_texture_rectangle_supported; + + GL_ShaderData shaders[NUM_SHADERS]; +}; + +/* + * NOTE: Always use sampler2D, etc here. We'll #define them to the + * texture_rectangle versions if we choose to use that extension. + */ +static const char *shader_source[NUM_SHADERS][2] = +{ + /* SHADER_NONE */ + { NULL, NULL }, + + /* SHADER_SOLID */ + { + /* vertex shader */ +"varying vec4 v_color;\n" +"\n" +"void main()\n" +"{\n" +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +" v_color = gl_Color;\n" +"}", + /* fragment shader */ +"varying vec4 v_color;\n" +"\n" +"void main()\n" +"{\n" +" gl_FragColor = v_color;\n" +"}" + }, + + /* SHADER_RGB */ + { + /* vertex shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"\n" +"void main()\n" +"{\n" +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +" v_color = gl_Color;\n" +" v_texCoord = vec2(gl_MultiTexCoord0);\n" +"}", + /* fragment shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"uniform sampler2D tex0;\n" +"\n" +"void main()\n" +"{\n" +" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n" +"}" + }, + + /* SHADER_YV12 */ + { + /* vertex shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"\n" +"void main()\n" +"{\n" +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +" v_color = gl_Color;\n" +" v_texCoord = vec2(gl_MultiTexCoord0);\n" +"}", + /* fragment shader */ +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"uniform sampler2D tex0; // Y \n" +"uniform sampler2D tex1; // U \n" +"uniform sampler2D tex2; // V \n" +"\n" +"// YUV offset \n" +"const vec3 offset = vec3(-0.0625, -0.5, -0.5);\n" +"\n" +"// RGB coefficients \n" +"const vec3 Rcoeff = vec3(1.164, 0.000, 1.596);\n" +"const vec3 Gcoeff = vec3(1.164, -0.391, -0.813);\n" +"const vec3 Bcoeff = vec3(1.164, 2.018, 0.000);\n" +"\n" +"void main()\n" +"{\n" +" vec2 tcoord;\n" +" vec3 yuv, rgb;\n" +"\n" +" // Get the Y value \n" +" tcoord = v_texCoord;\n" +" yuv.x = texture2D(tex0, tcoord).r;\n" +"\n" +" // Get the U and V values \n" +" tcoord *= 0.5;\n" +" yuv.y = texture2D(tex1, tcoord).r;\n" +" yuv.z = texture2D(tex2, tcoord).r;\n" +"\n" +" // Do the color transform \n" +" yuv += offset;\n" +" rgb.r = dot(yuv, Rcoeff);\n" +" rgb.g = dot(yuv, Gcoeff);\n" +" rgb.b = dot(yuv, Bcoeff);\n" +"\n" +" // That was easy. :) \n" +" gl_FragColor = vec4(rgb, 1.0) * v_color;\n" +"}" + }, +}; + +static SDL_bool +CompileShader(GL_ShaderContext *ctx, GLhandleARB shader, const char *defines, const char *source) +{ + GLint status; + const char *sources[2]; + + sources[0] = defines; + sources[1] = source; + + ctx->glShaderSourceARB(shader, SDL_arraysize(sources), sources, NULL); + ctx->glCompileShaderARB(shader); + ctx->glGetObjectParameterivARB(shader, GL_OBJECT_COMPILE_STATUS_ARB, &status); + if (status == 0) { + GLint length; + char *info; + + ctx->glGetObjectParameterivARB(shader, GL_OBJECT_INFO_LOG_LENGTH_ARB, &length); + info = SDL_stack_alloc(char, length+1); + ctx->glGetInfoLogARB(shader, length, NULL, info); + SDL_LogError(SDL_LOG_CATEGORY_RENDER, + "Failed to compile shader:\n%s%s\n%s", defines, source, info); +#ifdef DEBUG_SHADERS + fprintf(stderr, + "Failed to compile shader:\n%s%s\n%s", defines, source, info); +#endif + SDL_stack_free(info); + + return SDL_FALSE; + } else { + return SDL_TRUE; + } +} + +static SDL_bool +CompileShaderProgram(GL_ShaderContext *ctx, int index, GL_ShaderData *data) +{ + const int num_tmus_bound = 4; + const char *vert_defines = ""; + const char *frag_defines = ""; + int i; + GLint location; + + if (index == SHADER_NONE) { + return SDL_TRUE; + } + + ctx->glGetError(); + + /* Make sure we use the correct sampler type for our texture type */ + if (ctx->GL_ARB_texture_rectangle_supported) { + frag_defines = +"#define sampler2D sampler2DRect\n" +"#define texture2D texture2DRect\n"; + } + + /* Create one program object to rule them all */ + data->program = ctx->glCreateProgramObjectARB(); + + /* Create the vertex shader */ + data->vert_shader = ctx->glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB); + if (!CompileShader(ctx, data->vert_shader, vert_defines, shader_source[index][0])) { + return SDL_FALSE; + } + + /* Create the fragment shader */ + data->frag_shader = ctx->glCreateShaderObjectARB(GL_FRAGMENT_SHADER_ARB); + if (!CompileShader(ctx, data->frag_shader, frag_defines, shader_source[index][1])) { + return SDL_FALSE; + } + + /* ... and in the darkness bind them */ + ctx->glAttachObjectARB(data->program, data->vert_shader); + ctx->glAttachObjectARB(data->program, data->frag_shader); + ctx->glLinkProgramARB(data->program); + + /* Set up some uniform variables */ + ctx->glUseProgramObjectARB(data->program); + for (i = 0; i < num_tmus_bound; ++i) { + char tex_name[5]; + SDL_snprintf(tex_name, SDL_arraysize(tex_name), "tex%d", i); + location = ctx->glGetUniformLocationARB(data->program, tex_name); + if (location >= 0) { + ctx->glUniform1iARB(location, i); + } + } + ctx->glUseProgramObjectARB(0); + + return (ctx->glGetError() == GL_NO_ERROR); +} + +static void +DestroyShaderProgram(GL_ShaderContext *ctx, GL_ShaderData *data) +{ + ctx->glDeleteObjectARB(data->vert_shader); + ctx->glDeleteObjectARB(data->frag_shader); + ctx->glDeleteObjectARB(data->program); +} + +GL_ShaderContext * +GL_CreateShaderContext() +{ + GL_ShaderContext *ctx; + SDL_bool shaders_supported; + int i; + + ctx = (GL_ShaderContext *)SDL_calloc(1, sizeof(*ctx)); + if (!ctx) { + return NULL; + } + + if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") + || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { + ctx->GL_ARB_texture_rectangle_supported = SDL_TRUE; + } + + /* Check for shader support */ + shaders_supported = SDL_FALSE; + if (SDL_GL_ExtensionSupported("GL_ARB_shader_objects") && + SDL_GL_ExtensionSupported("GL_ARB_shading_language_100") && + SDL_GL_ExtensionSupported("GL_ARB_vertex_shader") && + SDL_GL_ExtensionSupported("GL_ARB_fragment_shader")) { + ctx->glGetError = (GLenum (*)(void)) SDL_GL_GetProcAddress("glGetError"); + ctx->glAttachObjectARB = (PFNGLATTACHOBJECTARBPROC) SDL_GL_GetProcAddress("glAttachObjectARB"); + ctx->glCompileShaderARB = (PFNGLCOMPILESHADERARBPROC) SDL_GL_GetProcAddress("glCompileShaderARB"); + ctx->glCreateProgramObjectARB = (PFNGLCREATEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glCreateProgramObjectARB"); + ctx->glCreateShaderObjectARB = (PFNGLCREATESHADEROBJECTARBPROC) SDL_GL_GetProcAddress("glCreateShaderObjectARB"); + ctx->glDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) SDL_GL_GetProcAddress("glDeleteObjectARB"); + ctx->glGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) SDL_GL_GetProcAddress("glGetInfoLogARB"); + ctx->glGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC) SDL_GL_GetProcAddress("glGetObjectParameterivARB"); + ctx->glGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC) SDL_GL_GetProcAddress("glGetUniformLocationARB"); + ctx->glLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) SDL_GL_GetProcAddress("glLinkProgramARB"); + ctx->glShaderSourceARB = (PFNGLSHADERSOURCEARBPROC) SDL_GL_GetProcAddress("glShaderSourceARB"); + ctx->glUniform1iARB = (PFNGLUNIFORM1IARBPROC) SDL_GL_GetProcAddress("glUniform1iARB"); + ctx->glUniform1fARB = (PFNGLUNIFORM1FARBPROC) SDL_GL_GetProcAddress("glUniform1fARB"); + ctx->glUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) SDL_GL_GetProcAddress("glUseProgramObjectARB"); + if (ctx->glGetError && + ctx->glAttachObjectARB && + ctx->glCompileShaderARB && + ctx->glCreateProgramObjectARB && + ctx->glCreateShaderObjectARB && + ctx->glDeleteObjectARB && + ctx->glGetInfoLogARB && + ctx->glGetObjectParameterivARB && + ctx->glGetUniformLocationARB && + ctx->glLinkProgramARB && + ctx->glShaderSourceARB && + ctx->glUniform1iARB && + ctx->glUniform1fARB && + ctx->glUseProgramObjectARB) { + shaders_supported = SDL_TRUE; + } + } + + if (!shaders_supported) { + SDL_free(ctx); + return NULL; + } + + /* Compile all the shaders */ + for (i = 0; i < NUM_SHADERS; ++i) { + if (!CompileShaderProgram(ctx, i, &ctx->shaders[i])) { + GL_DestroyShaderContext(ctx); + return NULL; + } + } + + /* We're done! */ + return ctx; +} + +void +GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader) +{ + ctx->glUseProgramObjectARB(ctx->shaders[shader].program); +} + +void +GL_DestroyShaderContext(GL_ShaderContext *ctx) +{ + int i; + + for (i = 0; i < NUM_SHADERS; ++i) { + DestroyShaderProgram(ctx, &ctx->shaders[i]); + } + SDL_free(ctx); +} + +#endif /* SDL_VIDEO_RENDER_OGL && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/opengl/SDL_shaders_gl.h b/project/jni/sdl-1.3/src/render/opengl/SDL_shaders_gl.h new file mode 100644 index 000000000..eb26cf53c --- /dev/null +++ b/project/jni/sdl-1.3/src/render/opengl/SDL_shaders_gl.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +/* OpenGL shader implementation */ + +typedef enum { + SHADER_NONE, + SHADER_SOLID, + SHADER_RGB, + SHADER_YV12, + NUM_SHADERS +} GL_Shader; + +typedef struct GL_ShaderContext GL_ShaderContext; + +extern GL_ShaderContext * GL_CreateShaderContext(); +extern void GL_SelectShader(GL_ShaderContext *ctx, GL_Shader shader); +extern void GL_DestroyShaderContext(GL_ShaderContext *ctx); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/opengles/SDL_render_gles.c b/project/jni/sdl-1.3/src/render/opengles/SDL_render_gles.c new file mode 100644 index 000000000..a6a313228 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/opengles/SDL_render_gles.c @@ -0,0 +1,887 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED + +#include "SDL_hints.h" +#include "SDL_opengles.h" +#include "../SDL_sysrender.h" +#include + +#if defined(SDL_VIDEO_DRIVER_PANDORA) + +/* Empty function stub to get OpenGL ES 1.x support without */ +/* OpenGL ES extension GL_OES_draw_texture supported */ +GL_API void GL_APIENTRY +glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) +{ + return; +} + +#endif /* PANDORA */ + +/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */ + +static const float inv255f = 1.0f / 255.0f; + +static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags); +static void GLES_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void GLES_UnlockTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static int GLES_UpdateViewport(SDL_Renderer * renderer); +static int GLES_RenderClear(SDL_Renderer * renderer); +static int GLES_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, int count); +static int GLES_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, int count); +static int GLES_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, int count); +static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, + const SDL_Rect * dstrect); +static int GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); +static void GLES_RenderPresent(SDL_Renderer * renderer); +static void GLES_DestroyTexture(SDL_Renderer * renderer, + SDL_Texture * texture); +static void GLES_DestroyRenderer(SDL_Renderer * renderer); + + +SDL_RenderDriver GLES_RenderDriver = { + GLES_CreateRenderer, + { + "opengles", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), + 5, + {SDL_PIXELFORMAT_ABGR8888,SDL_PIXELFORMAT_RGB565,SDL_PIXELFORMAT_RGBA5551,SDL_PIXELFORMAT_RGBA4444,SDL_PIXELFORMAT_RGB24}, + 0, + 0} +}; + +typedef struct +{ + SDL_GLContext context; + struct { + Uint32 color; + int blendMode; + SDL_bool tex_coords; + } current; + + SDL_bool useDrawTexture; + SDL_bool GL_OES_draw_texture_supported; +} GLES_RenderData; + +typedef struct +{ + GLuint texture; + GLenum type; + GLfloat texw; + GLfloat texh; + GLenum format; + GLenum formattype; + void *pixels; + int pitch; +} GLES_TextureData; + +static void +GLES_SetError(const char *prefix, GLenum result) +{ + const char *error; + + switch (result) { + case GL_NO_ERROR: + error = "GL_NO_ERROR"; + break; + case GL_INVALID_ENUM: + error = "GL_INVALID_ENUM"; + break; + case GL_INVALID_VALUE: + error = "GL_INVALID_VALUE"; + break; + case GL_INVALID_OPERATION: + error = "GL_INVALID_OPERATION"; + break; + case GL_STACK_OVERFLOW: + error = "GL_STACK_OVERFLOW"; + break; + case GL_STACK_UNDERFLOW: + error = "GL_STACK_UNDERFLOW"; + break; + case GL_OUT_OF_MEMORY: + error = "GL_OUT_OF_MEMORY"; + break; + default: + error = "UNKNOWN"; + break; + } + SDL_SetError("%s: %s", prefix, error); +} + +static SDL_GLContext SDL_CurrentContext = NULL; + +static int +GLES_ActivateRenderer(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + if (SDL_GL_MakeCurrent(renderer->window, data->context) < 0) { + return -1; + } + SDL_CurrentContext = data->context; + + GLES_UpdateViewport(renderer); + } + return 0; +} + +/* This is called if we need to invalidate all of the SDL OpenGL state */ +extern void +GLES_ResetState(SDL_Renderer *renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext == data->context) { + GLES_UpdateViewport(renderer); + } else { + GLES_ActivateRenderer(renderer); + } + + data->current.color = 0; + data->current.blendMode = -1; + data->current.tex_coords = SDL_FALSE; + + glDisable(GL_DEPTH_TEST); + glDisable(GL_CULL_FACE); + + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); + + glEnableClientState(GL_VERTEX_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); +} + +SDL_Renderer * +GLES_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_Renderer *renderer; + GLES_RenderData *data; + GLint value; + + __android_log_print(ANDROID_LOG_INFO, "SDL", "GLES_CreateRenderer(): creating GLES 1.x renderer"); + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + GLES_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + + renderer->WindowEvent = GLES_WindowEvent; + renderer->CreateTexture = GLES_CreateTexture; + renderer->UpdateTexture = GLES_UpdateTexture; + renderer->LockTexture = GLES_LockTexture; + renderer->UnlockTexture = GLES_UnlockTexture; + renderer->UpdateViewport = GLES_UpdateViewport; + renderer->RenderClear = GLES_RenderClear; + renderer->RenderDrawPoints = GLES_RenderDrawPoints; + renderer->RenderDrawLines = GLES_RenderDrawLines; + renderer->RenderFillRects = GLES_RenderFillRects; + renderer->RenderCopy = GLES_RenderCopy; + renderer->RenderReadPixels = GLES_RenderReadPixels; + renderer->RenderPresent = GLES_RenderPresent; + renderer->DestroyTexture = GLES_DestroyTexture; + renderer->DestroyRenderer = GLES_DestroyRenderer; + renderer->info = GLES_RenderDriver.info; + renderer->info.flags = SDL_RENDERER_ACCELERATED; + renderer->driverdata = data; + + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 1); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); + + data->context = SDL_GL_CreateContext(window); + if (!data->context) { + GLES_DestroyRenderer(renderer); + return NULL; + } + if (SDL_GL_MakeCurrent(window, data->context) < 0) { + GLES_DestroyRenderer(renderer); + return NULL; + } + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + if (SDL_GL_GetSwapInterval() > 0) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + +#if SDL_VIDEO_DRIVER_PANDORA + data->GL_OES_draw_texture_supported = SDL_FALSE; + data->useDrawTexture = SDL_FALSE; +#else + if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) { + data->GL_OES_draw_texture_supported = SDL_TRUE; + data->useDrawTexture = SDL_TRUE; + } else { + data->GL_OES_draw_texture_supported = SDL_FALSE; + data->useDrawTexture = SDL_FALSE; + } +#endif + + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_height = value; + + /* Set up parameters for rendering */ + GLES_ResetState(renderer); + + return renderer; +} + +static void +GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ +__android_log_print(ANDROID_LOG_INFO, "SDL", "GLES_WindowEvent() called"); +#ifndef ANDROID + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + /* Rebind the context to the window area and update matrices */ + SDL_CurrentContext = NULL; + } +#endif + if (event->event == SDL_WINDOWEVENT_MINIMIZED) { + /* According to Apple documentation, we need to finish drawing NOW! */ + glFinish(); + } +} + +static __inline__ int +power_of_2(int input) +{ + int value = 1; + + while (value < input) { + value <<= 1; + } + return value; +} + +static GLenum +GetScaleQuality(void) +{ + const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); + + if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { + return GL_NEAREST; + } else { + return GL_LINEAR; + } +} + +static int +GLES_CreateTextureInternal(SDL_Renderer * renderer, SDL_Texture * texture, GLES_TextureData *data) +{ + GLint internalFormat; + GLenum format, type; + int texture_w, texture_h; + GLenum scaleMode; + GLenum result; + + GLES_ActivateRenderer(renderer); + + switch (texture->format) { + case SDL_PIXELFORMAT_ABGR8888: + internalFormat = GL_RGBA; + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + break; + case SDL_PIXELFORMAT_RGB565: + internalFormat = GL_RGB; + format = GL_RGB; + type = GL_UNSIGNED_SHORT_5_6_5; + break; + case SDL_PIXELFORMAT_RGBA5551: + internalFormat = GL_RGBA; + format = GL_RGBA; + type = GL_UNSIGNED_SHORT_5_5_5_1; + break; + case SDL_PIXELFORMAT_RGBA4444: + internalFormat = GL_RGBA; + format = GL_RGBA; + type = GL_UNSIGNED_SHORT_4_4_4_4; + break; + case SDL_PIXELFORMAT_RGB24: + internalFormat = GL_RGB; + format = GL_RGB; + type = GL_UNSIGNED_BYTE; + break; + default: + SDL_SetError("Texture format not supported"); + return -1; + } + + if(data == NULL) { + data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_OutOfMemory(); + return -1; + } + + if (texture->access == SDL_TEXTUREACCESS_STREAMING) { + data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + data->pixels = SDL_calloc(1, texture->h * data->pitch); + if (!data->pixels) { + SDL_OutOfMemory(); + SDL_free(data); + return -1; + } + } + } + + texture->driverdata = data; + + glGetError(); + glEnable(GL_TEXTURE_2D); + glGenTextures(1, &data->texture); + + data->type = GL_TEXTURE_2D; + /* no NPOV textures allowed in OpenGL ES (yet) */ + texture_w = power_of_2(texture->w); + texture_h = power_of_2(texture->h); + data->texw = (GLfloat) texture->w / texture_w; + data->texh = (GLfloat) texture->h / texture_h; + + data->format = format; + data->formattype = type; + scaleMode = GetScaleQuality(); + glBindTexture(data->type, data->texture); + glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, scaleMode); + glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, scaleMode); + glTexParameteri(data->type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(data->type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + + glTexImage2D(data->type, 0, internalFormat, texture_w, + texture_h, 0, format, type, NULL); + glDisable(GL_TEXTURE_2D); + + result = glGetError(); + if (result != GL_NO_ERROR) { + GLES_SetError("glTexImage2D()", result); + return -1; + } + return 0; +} + +static int +GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + return GLES_CreateTextureInternal(renderer, texture, NULL); +} + +extern int +GLES_ReinitTextureAndroid(SDL_Renderer * renderer, SDL_Texture * texture, void * data) +{ + return GLES_CreateTextureInternal(renderer, texture, (GLES_TextureData *)data); +} + +static int +GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + Uint8 *blob = NULL; + Uint8 *src; + int srcPitch; + int y; + + GLES_ActivateRenderer(renderer); + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) + return 0; + + /* Reformat the texture data into a tightly packed array */ + srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format); + src = (Uint8 *)pixels; + if (pitch != srcPitch) + { + blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); + if (!blob) + { + SDL_OutOfMemory(); + return -1; + } + src = blob; + for (y = 0; y < rect->h; ++y) + { + SDL_memcpy(src, pixels, srcPitch); + src += srcPitch; + pixels = (Uint8 *)pixels + pitch; + } + src = blob; + } + + /* Create a texture subimage with the supplied data */ + glGetError(); + glEnable(data->type); + glBindTexture(data->type, data->texture); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexSubImage2D(data->type, + 0, + rect->x, + rect->y, + rect->w, + rect->h, + data->format, + data->formattype, + src); + if (blob) { + SDL_free(blob); + } + + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Failed to update texture"); + return -1; + } + return 0; +} + +static int +GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + + *pixels = + (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + + rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = data->pitch; + return 0; +} + +static void +GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + SDL_Rect rect; + + /* We do whole texture updates, at least for now */ + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + GLES_UpdateTexture(renderer, texture, &rect, data->pixels, data->pitch); +} + +static int +GLES_UpdateViewport(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (SDL_CurrentContext != data->context) { + /* We'll update the viewport after we rebind the context */ + return 0; + } + + glViewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrthof((GLfloat) 0, + (GLfloat) renderer->viewport.w, + (GLfloat) renderer->viewport.h, + (GLfloat) 0, 0.0, 1.0); + return 0; +} + +static void +GLES_SetColor(GLES_RenderData * data, Uint8 r, Uint8 g, Uint8 b, Uint8 a) +{ + Uint32 color = ((a << 24) | (r << 16) | (g << 8) | b); + + if (color != data->current.color) { + glColor4f((GLfloat) r * inv255f, + (GLfloat) g * inv255f, + (GLfloat) b * inv255f, + (GLfloat) a * inv255f); + data->current.color = color; + } +} + +static void +GLES_SetBlendMode(GLES_RenderData * data, int blendMode) +{ + if (blendMode != data->current.blendMode) { + switch (blendMode) { + case SDL_BLENDMODE_NONE: + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); + glDisable(GL_BLEND); + break; + case SDL_BLENDMODE_BLEND: + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + case SDL_BLENDMODE_ADD: + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + break; + case SDL_BLENDMODE_MOD: + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + glEnable(GL_BLEND); + glBlendFunc(GL_ZERO, GL_SRC_COLOR); + break; + } + data->current.blendMode = blendMode; + } +} + +static void +GLES_SetTexCoords(GLES_RenderData * data, SDL_bool enabled) +{ + if (enabled != data->current.tex_coords) { + if (enabled) { + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + } else { + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + } + data->current.tex_coords = enabled; + } +} + +static void +GLES_SetDrawingState(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + GLES_ActivateRenderer(renderer); + + GLES_SetColor(data, (GLfloat) renderer->r, + (GLfloat) renderer->g, + (GLfloat) renderer->b, + (GLfloat) renderer->a); + + GLES_SetBlendMode(data, renderer->blendMode); + + GLES_SetTexCoords(data, SDL_FALSE); +} + +static int +GLES_RenderClear(SDL_Renderer * renderer) +{ + GLES_ActivateRenderer(renderer); + + glClearColor((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + glClear(GL_COLOR_BUFFER_BIT); + + return 0; +} + +static int +GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, + int count) +{ + int i; + GLshort *vertices; + + GLES_SetDrawingState(renderer); + + vertices = SDL_stack_alloc(GLshort, count*2); + for (i = 0; i < count; ++i) { + vertices[2*i+0] = (GLshort)points[i].x; + vertices[2*i+1] = (GLshort)points[i].y; + } + glVertexPointer(2, GL_SHORT, 0, vertices); + glDrawArrays(GL_POINTS, 0, count); + SDL_stack_free(vertices); + + return 0; +} + +static int +GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, + int count) +{ + int i; + GLshort *vertices; + + GLES_SetDrawingState(renderer); + + vertices = SDL_stack_alloc(GLshort, count*2); + for (i = 0; i < count; ++i) { + vertices[2*i+0] = (GLshort)points[i].x; + vertices[2*i+1] = (GLshort)points[i].y; + } + glVertexPointer(2, GL_SHORT, 0, vertices); + if (count > 2 && + points[0].x == points[count-1].x && points[0].y == points[count-1].y) { + /* GL_LINE_LOOP takes care of the final segment */ + --count; + glDrawArrays(GL_LINE_LOOP, 0, count); + } else { + glDrawArrays(GL_LINE_STRIP, 0, count); + /* We need to close the endpoint of the line */ + glDrawArrays(GL_POINTS, count-1, 1); + } + SDL_stack_free(vertices); + + return 0; +} + +static int +GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, + int count) +{ + int i; + + GLES_SetDrawingState(renderer); + + for (i = 0; i < count; ++i) { + const SDL_Rect *rect = &rects[i]; + GLshort minx = rect->x; + GLshort maxx = rect->x + rect->w; + GLshort miny = rect->y; + GLshort maxy = rect->y + rect->h; + GLshort vertices[8]; + vertices[0] = minx; + vertices[1] = miny; + vertices[2] = maxx; + vertices[3] = miny; + vertices[4] = minx; + vertices[5] = maxy; + vertices[6] = maxx; + vertices[7] = maxy; + + glVertexPointer(2, GL_SHORT, 0, vertices); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + + return 0; +} + +static int +GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect) +{ + + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; + int minx, miny, maxx, maxy; + GLfloat minu, maxu, minv, maxv; + + GLES_ActivateRenderer(renderer); + + glEnable(GL_TEXTURE_2D); + + glBindTexture(texturedata->type, texturedata->texture); + + if (texture->modMode) { + GLES_SetColor(data, texture->r, texture->g, texture->b, texture->a); + } else { + GLES_SetColor(data, 255, 255, 255, 255); + } + + GLES_SetBlendMode(data, texture->blendMode); + + GLES_SetTexCoords(data, SDL_TRUE); + + if (data->GL_OES_draw_texture_supported && data->useDrawTexture) { + /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */ + GLint cropRect[4]; + int w, h; + SDL_Window *window = renderer->window; + + SDL_GetWindowSize(window, &w, &h); + cropRect[0] = srcrect->x; + cropRect[1] = srcrect->y + srcrect->h; + cropRect[2] = srcrect->w; + cropRect[3] = -srcrect->h; + glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, + cropRect); + glDrawTexiOES(renderer->viewport.x + dstrect->x, + h - (renderer->viewport.y + dstrect->y) - dstrect->h, 0, + dstrect->w, dstrect->h); + } else { + + minx = dstrect->x; + miny = dstrect->y; + maxx = dstrect->x + dstrect->w; + maxy = dstrect->y + dstrect->h; + + minu = (GLfloat) srcrect->x / texture->w; + minu *= texturedata->texw; + maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; + maxu *= texturedata->texw; + minv = (GLfloat) srcrect->y / texture->h; + minv *= texturedata->texh; + maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; + maxv *= texturedata->texh; + + GLshort vertices[8]; + GLfloat texCoords[8]; + + vertices[0] = minx; + vertices[1] = miny; + vertices[2] = maxx; + vertices[3] = miny; + vertices[4] = minx; + vertices[5] = maxy; + vertices[6] = maxx; + vertices[7] = maxy; + + texCoords[0] = minu; + texCoords[1] = minv; + texCoords[2] = maxu; + texCoords[3] = minv; + texCoords[4] = minu; + texCoords[5] = maxv; + texCoords[6] = maxu; + texCoords[7] = maxv; + + glVertexPointer(2, GL_SHORT, 0, vertices); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + glDisable(GL_TEXTURE_2D); + + return 0; +} + +static int +GLES_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ + SDL_Window *window = renderer->window; + Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888; + void *temp_pixels; + int temp_pitch; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + GLES_ActivateRenderer(renderer); + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + SDL_OutOfMemory(); + return -1; + } + + SDL_GetWindowSize(window, &w, &h); + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, + GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); + + /* Flip the rows to be top-down */ + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_stack_alloc(Uint8, length); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_stack_free(tmp); + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + +static void +GLES_RenderPresent(SDL_Renderer * renderer) +{ + GLES_ActivateRenderer(renderer); + + SDL_GL_SwapWindow(renderer->window); +} + +static void +GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; + + GLES_ActivateRenderer(renderer); + + if (!data) { + return; + } + if (data->texture) { + glDeleteTextures(1, &data->texture); + } + if (data->pixels) { + SDL_free(data->pixels); + } + SDL_free(data); + texture->driverdata = NULL; +} + +static void +GLES_DestroyRenderer(SDL_Renderer * renderer) +{ + GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; + + if (data) { + if (data->context) { + SDL_GL_DeleteContext(data->context); + } + SDL_free(data); + } + SDL_free(renderer); +} + +#endif /* SDL_VIDEO_RENDER_OGL_ES && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/opengles2/SDL_render_gles2.c b/project/jni/sdl-1.3/src/render/opengles2/SDL_render_gles2.c new file mode 100644 index 000000000..0122a298d --- /dev/null +++ b/project/jni/sdl-1.3/src/render/opengles2/SDL_render_gles2.c @@ -0,0 +1,1262 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED + +#include "SDL_hints.h" +#include "SDL_opengles2.h" +#include "../SDL_sysrender.h" +#include "SDL_shaders_gles2.h" + +/************************************************************************************************* + * Bootstrap data * + *************************************************************************************************/ + +static SDL_Renderer *GLES2_CreateRenderer(SDL_Window *window, Uint32 flags); + +SDL_RenderDriver GLES2_RenderDriver = { + GLES2_CreateRenderer, + { + "opengles2", + (SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC), + 1, + {SDL_PIXELFORMAT_ABGR8888}, + 0, + 0 + } +}; + +/************************************************************************************************* + * Context structures * + *************************************************************************************************/ + +typedef struct GLES2_TextureData +{ + GLenum texture; + GLenum texture_type; + GLenum pixel_format; + GLenum pixel_type; + void *pixel_data; + size_t pitch; +} GLES2_TextureData; + +typedef struct GLES2_ShaderCacheEntry +{ + GLuint id; + GLES2_ShaderType type; + const GLES2_ShaderInstance *instance; + int references; + struct GLES2_ShaderCacheEntry *prev; + struct GLES2_ShaderCacheEntry *next; +} GLES2_ShaderCacheEntry; + +typedef struct GLES2_ShaderCache +{ + int count; + GLES2_ShaderCacheEntry *head; +} GLES2_ShaderCache; + +typedef struct GLES2_ProgramCacheEntry +{ + GLuint id; + SDL_BlendMode blend_mode; + GLES2_ShaderCacheEntry *vertex_shader; + GLES2_ShaderCacheEntry *fragment_shader; + GLuint uniform_locations[16]; + struct GLES2_ProgramCacheEntry *prev; + struct GLES2_ProgramCacheEntry *next; +} GLES2_ProgramCacheEntry; + +typedef struct GLES2_ProgramCache +{ + int count; + GLES2_ProgramCacheEntry *head; + GLES2_ProgramCacheEntry *tail; +} GLES2_ProgramCache; + +typedef enum +{ + GLES2_ATTRIBUTE_POSITION = 0, + GLES2_ATTRIBUTE_TEXCOORD = 1 +} GLES2_Attribute; + +typedef enum +{ + GLES2_UNIFORM_PROJECTION, + GLES2_UNIFORM_TEXTURE, + GLES2_UNIFORM_MODULATION, + GLES2_UNIFORM_COLOR, + GLES2_UNIFORM_COLORTABLE +} GLES2_Uniform; + +typedef enum +{ + GLES2_IMAGESOURCE_SOLID, + GLES2_IMAGESOURCE_TEXTURE +} GLES2_ImageSource; + +typedef struct GLES2_DriverContext +{ + SDL_GLContext *context; + struct { + int blendMode; + SDL_bool tex_coords; + } current; + + int shader_format_count; + GLenum *shader_formats; + GLES2_ShaderCache shader_cache; + GLES2_ProgramCache program_cache; + GLES2_ProgramCacheEntry *current_program; +} GLES2_DriverContext; + +#define GLES2_MAX_CACHED_PROGRAMS 8 + +/************************************************************************************************* + * Renderer state APIs * + *************************************************************************************************/ + +static int GLES2_ActivateRenderer(SDL_Renderer *renderer); +static void GLES2_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int GLES2_UpdateViewport(SDL_Renderer * renderer); +static void GLES2_DestroyRenderer(SDL_Renderer *renderer); + +static SDL_GLContext SDL_CurrentContext = NULL; + +static int +GLES2_ActivateRenderer(SDL_Renderer * renderer) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + + if (SDL_CurrentContext != rdata->context) { + /* Null out the current program to ensure we set it again */ + rdata->current_program = NULL; + + if (SDL_GL_MakeCurrent(renderer->window, rdata->context) < 0) { + return -1; + } + SDL_CurrentContext = rdata->context; + + GLES2_UpdateViewport(renderer); + } + return 0; +} + +static void +GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + /* Rebind the context to the window area */ + SDL_CurrentContext = NULL; + } + + if (event->event == SDL_WINDOWEVENT_MINIMIZED) { + /* According to Apple documentation, we need to finish drawing NOW! */ + glFinish(); + } +} + +static int +GLES2_UpdateViewport(SDL_Renderer * renderer) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + + if (SDL_CurrentContext != rdata->context) { + /* We'll update the viewport after we rebind the context */ + return 0; + } + + glViewport(renderer->viewport.x, renderer->viewport.y, + renderer->viewport.w, renderer->viewport.h); + return 0; +} + +static void +GLES2_DestroyRenderer(SDL_Renderer *renderer) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + + /* Deallocate everything */ + if (rdata) { + GLES2_ActivateRenderer(renderer); + + { + GLES2_ShaderCacheEntry *entry; + GLES2_ShaderCacheEntry *next; + entry = rdata->shader_cache.head; + while (entry) + { + glDeleteShader(entry->id); + next = entry->next; + SDL_free(entry); + entry = next; + } + } + { + GLES2_ProgramCacheEntry *entry; + GLES2_ProgramCacheEntry *next; + entry = rdata->program_cache.head; + while (entry) { + glDeleteProgram(entry->id); + next = entry->next; + SDL_free(entry); + entry = next; + } + } + if (rdata->context) { + SDL_GL_DeleteContext(rdata->context); + } + if (rdata->shader_formats) { + SDL_free(rdata->shader_formats); + } + SDL_free(rdata); + } + SDL_free(renderer); +} + +/************************************************************************************************* + * Texture APIs * + *************************************************************************************************/ + +static int GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture); +static void GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture); +static int GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + void **pixels, int *pitch); +static void GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture); +static int GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch); + +static GLenum +GetScaleQuality(void) +{ + const char *hint = SDL_GetHint(SDL_HINT_RENDER_SCALE_QUALITY); + + if (!hint || *hint == '0' || SDL_strcasecmp(hint, "nearest") == 0) { + return GL_NEAREST; + } else { + return GL_LINEAR; + } +} + +static int +GLES2_CreateTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_TextureData *tdata; + GLenum format; + GLenum type; + GLenum scaleMode; + + GLES2_ActivateRenderer(renderer); + + /* Determine the corresponding GLES texture format params */ + switch (texture->format) + { + case SDL_PIXELFORMAT_ABGR8888: + format = GL_RGBA; + type = GL_UNSIGNED_BYTE; + break; + default: + SDL_SetError("Texture format not supported"); + return -1; + } + + /* Allocate a texture struct */ + tdata = (GLES2_TextureData *)SDL_calloc(1, sizeof(GLES2_TextureData)); + if (!tdata) + { + SDL_OutOfMemory(); + return -1; + } + tdata->texture = 0; + tdata->texture_type = GL_TEXTURE_2D; + tdata->pixel_format = format; + tdata->pixel_type = type; + scaleMode = GetScaleQuality(); + + /* Allocate a blob for image data */ + if (texture->access == SDL_TEXTUREACCESS_STREAMING) + { + tdata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); + tdata->pixel_data = SDL_calloc(1, tdata->pitch * texture->h); + if (!tdata->pixel_data) + { + SDL_OutOfMemory(); + SDL_free(tdata); + return -1; + } + } + + /* Allocate the texture */ + glGetError(); + glGenTextures(1, &tdata->texture); + glActiveTexture(GL_TEXTURE0); + glBindTexture(tdata->texture_type, tdata->texture); + glTexParameteri(tdata->texture_type, GL_TEXTURE_MIN_FILTER, scaleMode); + glTexParameteri(tdata->texture_type, GL_TEXTURE_MAG_FILTER, scaleMode); + glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(tdata->texture_type, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexImage2D(tdata->texture_type, 0, format, texture->w, texture->h, 0, format, type, NULL); + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Texture creation failed"); + glDeleteTextures(1, &tdata->texture); + SDL_free(tdata); + return -1; + } + texture->driverdata = tdata; + return 0; +} + +static void +GLES2_DestroyTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + GLES2_ActivateRenderer(renderer); + + /* Destroy the texture */ + if (tdata) + { + glDeleteTextures(1, &tdata->texture); + SDL_free(tdata->pixel_data); + SDL_free(tdata); + texture->driverdata = NULL; + } +} + +static int +GLES2_LockTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + void **pixels, int *pitch) +{ + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + + /* Retrieve the buffer/pitch for the specified region */ + *pixels = (Uint8 *)tdata->pixel_data + + (tdata->pitch * rect->y) + + (rect->x * SDL_BYTESPERPIXEL(texture->format)); + *pitch = tdata->pitch; + + return 0; +} + +static void +GLES2_UnlockTexture(SDL_Renderer *renderer, SDL_Texture *texture) +{ + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + SDL_Rect rect; + + /* We do whole texture updates, at least for now */ + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + GLES2_UpdateTexture(renderer, texture, &rect, tdata->pixel_data, tdata->pitch); +} + +static int +GLES2_UpdateTexture(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *rect, + const void *pixels, int pitch) +{ + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + Uint8 *blob = NULL; + Uint8 *src; + int srcPitch; + int y; + + GLES2_ActivateRenderer(renderer); + + /* Bail out if we're supposed to update an empty rectangle */ + if (rect->w <= 0 || rect->h <= 0) + return 0; + + /* Reformat the texture data into a tightly packed array */ + srcPitch = rect->w * SDL_BYTESPERPIXEL(texture->format); + src = (Uint8 *)pixels; + if (pitch != srcPitch) + { + blob = (Uint8 *)SDL_malloc(srcPitch * rect->h); + if (!blob) + { + SDL_OutOfMemory(); + return -1; + } + src = blob; + for (y = 0; y < rect->h; ++y) + { + SDL_memcpy(src, pixels, srcPitch); + src += srcPitch; + pixels = (Uint8 *)pixels + pitch; + } + src = blob; + } + + /* Create a texture subimage with the supplied data */ + glGetError(); + glActiveTexture(GL_TEXTURE0); + glBindTexture(tdata->texture_type, tdata->texture); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glTexSubImage2D(tdata->texture_type, + 0, + rect->x, + rect->y, + rect->w, + rect->h, + tdata->pixel_format, + tdata->pixel_type, + src); + if (blob) { + SDL_free(blob); + } + + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Failed to update texture"); + return -1; + } + return 0; +} + +/************************************************************************************************* + * Shader management functions * + *************************************************************************************************/ + +static GLES2_ShaderCacheEntry *GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, + SDL_BlendMode blendMode); +static void GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry); +static GLES2_ProgramCacheEntry *GLES2_CacheProgram(SDL_Renderer *renderer, + GLES2_ShaderCacheEntry *vertex, + GLES2_ShaderCacheEntry *fragment, + SDL_BlendMode blendMode); +static int GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, + SDL_BlendMode blendMode); +static int GLES2_SetOrthographicProjection(SDL_Renderer *renderer); + +static GLES2_ProgramCacheEntry * +GLES2_CacheProgram(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *vertex, + GLES2_ShaderCacheEntry *fragment, SDL_BlendMode blendMode) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_ProgramCacheEntry *entry; + GLES2_ShaderCacheEntry *shaderEntry; + GLint linkSuccessful; + + /* Check if we've already cached this program */ + entry = rdata->program_cache.head; + while (entry) + { + if (entry->vertex_shader == vertex && entry->fragment_shader == fragment) + break; + entry = entry->next; + } + if (entry) + { + if (rdata->program_cache.head != entry) + { + if (entry->next) + entry->next->prev = entry->prev; + if (entry->prev) + entry->prev->next = entry->next; + entry->prev = NULL; + entry->next = rdata->program_cache.head; + rdata->program_cache.head->prev = entry; + rdata->program_cache.head = entry; + } + return entry; + } + + /* Create a program cache entry */ + entry = (GLES2_ProgramCacheEntry *)SDL_calloc(1, sizeof(GLES2_ProgramCacheEntry)); + if (!entry) + { + SDL_OutOfMemory(); + return NULL; + } + entry->vertex_shader = vertex; + entry->fragment_shader = fragment; + entry->blend_mode = blendMode; + + /* Create the program and link it */ + glGetError(); + entry->id = glCreateProgram(); + glAttachShader(entry->id, vertex->id); + glAttachShader(entry->id, fragment->id); + glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_POSITION, "a_position"); + glBindAttribLocation(entry->id, GLES2_ATTRIBUTE_TEXCOORD, "a_texCoord"); + glLinkProgram(entry->id); + glGetProgramiv(entry->id, GL_LINK_STATUS, &linkSuccessful); + if (glGetError() != GL_NO_ERROR || !linkSuccessful) + { + SDL_SetError("Failed to link shader program"); + glDeleteProgram(entry->id); + SDL_free(entry); + return NULL; + } + + /* Predetermine locations of uniform variables */ + entry->uniform_locations[GLES2_UNIFORM_PROJECTION] = + glGetUniformLocation(entry->id, "u_projection"); + entry->uniform_locations[GLES2_UNIFORM_TEXTURE] = + glGetUniformLocation(entry->id, "u_texture"); + entry->uniform_locations[GLES2_UNIFORM_MODULATION] = + glGetUniformLocation(entry->id, "u_modulation"); + entry->uniform_locations[GLES2_UNIFORM_COLOR] = + glGetUniformLocation(entry->id, "u_color"); + entry->uniform_locations[GLES2_UNIFORM_COLORTABLE] = + glGetUniformLocation(entry->id, "u_colorTable"); + + /* Cache the linked program */ + if (rdata->program_cache.head) + { + entry->next = rdata->program_cache.head; + rdata->program_cache.head->prev = entry; + } + else + { + rdata->program_cache.tail = entry; + } + rdata->program_cache.head = entry; + ++rdata->program_cache.count; + + /* Increment the refcount of the shaders we're using */ + ++vertex->references; + ++fragment->references; + + /* Evict the last entry from the cache if we exceed the limit */ + if (rdata->program_cache.count > GLES2_MAX_CACHED_PROGRAMS) + { + shaderEntry = rdata->program_cache.tail->vertex_shader; + if (--shaderEntry->references <= 0) + GLES2_EvictShader(renderer, shaderEntry); + shaderEntry = rdata->program_cache.tail->fragment_shader; + if (--shaderEntry->references <= 0) + GLES2_EvictShader(renderer, shaderEntry); + glDeleteProgram(rdata->program_cache.tail->id); + rdata->program_cache.tail = rdata->program_cache.tail->prev; + SDL_free(rdata->program_cache.tail->next); + rdata->program_cache.tail->next = NULL; + --rdata->program_cache.count; + } + return entry; +} + +static GLES2_ShaderCacheEntry * +GLES2_CacheShader(SDL_Renderer *renderer, GLES2_ShaderType type, SDL_BlendMode blendMode) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + const GLES2_Shader *shader; + const GLES2_ShaderInstance *instance = NULL; + GLES2_ShaderCacheEntry *entry = NULL; + GLint compileSuccessful = GL_FALSE; + int i, j; + + /* Find the corresponding shader */ + shader = GLES2_GetShader(type, blendMode); + if (!shader) + { + SDL_SetError("No shader matching the requested characteristics was found"); + return NULL; + } + + /* Find a matching shader instance that's supported on this hardware */ + for (i = 0; i < shader->instance_count && !instance; ++i) + { + for (j = 0; j < rdata->shader_format_count && !instance; ++j) + { + if (!shader->instances) + continue; + if (!shader->instances[i]) + continue; + if (shader->instances[i]->format != rdata->shader_formats[j]) + continue; + instance = shader->instances[i]; + } + } + if (!instance) + { + SDL_SetError("The specified shader cannot be loaded on the current platform"); + return NULL; + } + + /* Check if we've already cached this shader */ + entry = rdata->shader_cache.head; + while (entry) + { + if (entry->instance == instance) + break; + entry = entry->next; + } + if (entry) + return entry; + + /* Create a shader cache entry */ + entry = (GLES2_ShaderCacheEntry *)SDL_calloc(1, sizeof(GLES2_ShaderCacheEntry)); + if (!entry) + { + SDL_OutOfMemory(); + return NULL; + } + entry->type = type; + entry->instance = instance; + + /* Compile or load the selected shader instance */ + glGetError(); + entry->id = glCreateShader(instance->type); + if (instance->format == (GLenum)-1) + { + glShaderSource(entry->id, 1, (const char **)&instance->data, NULL); + glCompileShader(entry->id); + glGetShaderiv(entry->id, GL_COMPILE_STATUS, &compileSuccessful); + } + else + { + glShaderBinary(1, &entry->id, instance->format, instance->data, instance->length); + compileSuccessful = GL_TRUE; + } + if (glGetError() != GL_NO_ERROR || !compileSuccessful) + { + char *info = NULL; + int length; + + glGetShaderiv(entry->id, GL_INFO_LOG_LENGTH, &length); + if (length > 0) { + info = SDL_stack_alloc(char, length); + if (info) { + glGetShaderInfoLog(entry->id, length, &length, info); + } + } + if (info) { + SDL_SetError("Failed to load the shader: %s", info); + SDL_stack_free(info); + } else { + SDL_SetError("Failed to load the shader"); + } + glDeleteShader(entry->id); + SDL_free(entry); + return NULL; + } + + /* Link the shader entry in at the front of the cache */ + if (rdata->shader_cache.head) + { + entry->next = rdata->shader_cache.head; + rdata->shader_cache.head->prev = entry; + } + rdata->shader_cache.head = entry; + ++rdata->shader_cache.count; + return entry; +} + +static void +GLES2_EvictShader(SDL_Renderer *renderer, GLES2_ShaderCacheEntry *entry) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + + /* Unlink the shader from the cache */ + if (entry->next) + entry->next->prev = entry->prev; + if (entry->prev) + entry->prev->next = entry->next; + if (rdata->shader_cache.head == entry) + rdata->shader_cache.head = entry->next; + --rdata->shader_cache.count; + + /* Deallocate the shader */ + glDeleteShader(entry->id); + SDL_free(entry); +} + +static int +GLES2_SelectProgram(SDL_Renderer *renderer, GLES2_ImageSource source, SDL_BlendMode blendMode) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_ShaderCacheEntry *vertex = NULL; + GLES2_ShaderCacheEntry *fragment = NULL; + GLES2_ShaderType vtype, ftype; + GLES2_ProgramCacheEntry *program; + + /* Select an appropriate shader pair for the specified modes */ + vtype = GLES2_SHADER_VERTEX_DEFAULT; + switch (source) + { + case GLES2_IMAGESOURCE_SOLID: + ftype = GLES2_SHADER_FRAGMENT_SOLID_SRC; + break; + case GLES2_IMAGESOURCE_TEXTURE: + ftype = GLES2_SHADER_FRAGMENT_TEXTURE_SRC; + break; + } + + /* Load the requested shaders */ + vertex = GLES2_CacheShader(renderer, vtype, blendMode); + if (!vertex) + goto fault; + fragment = GLES2_CacheShader(renderer, ftype, blendMode); + if (!fragment) + goto fault; + + /* Check if we need to change programs at all */ + if (rdata->current_program && + rdata->current_program->vertex_shader == vertex && + rdata->current_program->fragment_shader == fragment) + return 0; + + /* Generate a matching program */ + program = GLES2_CacheProgram(renderer, vertex, fragment, blendMode); + if (!program) + goto fault; + + /* Select that program in OpenGL */ + glGetError(); + glUseProgram(program->id); + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Failed to select program"); + goto fault; + } + + /* Set the current program */ + rdata->current_program = program; + + /* Activate an orthographic projection */ + if (GLES2_SetOrthographicProjection(renderer) < 0) + goto fault; + + /* Clean up and return */ + return 0; +fault: + if (vertex && vertex->references <= 0) + GLES2_EvictShader(renderer, vertex); + if (fragment && fragment->references <= 0) + GLES2_EvictShader(renderer, fragment); + rdata->current_program = NULL; + return -1; +} + +static int +GLES2_SetOrthographicProjection(SDL_Renderer *renderer) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLfloat projection[4][4]; + GLuint locProjection; + + /* Prepare an orthographic projection */ + projection[0][0] = 2.0f / renderer->viewport.w; + projection[0][1] = 0.0f; + projection[0][2] = 0.0f; + projection[0][3] = 0.0f; + projection[1][0] = 0.0f; + projection[1][1] = -2.0f / renderer->viewport.h; + projection[1][2] = 0.0f; + projection[1][3] = 0.0f; + projection[2][0] = 0.0f; + projection[2][1] = 0.0f; + projection[2][2] = 1.0f; + projection[2][3] = 0.0f; + projection[3][0] = -1.0f; + projection[3][1] = 1.0f; + projection[3][2] = 0.0f; + projection[3][3] = 1.0f; + + /* Set the projection matrix */ + locProjection = rdata->current_program->uniform_locations[GLES2_UNIFORM_PROJECTION]; + glGetError(); + glUniformMatrix4fv(locProjection, 1, GL_FALSE, (GLfloat *)projection); + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Failed to set orthographic projection"); + return -1; + } + return 0; +} + +/************************************************************************************************* + * Rendering functions * + *************************************************************************************************/ + +static const float inv255f = 1.0f / 255.0f; + +static int GLES2_RenderClear(SDL_Renderer *renderer); +static int GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count); +static int GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count); +static int GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count); +static int GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, + const SDL_Rect *dstrect); +static int GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch); +static void GLES2_RenderPresent(SDL_Renderer *renderer); + + +static int +GLES2_RenderClear(SDL_Renderer * renderer) +{ + GLES2_ActivateRenderer(renderer); + + glClearColor((GLfloat) renderer->r * inv255f, + (GLfloat) renderer->g * inv255f, + (GLfloat) renderer->b * inv255f, + (GLfloat) renderer->a * inv255f); + + glClear(GL_COLOR_BUFFER_BIT); + + return 0; +} + +static void +GLES2_SetBlendMode(GLES2_DriverContext *rdata, int blendMode) +{ + if (blendMode != rdata->current.blendMode) { + switch (blendMode) { + default: + case SDL_BLENDMODE_NONE: + glDisable(GL_BLEND); + break; + case SDL_BLENDMODE_BLEND: + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + break; + case SDL_BLENDMODE_ADD: + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + break; + case SDL_BLENDMODE_MOD: + glEnable(GL_BLEND); + glBlendFunc(GL_ZERO, GL_SRC_COLOR); + break; + } + rdata->current.blendMode = blendMode; + } +} + +static void +GLES2_SetTexCoords(GLES2_DriverContext * rdata, SDL_bool enabled) +{ + if (enabled != rdata->current.tex_coords) { + if (enabled) { + glEnableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + } else { + glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); + } + rdata->current.tex_coords = enabled; + } +} + +static int +GLES2_SetDrawingState(SDL_Renderer * renderer) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + int blendMode = renderer->blendMode; + GLuint locColor; + + glGetError(); + + GLES2_ActivateRenderer(renderer); + + GLES2_SetBlendMode(rdata, blendMode); + + GLES2_SetTexCoords(rdata, SDL_FALSE); + + /* Activate an appropriate shader and set the projection matrix */ + if (GLES2_SelectProgram(renderer, GLES2_IMAGESOURCE_SOLID, blendMode) < 0) + return -1; + + /* Select the color to draw with */ + locColor = rdata->current_program->uniform_locations[GLES2_UNIFORM_COLOR]; + glUniform4f(locColor, + renderer->r * inv255f, + renderer->g * inv255f, + renderer->b * inv255f, + renderer->a * inv255f); + return 0; +} + +static int +GLES2_RenderDrawPoints(SDL_Renderer *renderer, const SDL_Point *points, int count) +{ + GLfloat *vertices; + int idx; + + if (GLES2_SetDrawingState(renderer) < 0) { + return -1; + } + + /* Emit the specified vertices as points */ + vertices = SDL_stack_alloc(GLfloat, count * 2); + for (idx = 0; idx < count; ++idx) + { + GLfloat x = (GLfloat)points[idx].x + 0.5f; + GLfloat y = (GLfloat)points[idx].y + 0.5f; + + vertices[idx * 2] = x; + vertices[(idx * 2) + 1] = y; + } + glGetError(); + glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glDrawArrays(GL_POINTS, 0, count); + SDL_stack_free(vertices); + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Failed to render lines"); + return -1; + } + return 0; +} + +static int +GLES2_RenderDrawLines(SDL_Renderer *renderer, const SDL_Point *points, int count) +{ + GLfloat *vertices; + int idx; + + if (GLES2_SetDrawingState(renderer) < 0) { + return -1; + } + + /* Emit a line strip including the specified vertices */ + vertices = SDL_stack_alloc(GLfloat, count * 2); + for (idx = 0; idx < count; ++idx) + { + GLfloat x = (GLfloat)points[idx].x + 0.5f; + GLfloat y = (GLfloat)points[idx].y + 0.5f; + + vertices[idx * 2] = x; + vertices[(idx * 2) + 1] = y; + } + glGetError(); + glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glDrawArrays(GL_LINE_STRIP, 0, count); + + /* We need to close the endpoint of the line */ + if (count == 2 || + points[0].x != points[count-1].x || points[0].y != points[count-1].y) { + glDrawArrays(GL_POINTS, count-1, 1); + } + SDL_stack_free(vertices); + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Failed to render lines"); + return -1; + } + return 0; +} + +static int +GLES2_RenderFillRects(SDL_Renderer *renderer, const SDL_Rect *rects, int count) +{ + GLfloat vertices[8]; + int idx; + + if (GLES2_SetDrawingState(renderer) < 0) { + return -1; + } + + /* Emit a line loop for each rectangle */ + glGetError(); + for (idx = 0; idx < count; ++idx) { + const SDL_Rect *rect = &rects[idx]; + + GLfloat xMin = (GLfloat)rect->x; + GLfloat xMax = (GLfloat)(rect->x + rect->w); + GLfloat yMin = (GLfloat)rect->y; + GLfloat yMax = (GLfloat)(rect->y + rect->h); + + vertices[0] = xMin; + vertices[1] = yMin; + vertices[2] = xMax; + vertices[3] = yMin; + vertices[4] = xMin; + vertices[5] = yMax; + vertices[6] = xMax; + vertices[7] = yMax; + glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + } + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Failed to render lines"); + return -1; + } + return 0; +} + +static int +GLES2_RenderCopy(SDL_Renderer *renderer, SDL_Texture *texture, const SDL_Rect *srcrect, + const SDL_Rect *dstrect) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata; + GLES2_TextureData *tdata = (GLES2_TextureData *)texture->driverdata; + GLES2_ImageSource sourceType; + SDL_BlendMode blendMode; + GLfloat vertices[8]; + GLfloat texCoords[8]; + GLuint locTexture; + GLuint locModulation; + + GLES2_ActivateRenderer(renderer); + + /* Activate an appropriate shader and set the projection matrix */ + blendMode = texture->blendMode; + sourceType = GLES2_IMAGESOURCE_TEXTURE; + if (GLES2_SelectProgram(renderer, sourceType, blendMode) < 0) + return -1; + + /* Select the target texture */ + locTexture = rdata->current_program->uniform_locations[GLES2_UNIFORM_TEXTURE]; + glGetError(); + glActiveTexture(GL_TEXTURE0); + glBindTexture(tdata->texture_type, tdata->texture); + glUniform1i(locTexture, 0); + + /* Configure color modulation */ + locModulation = rdata->current_program->uniform_locations[GLES2_UNIFORM_MODULATION]; + glUniform4f(locModulation, + texture->r * inv255f, + texture->g * inv255f, + texture->b * inv255f, + texture->a * inv255f); + + /* Configure texture blending */ + GLES2_SetBlendMode(rdata, blendMode); + + GLES2_SetTexCoords(rdata, SDL_TRUE); + + /* Emit the textured quad */ + vertices[0] = (GLfloat)dstrect->x; + vertices[1] = (GLfloat)dstrect->y; + vertices[2] = (GLfloat)(dstrect->x + dstrect->w); + vertices[3] = (GLfloat)dstrect->y; + vertices[4] = (GLfloat)dstrect->x; + vertices[5] = (GLfloat)(dstrect->y + dstrect->h); + vertices[6] = (GLfloat)(dstrect->x + dstrect->w); + vertices[7] = (GLfloat)(dstrect->y + dstrect->h); + glVertexAttribPointer(GLES2_ATTRIBUTE_POSITION, 2, GL_FLOAT, GL_FALSE, 0, vertices); + texCoords[0] = srcrect->x / (GLfloat)texture->w; + texCoords[1] = srcrect->y / (GLfloat)texture->h; + texCoords[2] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; + texCoords[3] = srcrect->y / (GLfloat)texture->h; + texCoords[4] = srcrect->x / (GLfloat)texture->w; + texCoords[5] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; + texCoords[6] = (srcrect->x + srcrect->w) / (GLfloat)texture->w; + texCoords[7] = (srcrect->y + srcrect->h) / (GLfloat)texture->h; + glVertexAttribPointer(GLES2_ATTRIBUTE_TEXCOORD, 2, GL_FLOAT, GL_FALSE, 0, texCoords); + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); + if (glGetError() != GL_NO_ERROR) + { + SDL_SetError("Failed to render texture"); + return -1; + } + return 0; +} + +static int +GLES2_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 pixel_format, void * pixels, int pitch) +{ + SDL_Window *window = renderer->window; + Uint32 temp_format = SDL_PIXELFORMAT_ABGR8888; + void *temp_pixels; + int temp_pitch; + Uint8 *src, *dst, *tmp; + int w, h, length, rows; + int status; + + GLES2_ActivateRenderer(renderer); + + temp_pitch = rect->w * SDL_BYTESPERPIXEL(temp_format); + temp_pixels = SDL_malloc(rect->h * temp_pitch); + if (!temp_pixels) { + SDL_OutOfMemory(); + return -1; + } + + SDL_GetWindowSize(window, &w, &h); + + glPixelStorei(GL_PACK_ALIGNMENT, 1); + + glReadPixels(rect->x, (h-rect->y)-rect->h, rect->w, rect->h, + GL_RGBA, GL_UNSIGNED_BYTE, temp_pixels); + + /* Flip the rows to be top-down */ + length = rect->w * SDL_BYTESPERPIXEL(temp_format); + src = (Uint8*)temp_pixels + (rect->h-1)*temp_pitch; + dst = (Uint8*)temp_pixels; + tmp = SDL_stack_alloc(Uint8, length); + rows = rect->h / 2; + while (rows--) { + SDL_memcpy(tmp, dst, length); + SDL_memcpy(dst, src, length); + SDL_memcpy(src, tmp, length); + dst += temp_pitch; + src -= temp_pitch; + } + SDL_stack_free(tmp); + + status = SDL_ConvertPixels(rect->w, rect->h, + temp_format, temp_pixels, temp_pitch, + pixel_format, pixels, pitch); + SDL_free(temp_pixels); + + return status; +} + +static void +GLES2_RenderPresent(SDL_Renderer *renderer) +{ + GLES2_ActivateRenderer(renderer); + + /* Tell the video driver to swap buffers */ + SDL_GL_SwapWindow(renderer->window); +} + +/************************************************************************************************* + * Renderer instantiation * + *************************************************************************************************/ + +#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B + +static void +GLES2_ResetState(SDL_Renderer *renderer) +{ + GLES2_DriverContext *rdata = (GLES2_DriverContext *) renderer->driverdata; + + if (SDL_CurrentContext == rdata->context) { + GLES2_UpdateViewport(renderer); + } else { + GLES2_ActivateRenderer(renderer); + } + + rdata->current.blendMode = -1; + rdata->current.tex_coords = SDL_FALSE; + + glEnableVertexAttribArray(GLES2_ATTRIBUTE_POSITION); + glDisableVertexAttribArray(GLES2_ATTRIBUTE_TEXCOORD); +} + +static SDL_Renderer * +GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) +{ + SDL_Renderer *renderer; + GLES2_DriverContext *rdata; + GLint nFormats; +#ifndef ZUNE_HD + GLboolean hasCompiler; +#endif + + /* Create the renderer struct */ + renderer = (SDL_Renderer *)SDL_calloc(1, sizeof(SDL_Renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + rdata = (GLES2_DriverContext *)SDL_calloc(1, sizeof(GLES2_DriverContext)); + if (!rdata) { + GLES2_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + renderer->info = GLES2_RenderDriver.info; + renderer->info.flags = SDL_RENDERER_ACCELERATED; + renderer->driverdata = rdata; + + /* Create an OpenGL ES 2.0 context */ + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); + + rdata->context = SDL_GL_CreateContext(window); + if (!rdata->context) + { + GLES2_DestroyRenderer(renderer); + return NULL; + } + if (SDL_GL_MakeCurrent(window, rdata->context) < 0) { + GLES2_DestroyRenderer(renderer); + return NULL; + } + + if (flags & SDL_RENDERER_PRESENTVSYNC) { + SDL_GL_SetSwapInterval(1); + } else { + SDL_GL_SetSwapInterval(0); + } + if (SDL_GL_GetSwapInterval() > 0) { + renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; + } + + /* Determine supported shader formats */ + /* HACK: glGetInteger is broken on the Zune HD's compositor, so we just hardcode this */ + glGetError(); +#ifdef ZUNE_HD + nFormats = 1; +#else /* !ZUNE_HD */ + glGetIntegerv(GL_NUM_SHADER_BINARY_FORMATS, &nFormats); + glGetBooleanv(GL_SHADER_COMPILER, &hasCompiler); + if (hasCompiler) + ++nFormats; +#endif /* ZUNE_HD */ + rdata->shader_formats = (GLenum *)SDL_calloc(nFormats, sizeof(GLenum)); + if (!rdata->shader_formats) + { + GLES2_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + rdata->shader_format_count = nFormats; +#ifdef ZUNE_HD + rdata->shader_formats[0] = GL_NVIDIA_PLATFORM_BINARY_NV; +#else /* !ZUNE_HD */ + glGetIntegerv(GL_SHADER_BINARY_FORMATS, (GLint *)rdata->shader_formats); + if (glGetError() != GL_NO_ERROR) + { + GLES2_DestroyRenderer(renderer); + SDL_SetError("Failed to query supported shader formats"); + return NULL; + } + if (hasCompiler) + rdata->shader_formats[nFormats - 1] = (GLenum)-1; +#endif /* ZUNE_HD */ + + /* Populate the function pointers for the module */ + renderer->WindowEvent = &GLES2_WindowEvent; + renderer->CreateTexture = &GLES2_CreateTexture; + renderer->UpdateTexture = &GLES2_UpdateTexture; + renderer->LockTexture = &GLES2_LockTexture; + renderer->UnlockTexture = &GLES2_UnlockTexture; + renderer->UpdateViewport = &GLES2_UpdateViewport; + renderer->RenderClear = &GLES2_RenderClear; + renderer->RenderDrawPoints = &GLES2_RenderDrawPoints; + renderer->RenderDrawLines = &GLES2_RenderDrawLines; + renderer->RenderFillRects = &GLES2_RenderFillRects; + renderer->RenderCopy = &GLES2_RenderCopy; + renderer->RenderReadPixels = &GLES2_RenderReadPixels; + renderer->RenderPresent = &GLES2_RenderPresent; + renderer->DestroyTexture = &GLES2_DestroyTexture; + renderer->DestroyRenderer = &GLES2_DestroyRenderer; + + GLES2_ResetState(renderer); + + return renderer; +} + +#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/opengles2/SDL_shaders_gles2.c b/project/jni/sdl-1.3/src/render/opengles2/SDL_shaders_gles2.c new file mode 100644 index 000000000..e82716b14 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/opengles2/SDL_shaders_gles2.c @@ -0,0 +1,541 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED + +#include "SDL_video.h" +#include "SDL_opengles2.h" +#include "SDL_shaders_gles2.h" +#include "SDL_stdinc.h" + +/************************************************************************************************* + * Vertex/fragment shader source * + *************************************************************************************************/ + +static const Uint8 GLES2_VertexSrc_Default_[] = " \ + uniform mat4 u_projection; \ + attribute vec4 a_position; \ + attribute vec2 a_texCoord; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + v_texCoord = a_texCoord; \ + gl_Position = u_projection * a_position; \ + gl_PointSize = 1.0; \ + } \ +"; + +static const Uint8 GLES2_FragmentSrc_SolidSrc_[] = " \ + precision mediump float; \ + uniform vec4 u_color; \ + \ + void main() \ + { \ + gl_FragColor = u_color; \ + } \ +"; + +static const Uint8 GLES2_FragmentSrc_TextureSrc_[] = " \ + precision mediump float; \ + uniform sampler2D u_texture; \ + uniform vec4 u_modulation; \ + varying vec2 v_texCoord; \ + \ + void main() \ + { \ + gl_FragColor = texture2D(u_texture, v_texCoord); \ + gl_FragColor *= u_modulation; \ + } \ +"; + +static const GLES2_ShaderInstance GLES2_VertexSrc_Default = { + GL_VERTEX_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_VertexSrc_Default_), + GLES2_VertexSrc_Default_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_SolidSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_SolidSrc_), + GLES2_FragmentSrc_SolidSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentSrc_TextureSrc = { + GL_FRAGMENT_SHADER, + GLES2_SOURCE_SHADER, + sizeof(GLES2_FragmentSrc_TextureSrc_), + GLES2_FragmentSrc_TextureSrc_ +}; + +/************************************************************************************************* + * Vertex/fragment shader binaries (NVIDIA Tegra 1/2) * + *************************************************************************************************/ + +#if GLES2_INCLUDE_NVIDIA_SHADERS + +#define GL_NVIDIA_PLATFORM_BINARY_NV 0x890B + +static const Uint8 GLES2_VertexTegra_Default_[] = { + 243, 193, 1, 142, 31, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, + 0, 0, 46, 0, 0, 0, 48, 0, 0, 0, 2, 0, 0, 0, 85, 0, 0, 0, 2, 0, 0, 0, 24, 0, 0, 0, 3, 0, 0, 0, + 91, 0, 0, 0, 1, 0, 0, 0, 16, 0, 0, 0, 5, 0, 0, 0, 95, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 95, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, + 13, 0, 0, 0, 102, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 16, 0, 0, 0, 104, 0, 0, 0, 1, 0, 0, 0, 32, 0, 0, 0, 17, 0, 0, 0, 112, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 112, 0, 0, 0, 80, 0, 0, 0, 80, 0, 0, 0, 19, 0, 0, 0, 132, 0, + 0, 0, 104, 0, 0, 0, 104, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 97, + 95, 112, 111, 115, 105, 116, 105, 111, 110, 0, 97, 95, 116, 101, 120, 67, 111, 111, 114, 100, + 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 112, 114, 111, 106, 101, 99, + 116, 105, 111, 110, 0, 0, 0, 0, 0, 0, 0, 82, 139, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 80, 139, 0, + 0, 1, 0, 0, 0, 22, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 33, 0, 0, 0, 92, 139, 0, 0, + 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 240, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 64, 0, 0, 0, 80, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 193, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 128, 63, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 66, 24, 0, 6, 34, 108, 28, + 0, 0, 42, 16, 128, 0, 195, 192, 6, 129, 252, 255, 65, 96, 108, 28, 0, 0, 0, 0, 0, 1, 195, 192, + 6, 1, 252, 255, 33, 96, 108, 156, 31, 64, 8, 1, 64, 0, 131, 192, 6, 1, 156, 159, 65, 96, 108, + 28, 0, 0, 85, 32, 0, 1, 195, 192, 6, 1, 252, 255, 33, 96, 108, 156, 31, 64, 0, 64, 64, 0, 131, + 192, 134, 1, 152, 31, 65, 96, 108, 156, 31, 64, 127, 48, 0, 1, 195, 192, 6, 129, 129, 255, 33, + 96 +}; + +static const Uint8 GLES2_FragmentTegra_None_SolidSrc_[] = { + 155, 191, 159, 1, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, + 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0, + 0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4, + 0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0, + 0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, + 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 0, 0, 0, 241, 0, 0, 0, 240, 0, 0, + 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, + 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, + 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 0, 0, 0, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0, 0, 0, + 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 0, 40, 0, 0, 0, 242, 65, 63, + 192, 200, 0, 0, 0, 242, 65, 63, 128, 168, 0, 0, 0, 242, 65, 63, 64, 72, 0, 0, 0, 242, 65, 63, + 1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0 +}; + +static const Uint8 GLES2_FragmentTegra_Alpha_SolidSrc_[] = { + 169, 153, 195, 28, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, + 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0, + 0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4, + 0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0, + 0, 220, 0, 0, 0, 220, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, + 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 118, 118, 17, 241, 0, 0, 0, 240, 0, + 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 3, 0, 0, 0, 21, 32, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, + 1, 0, 0, 0, 3, 0, 0, 0, 3, 0, 65, 37, 8, 0, 129, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 21, 0, + 0, 0, 0, 3, 0, 1, 38, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 39, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 3, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0, 9, 0, 0, 0, 24, 0, 4, 40, 232, 231, 15, + 0, 0, 242, 65, 62, 194, 72, 1, 0, 0, 250, 65, 63, 194, 40, 1, 0, 0, 250, 65, 63, 192, 168, 1, + 0, 0, 242, 1, 64, 192, 168, 1, 0, 0, 242, 1, 68, 168, 32, 0, 0, 0, 50, 64, 0, 192, 168, 15, + 0, 0, 242, 1, 66, 168, 64, 0, 16, 0, 242, 65, 1, 232, 231, 15, 0, 0, 242, 65, 62, 168, 160, + 0, 0, 0, 50, 64, 2, 104, 192, 0, 0, 36, 48, 66, 4, 232, 231, 15, 0, 0, 242, 65, 62, 3, 0, 6, + 40, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, 1, 41, 0, 0, 0, 0, 0, 0, 0, 0, 5, 0, 2, 0 +}; + +static const Uint8 GLES2_FragmentTegra_Additive_SolidSrc_[] = { + 59, 71, 42, 17, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, 0, + 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0, + 0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4, + 0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0, + 0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, + 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 22, 22, 17, 241, 0, 0, 0, 240, 0, + 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, + 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0, + 0, 0, 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 192, 200, 0, 0, 0, 26, + 0, 70, 192, 40, 0, 0, 0, 2, 0, 64, 192, 72, 0, 0, 0, 10, 0, 66, 192, 168, 0, 0, 0, 18, 0, 68, + 1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0 +}; + +static const Uint8 GLES2_FragmentTegra_Modulated_SolidSrc_[] = { + 37, 191, 49, 17, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, 0, + 0, 8, 0, 0, 0, 8, 0, 0, 0, 2, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 75, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 6, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, 0, 0, + 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 75, 0, 0, 0, 1, 0, 0, 0, 28, 0, 0, 0, 13, 0, + 0, 0, 82, 0, 0, 0, 2, 0, 0, 0, 8, 0, 0, 0, 14, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 22, 0, 0, 0, 84, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 92, 0, 0, 0, 1, 0, 0, 0, 4, + 0, 0, 0, 15, 0, 0, 0, 93, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 113, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 113, 0, 0, + 0, 108, 0, 0, 0, 108, 0, 0, 0, 20, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, 0, + 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 117, 95, 99, 111, 108, 111, 114, 0, 0, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 32, 32, 17, 241, 0, 0, 0, 240, 0, + 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 20, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, + 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 0, + 0, 0, 0, 1, 0, 1, 39, 0, 0, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 104, 192, 0, 0, 0, 242, + 1, 70, 8, 32, 0, 0, 0, 242, 1, 64, 40, 64, 0, 0, 0, 242, 1, 66, 72, 160, 0, 0, 0, 242, 1, 68, + 1, 0, 6, 40, 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0 +}; + +static const Uint8 GLES2_FragmentTegra_None_TextureSrc_[] = { + 220, 217, 41, 211, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, + 0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, + 82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, + 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0, + 13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4, + 0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0, + 0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135, + 0, 0, 0, 120, 0, 0, 0, 120, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, + 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108, + 97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, + 0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 0, 0, 0, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, + 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 1, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 65, 37, 0, 0, 0, 0, 1, 0, + 0, 21, 0, 0, 0, 0, 1, 0, 1, 38, 1, 0, 0, 0, 2, 0, 4, 38, 186, 81, 78, 16, 2, 1, 0, 0, 1, 0, + 1, 39, 0, 4, 0, 0, 1, 0, 1, 40, 1, 0, 0, 0, 8, 0, 4, 40, 104, 192, 0, 0, 0, 242, 1, 70, 8, 32, + 0, 0, 0, 242, 1, 64, 40, 64, 0, 0, 0, 242, 1, 66, 72, 160, 0, 0, 0, 242, 1, 68, 1, 0, 6, 40, + 0, 0, 0, 0, 1, 0, 1, 41, 5, 0, 2, 0 +}; + +static const Uint8 GLES2_FragmentTegra_Alpha_TextureSrc_[] = { + 71, 202, 114, 229, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, + 0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, + 82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, + 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0, + 13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4, + 0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0, + 0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135, + 0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, + 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108, + 97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, + 0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 118, 118, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, + 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, + 1, 0, 0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, + 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, + 8, 0, 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, + 81, 78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, + 0, 0, 16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 8, 192, 1, 0, 0, 242, 1, 64, 104, 32, 1, 0, + 0, 242, 1, 70, 72, 64, 1, 0, 0, 242, 1, 68, 154, 192, 0, 0, 37, 34, 64, 3, 8, 32, 0, 0, 5, 58, + 208, 4, 40, 64, 0, 0, 5, 50, 208, 4, 72, 160, 0, 0, 37, 42, 208, 4, 2, 0, 6, 40, 0, 0, 0, 0, + 0, 0, 0, 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0 +}; + +static const Uint8 GLES2_FragmentTegra_Additive_TextureSrc_[] = { + 161, 234, 193, 234, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, + 0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, + 82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, + 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0, + 13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4, + 0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0, + 0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135, + 0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, + 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108, + 97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, + 0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 22, 22, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, + 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, + 0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, 8, 0, + 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, 81, + 78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0, + 16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 104, 32, 1, 0, 0, 242, 1, 70, 8, 192, 1, 0, 0, 242, + 1, 64, 72, 64, 1, 0, 0, 242, 1, 68, 136, 192, 0, 0, 0, 26, 64, 4, 136, 32, 0, 0, 0, 2, 64, 7, + 136, 64, 0, 0, 0, 10, 64, 6, 136, 160, 0, 0, 0, 18, 64, 5, 2, 0, 6, 40, 0, 0, 0, 0, 0, 0, 0, + 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0 +}; + +static const Uint8 GLES2_FragmentTegra_Modulated_TextureSrc_[] = { + 75, 132, 201, 227, 47, 109, 131, 38, 6, 0, 1, 0, 5, 0, 0, 0, 17, 0, 0, 0, 1, 0, 0, 0, 73, 0, + 0, 0, 34, 0, 0, 0, 36, 0, 0, 0, 2, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, + 82, 0, 0, 0, 1, 0, 0, 0, 20, 0, 0, 0, 6, 0, 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 7, 0, + 0, 0, 87, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 87, 0, 0, 0, 2, 0, 0, 0, 56, 0, 0, 0, + 13, 0, 0, 0, 101, 0, 0, 0, 4, 0, 0, 0, 16, 0, 0, 0, 14, 0, 0, 0, 105, 0, 0, 0, 1, 0, 0, 0, 4, + 0, 0, 0, 22, 0, 0, 0, 106, 0, 0, 0, 8, 0, 0, 0, 32, 0, 0, 0, 23, 0, 0, 0, 114, 0, 0, 0, 1, 0, + 0, 0, 4, 0, 0, 0, 15, 0, 0, 0, 115, 0, 0, 0, 1, 0, 0, 0, 80, 0, 0, 0, 17, 0, 0, 0, 135, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 135, + 0, 0, 0, 176, 0, 0, 0, 176, 0, 0, 0, 20, 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 21, + 0, 0, 0, 135, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 109, 97, 110, 70, 73, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 118, 95, 116, 101, 120, 67, 111, 111, 114, 100, 0, 117, 95, 109, 111, 100, 117, 108, + 97, 116, 105, 111, 110, 0, 117, 95, 116, 101, 120, 116, 117, 114, 101, 0, 0, 0, 0, 0, 0, 0, + 2, 0, 0, 0, 0, 0, 0, 0, 220, 0, 0, 0, 0, 0, 0, 0, 11, 0, 0, 0, 82, 139, 0, 0, 1, 0, 0, 0, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 94, 139, 0, 0, 1, 0, 0, 0, 1, 0, 0, + 0, 2, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 5, 48, 0, 0, 0, 0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 1, 32, 32, 17, 241, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 240, + 0, 0, 0, 240, 0, 0, 0, 240, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 7, 0, 0, 0, 2, 0, 0, 0, 1, 0, + 0, 0, 2, 0, 0, 0, 21, 32, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 16, 0, 0, 0, 16, 0, 0, + 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 65, 82, 50, 48, 45, 66, 73, 78, 1, 0, 0, 0, 2, 0, 0, 0, 2, 0, 65, 37, 0, 0, 0, 0, 8, 0, + 129, 0, 1, 0, 0, 21, 0, 0, 0, 0, 2, 0, 1, 38, 1, 0, 0, 0, 0, 0, 0, 0, 2, 0, 4, 38, 186, 81, + 78, 16, 2, 1, 0, 0, 2, 0, 1, 39, 0, 4, 0, 0, 0, 0, 0, 0, 2, 0, 1, 40, 1, 0, 0, 0, 5, 0, 0, 0, + 16, 0, 4, 40, 40, 160, 1, 0, 0, 242, 1, 66, 8, 192, 1, 0, 0, 242, 1, 64, 104, 32, 1, 0, 0, 242, + 1, 70, 72, 64, 1, 0, 0, 242, 1, 68, 104, 192, 0, 0, 0, 242, 65, 4, 232, 32, 0, 0, 0, 242, 65, + 0, 40, 64, 0, 0, 0, 242, 65, 6, 72, 160, 0, 0, 0, 242, 65, 5, 2, 0, 6, 40, 0, 0, 0, 0, 0, 0, + 0, 0, 2, 0, 1, 41, 0, 0, 0, 0, 5, 0, 2, 0 +}; + +static const GLES2_ShaderInstance GLES2_VertexTegra_Default = { + GL_VERTEX_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_VertexTegra_Default_), + GLES2_VertexTegra_Default_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentTegra_None_SolidSrc = { + GL_FRAGMENT_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_FragmentTegra_None_SolidSrc_), + GLES2_FragmentTegra_None_SolidSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentTegra_Alpha_SolidSrc = { + GL_FRAGMENT_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_FragmentTegra_Alpha_SolidSrc_), + GLES2_FragmentTegra_Alpha_SolidSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentTegra_Additive_SolidSrc = { + GL_FRAGMENT_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_FragmentTegra_Additive_SolidSrc_), + GLES2_FragmentTegra_Additive_SolidSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentTegra_Modulated_SolidSrc = { + GL_FRAGMENT_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_FragmentTegra_Modulated_SolidSrc_), + GLES2_FragmentTegra_Modulated_SolidSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentTegra_None_TextureSrc = { + GL_FRAGMENT_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_FragmentTegra_None_TextureSrc_), + GLES2_FragmentTegra_None_TextureSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentTegra_Alpha_TextureSrc = { + GL_FRAGMENT_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_FragmentTegra_Alpha_TextureSrc_), + GLES2_FragmentTegra_Alpha_TextureSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentTegra_Additive_TextureSrc = { + GL_FRAGMENT_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_FragmentTegra_Additive_TextureSrc_), + GLES2_FragmentTegra_Additive_TextureSrc_ +}; + +static const GLES2_ShaderInstance GLES2_FragmentTegra_Modulated_TextureSrc = { + GL_FRAGMENT_SHADER, + GL_NVIDIA_PLATFORM_BINARY_NV, + sizeof(GLES2_FragmentTegra_Modulated_TextureSrc_), + GLES2_FragmentTegra_Modulated_TextureSrc_ +}; + +#endif /* GLES2_INCLUDE_NVIDIA_SHADERS */ + +/************************************************************************************************* + * Vertex/fragment shader definitions * + *************************************************************************************************/ + +static GLES2_Shader GLES2_VertexShader_Default = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_VertexTegra_Default, +#endif + &GLES2_VertexSrc_Default + } +}; + +static GLES2_Shader GLES2_FragmentShader_None_SolidSrc = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_FragmentTegra_None_SolidSrc, +#endif + &GLES2_FragmentSrc_SolidSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_Alpha_SolidSrc = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_FragmentTegra_Alpha_SolidSrc, +#endif + &GLES2_FragmentSrc_SolidSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_Additive_SolidSrc = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_FragmentTegra_Additive_SolidSrc, +#endif + &GLES2_FragmentSrc_SolidSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_Modulated_SolidSrc = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_FragmentTegra_Modulated_SolidSrc, +#endif + &GLES2_FragmentSrc_SolidSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_None_TextureSrc = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_FragmentTegra_None_TextureSrc, +#endif + &GLES2_FragmentSrc_TextureSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_Alpha_TextureSrc = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_FragmentTegra_Alpha_TextureSrc, +#endif + &GLES2_FragmentSrc_TextureSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_Additive_TextureSrc = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_FragmentTegra_Additive_TextureSrc, +#endif + &GLES2_FragmentSrc_TextureSrc + } +}; + +static GLES2_Shader GLES2_FragmentShader_Modulated_TextureSrc = { + 2, + { +#if GLES2_INCLUDE_NVIDIA_SHADERS + &GLES2_FragmentTegra_Modulated_TextureSrc, +#endif + &GLES2_FragmentSrc_TextureSrc + } +}; + +/************************************************************************************************* + * Shader selector * + *************************************************************************************************/ + +const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode) +{ + switch (type) + { + case GLES2_SHADER_VERTEX_DEFAULT: + return &GLES2_VertexShader_Default; + case GLES2_SHADER_FRAGMENT_SOLID_SRC: + switch (blendMode) + { + case SDL_BLENDMODE_NONE: + return &GLES2_FragmentShader_None_SolidSrc; + case SDL_BLENDMODE_BLEND: + return &GLES2_FragmentShader_Alpha_SolidSrc; + case SDL_BLENDMODE_ADD: + return &GLES2_FragmentShader_Additive_SolidSrc; + case SDL_BLENDMODE_MOD: + return &GLES2_FragmentShader_Modulated_SolidSrc; + default: + return NULL; + } + case GLES2_SHADER_FRAGMENT_TEXTURE_SRC: + switch (blendMode) + { + case SDL_BLENDMODE_NONE: + return &GLES2_FragmentShader_None_TextureSrc; + case SDL_BLENDMODE_BLEND: + return &GLES2_FragmentShader_Alpha_TextureSrc; + case SDL_BLENDMODE_ADD: + return &GLES2_FragmentShader_Additive_TextureSrc; + case SDL_BLENDMODE_MOD: + return &GLES2_FragmentShader_Modulated_TextureSrc; + default: + return NULL; + } + default: + return NULL; + } +} + +#endif /* SDL_VIDEO_RENDER_OGL_ES2 && !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/opengles2/SDL_shaders_gles2.h b/project/jni/sdl-1.3/src/render/opengles2/SDL_shaders_gles2.h new file mode 100644 index 000000000..c34d7e587 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/opengles2/SDL_shaders_gles2.h @@ -0,0 +1,57 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_RENDER_OGL_ES2 + +#ifndef SDL_shaderdata_h_ +#define SDL_shaderdata_h_ + +typedef struct GLES2_ShaderInstance +{ + GLenum type; + GLenum format; + int length; + const void *data; +} GLES2_ShaderInstance; + +typedef struct GLES2_Shader +{ + int instance_count; + const GLES2_ShaderInstance *instances[4]; +} GLES2_Shader; + +typedef enum +{ + GLES2_SHADER_VERTEX_DEFAULT, + GLES2_SHADER_FRAGMENT_SOLID_SRC, + GLES2_SHADER_FRAGMENT_TEXTURE_SRC +} GLES2_ShaderType; + +#define GLES2_SOURCE_SHADER (GLenum)-1 + +const GLES2_Shader *GLES2_GetShader(GLES2_ShaderType type, SDL_BlendMode blendMode); + +#endif /* SDL_shaderdata_h_ */ + +#endif /* SDL_VIDEO_RENDER_OGL_ES2 */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_blendfillrect.c b/project/jni/sdl-1.3/src/render/software/SDL_blendfillrect.c similarity index 85% rename from project/jni/sdl-1.3/src/video/SDL_blendfillrect.c rename to project/jni/sdl-1.3/src/render/software/SDL_blendfillrect.c index 617b1601f..f7d7e705a 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blendfillrect.c +++ b/project/jni/sdl-1.3/src/render/software/SDL_blendfillrect.c @@ -1,28 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_video.h" +#if !SDL_RENDER_DISABLED + #include "SDL_draw.h" +#include "SDL_blendfillrect.h" + static int SDL_BlendFillRect_RGB555(SDL_Surface * dst, const SDL_Rect * rect, @@ -262,10 +264,10 @@ SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, } int -SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, +SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { - SDL_Rect clipped; + SDL_Rect rect; int i; int (*func)(SDL_Surface * dst, const SDL_Rect * rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) = NULL; @@ -326,22 +328,15 @@ SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, } for (i = 0; i < count; ++i) { - const SDL_Rect * rect = rects[i]; - - /* If 'rect' == NULL, then fill the whole surface */ - if (rect) { - /* Perform clipping */ - if (!SDL_IntersectRect(rect, &dst->clip_rect, &clipped)) { - continue; - } - rect = &clipped; - } else { - rect = &dst->clip_rect; + /* Perform clipping */ + if (!SDL_IntersectRect(&rects[i], &dst->clip_rect, &rect)) { + continue; } - - status = func(dst, rect, blendMode, r, g, b, a); + status = func(dst, &rect, blendMode, r, g, b, a); } return status; } +#endif /* !SDL_RENDER_DISABLED */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/software/SDL_blendfillrect.h b/project/jni/sdl-1.3/src/render/software/SDL_blendfillrect.h new file mode 100644 index 000000000..ad4829f11 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/software/SDL_blendfillrect.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + + +extern int SDL_BlendFillRect(SDL_Surface * dst, const SDL_Rect * rect, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendFillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_blendline.c b/project/jni/sdl-1.3/src/render/software/SDL_blendline.c similarity index 95% rename from project/jni/sdl-1.3/src/video/SDL_blendline.c rename to project/jni/sdl-1.3/src/render/software/SDL_blendline.c index 3c24624d4..796bd91eb 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blendline.c +++ b/project/jni/sdl-1.3/src/render/software/SDL_blendline.c @@ -1,27 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if !SDL_RENDER_DISABLED + #include "SDL_draw.h" +#include "SDL_blendline.h" +#include "SDL_blendpoint.h" static void @@ -121,7 +124,6 @@ SDL_BlendLine_RGB555(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end) { - const SDL_PixelFormat *fmt = dst->format; unsigned r, g, b, a, inva; if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { @@ -213,7 +215,6 @@ SDL_BlendLine_RGB565(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end) { - const SDL_PixelFormat *fmt = dst->format; unsigned r, g, b, a, inva; if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { @@ -489,7 +490,6 @@ SDL_BlendLine_RGB888(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end) { - const SDL_PixelFormat *fmt = dst->format; unsigned r, g, b, a, inva; if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { @@ -581,7 +581,6 @@ SDL_BlendLine_ARGB8888(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 _r, Uint8 _g, Uint8 _b, Uint8 _a, SDL_bool draw_end) { - const SDL_PixelFormat *fmt = dst->format; unsigned r, g, b, a, inva; if (blendMode == SDL_BLENDMODE_BLEND || blendMode == SDL_BLENDMODE_ADD) { @@ -777,4 +776,6 @@ SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, return 0; } +#endif /* !SDL_RENDER_DISABLED */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/software/SDL_blendline.h b/project/jni/sdl-1.3/src/render/software/SDL_blendline.h new file mode 100644 index 000000000..407b60c41 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/software/SDL_blendline.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + + +extern int SDL_BlendLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendLines(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_blendpoint.c b/project/jni/sdl-1.3/src/render/software/SDL_blendpoint.c similarity index 89% rename from project/jni/sdl-1.3/src/video/SDL_blendpoint.c rename to project/jni/sdl-1.3/src/render/software/SDL_blendpoint.c index dfd346804..96a07631a 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blendpoint.c +++ b/project/jni/sdl-1.3/src/render/software/SDL_blendpoint.c @@ -1,27 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if !SDL_RENDER_DISABLED + #include "SDL_draw.h" +#include "SDL_blendpoint.h" + static int SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, @@ -341,4 +344,6 @@ SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, return status; } +#endif /* !SDL_RENDER_DISABLED */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/software/SDL_blendpoint.h b/project/jni/sdl-1.3/src/render/software/SDL_blendpoint.h new file mode 100644 index 000000000..3189cf9ee --- /dev/null +++ b/project/jni/sdl-1.3/src/render/software/SDL_blendpoint.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + + +extern int SDL_BlendPoint(SDL_Surface * dst, int x, int y, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); +extern int SDL_BlendPoints(SDL_Surface * dst, const SDL_Point * points, int count, SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_draw.h b/project/jni/sdl-1.3/src/render/software/SDL_draw.h similarity index 93% rename from project/jni/sdl-1.3/src/video/SDL_draw.h rename to project/jni/sdl-1.3/src/render/software/SDL_draw.h index 9990016e7..12cd6849c 100644 --- a/project/jni/sdl-1.3/src/video/SDL_draw.h +++ b/project/jni/sdl-1.3/src/render/software/SDL_draw.h @@ -1,27 +1,26 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_blit.h" +#include "../../video/SDL_blit.h" /* This code assumes that r, g, b, a are the source color, * and in the blend and add case, the RGB values are premultiplied by a. @@ -46,13 +45,13 @@ #define DRAW_SETPIXEL(setpixel) \ do { \ - unsigned sr = r, sg = g, sb = b, sa = a; \ + unsigned sr = r, sg = g, sb = b, sa = a; (void) sa; \ setpixel; \ } while (0) #define DRAW_SETPIXEL_BLEND(getpixel, setpixel) \ do { \ - unsigned sr, sg, sb, sa; sa; \ + unsigned sr, sg, sb, sa; (void) sa; \ getpixel; \ sr = DRAW_MUL(inva, sr) + r; \ sg = DRAW_MUL(inva, sg) + g; \ @@ -62,7 +61,7 @@ do { \ #define DRAW_SETPIXEL_ADD(getpixel, setpixel) \ do { \ - unsigned sr, sg, sb, sa; sa; \ + unsigned sr, sg, sb, sa; (void) sa; \ getpixel; \ sr += r; if (sr > 0xff) sr = 0xff; \ sg += g; if (sg > 0xff) sg = 0xff; \ @@ -72,7 +71,7 @@ do { \ #define DRAW_SETPIXEL_MOD(getpixel, setpixel) \ do { \ - unsigned sr, sg, sb, sa; sa; \ + unsigned sr, sg, sb, sa; (void) sa; \ getpixel; \ sr = DRAW_MUL(sr, r); \ sg = DRAW_MUL(sg, g); \ diff --git a/project/jni/sdl-1.3/src/video/SDL_drawline.c b/project/jni/sdl-1.3/src/render/software/SDL_drawline.c similarity index 84% rename from project/jni/sdl-1.3/src/video/SDL_drawline.c rename to project/jni/sdl-1.3/src/render/software/SDL_drawline.c index bb6dbfe8a..b3a963418 100644 --- a/project/jni/sdl-1.3/src/video/SDL_drawline.c +++ b/project/jni/sdl-1.3/src/render/software/SDL_drawline.c @@ -1,27 +1,31 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if !SDL_RENDER_DISABLED + #include "SDL_draw.h" +#include "SDL_drawline.h" +#include "SDL_drawpoint.h" + static void SDL_DrawLine1(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color, @@ -205,4 +209,6 @@ SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, return 0; } +#endif /* !SDL_RENDER_DISABLED */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/software/SDL_drawline.h b/project/jni/sdl-1.3/src/render/software/SDL_drawline.h new file mode 100644 index 000000000..2c582d747 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/software/SDL_drawline.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + + +extern int SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color); +extern int SDL_DrawLines(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_drawpoint.c b/project/jni/sdl-1.3/src/render/software/SDL_drawpoint.c similarity index 68% rename from project/jni/sdl-1.3/src/video/SDL_drawpoint.c rename to project/jni/sdl-1.3/src/render/software/SDL_drawpoint.c index e6a8aad57..9ee3686e0 100644 --- a/project/jni/sdl-1.3/src/video/SDL_drawpoint.c +++ b/project/jni/sdl-1.3/src/render/software/SDL_drawpoint.c @@ -1,27 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if !SDL_RENDER_DISABLED + #include "SDL_draw.h" +#include "SDL_drawpoint.h" int @@ -113,4 +115,6 @@ SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, return 0; } +#endif /* !SDL_RENDER_DISABLED */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/software/SDL_drawpoint.h b/project/jni/sdl-1.3/src/render/software/SDL_drawpoint.h new file mode 100644 index 000000000..481cf93e2 --- /dev/null +++ b/project/jni/sdl-1.3/src/render/software/SDL_drawpoint.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + + +extern int SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color); +extern int SDL_DrawPoints(SDL_Surface * dst, const SDL_Point * points, int count, Uint32 color); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/software/SDL_render_sw.c b/project/jni/sdl-1.3/src/render/software/SDL_render_sw.c new file mode 100644 index 000000000..ce63f1dee --- /dev/null +++ b/project/jni/sdl-1.3/src/render/software/SDL_render_sw.c @@ -0,0 +1,546 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if !SDL_RENDER_DISABLED + +#include "../SDL_sysrender.h" +#include "SDL_render_sw_c.h" + +#include "SDL_draw.h" +#include "SDL_blendfillrect.h" +#include "SDL_blendline.h" +#include "SDL_blendpoint.h" +#include "SDL_drawline.h" +#include "SDL_drawpoint.h" + + +/* SDL surface based renderer implementation */ + +static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags); +static void SW_WindowEvent(SDL_Renderer * renderer, + const SDL_WindowEvent *event); +static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int SW_SetTextureColorMod(SDL_Renderer * renderer, + SDL_Texture * texture); +static int SW_SetTextureAlphaMod(SDL_Renderer * renderer, + SDL_Texture * texture); +static int SW_SetTextureBlendMode(SDL_Renderer * renderer, + SDL_Texture * texture); +static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, + int pitch); +static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch); +static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static int SW_UpdateViewport(SDL_Renderer * renderer); +static int SW_RenderClear(SDL_Renderer * renderer); +static int SW_RenderDrawPoints(SDL_Renderer * renderer, + const SDL_Point * points, int count); +static int SW_RenderDrawLines(SDL_Renderer * renderer, + const SDL_Point * points, int count); +static int SW_RenderFillRects(SDL_Renderer * renderer, + const SDL_Rect * rects, int count); +static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect); +static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch); +static void SW_RenderPresent(SDL_Renderer * renderer); +static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); +static void SW_DestroyRenderer(SDL_Renderer * renderer); + + +SDL_RenderDriver SW_RenderDriver = { + SW_CreateRenderer, + { + "software", + SDL_RENDERER_SOFTWARE, + 8, + { + SDL_PIXELFORMAT_RGB555, + SDL_PIXELFORMAT_RGB565, + SDL_PIXELFORMAT_RGB888, + SDL_PIXELFORMAT_BGR888, + SDL_PIXELFORMAT_ARGB8888, + SDL_PIXELFORMAT_RGBA8888, + SDL_PIXELFORMAT_ABGR8888, + SDL_PIXELFORMAT_BGRA8888 + }, + 0, + 0} +}; + +typedef struct +{ + SDL_Surface *surface; +} SW_RenderData; + + +static SDL_Surface * +SW_ActivateRenderer(SDL_Renderer * renderer) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + + if (!data->surface) { + data->surface = SDL_GetWindowSurface(renderer->window); + + SW_UpdateViewport(renderer); + } + return data->surface; +} + +SDL_Renderer * +SW_CreateRendererForSurface(SDL_Surface * surface) +{ + SDL_Renderer *renderer; + SW_RenderData *data; + + if (!surface) { + SDL_SetError("Can't create renderer for NULL surface"); + return NULL; + } + + renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); + if (!renderer) { + SDL_OutOfMemory(); + return NULL; + } + + data = (SW_RenderData *) SDL_calloc(1, sizeof(*data)); + if (!data) { + SW_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return NULL; + } + data->surface = surface; + + renderer->WindowEvent = SW_WindowEvent; + renderer->CreateTexture = SW_CreateTexture; + renderer->SetTextureColorMod = SW_SetTextureColorMod; + renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod; + renderer->SetTextureBlendMode = SW_SetTextureBlendMode; + renderer->UpdateTexture = SW_UpdateTexture; + renderer->LockTexture = SW_LockTexture; + renderer->UnlockTexture = SW_UnlockTexture; + renderer->UpdateViewport = SW_UpdateViewport; + renderer->DestroyTexture = SW_DestroyTexture; + renderer->RenderClear = SW_RenderClear; + renderer->RenderDrawPoints = SW_RenderDrawPoints; + renderer->RenderDrawLines = SW_RenderDrawLines; + renderer->RenderFillRects = SW_RenderFillRects; + renderer->RenderCopy = SW_RenderCopy; + renderer->RenderReadPixels = SW_RenderReadPixels; + renderer->RenderPresent = SW_RenderPresent; + renderer->DestroyRenderer = SW_DestroyRenderer; + renderer->info = SW_RenderDriver.info; + renderer->driverdata = data; + + SW_ActivateRenderer(renderer); + + return renderer; +} + +SDL_Renderer * +SW_CreateRenderer(SDL_Window * window, Uint32 flags) +{ + SDL_Surface *surface; + + surface = SDL_GetWindowSurface(window); + if (!surface) { + return NULL; + } + return SW_CreateRendererForSurface(surface); +} + +static void +SW_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + data->surface = NULL; + } +} + +static int +SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + + if (!SDL_PixelFormatEnumToMasks + (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { + SDL_SetError("Unknown texture format"); + return -1; + } + + texture->driverdata = + SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask, + Bmask, Amask); + SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g, + texture->b); + SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a); + SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode); + + if (texture->access == SDL_TEXTUREACCESS_STATIC) { + SDL_SetSurfaceRLE(texture->driverdata, 1); + } + + if (!texture->driverdata) { + return -1; + } + return 0; +} + +static int +SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + return SDL_SetSurfaceColorMod(surface, texture->r, texture->g, + texture->b); +} + +static int +SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + return SDL_SetSurfaceAlphaMod(surface, texture->a); +} + +static int +SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + return SDL_SetSurfaceBlendMode(surface, texture->blendMode); +} + +static int +SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, const void *pixels, int pitch) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + Uint8 *src, *dst; + int row; + size_t length; + + if(SDL_MUSTLOCK(surface)) + SDL_LockSurface(surface); + src = (Uint8 *) pixels; + dst = (Uint8 *) surface->pixels + + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel; + length = rect->w * surface->format->BytesPerPixel; + for (row = 0; row < rect->h; ++row) { + SDL_memcpy(dst, src, length); + src += pitch; + dst += surface->pitch; + } + if(SDL_MUSTLOCK(surface)) + SDL_UnlockSurface(surface); + return 0; +} + +static int +SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * rect, void **pixels, int *pitch) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + + *pixels = + (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel); + *pitch = surface->pitch; + return 0; +} + +static void +SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ +} + +static int +SW_UpdateViewport(SDL_Renderer * renderer) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + SDL_Surface *surface = data->surface; + + if (!surface) { + /* We'll update the viewport after we recreate the surface */ + return 0; + } + + if (!renderer->viewport.w && !renderer->viewport.h) { + /* There may be no window, so update the viewport directly */ + renderer->viewport.w = surface->w; + renderer->viewport.h = surface->h; + } + SDL_SetClipRect(data->surface, &renderer->viewport); + return 0; +} + +static int +SW_RenderClear(SDL_Renderer * renderer) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + Uint32 color; + SDL_Rect clip_rect; + + if (!surface) { + return -1; + } + + color = SDL_MapRGBA(surface->format, + renderer->r, renderer->g, renderer->b, renderer->a); + + /* By definition the clear ignores the clip rect */ + clip_rect = surface->clip_rect; + SDL_SetClipRect(surface, NULL); + SDL_FillRect(surface, NULL, color); + SDL_SetClipRect(surface, &clip_rect); + return 0; +} + +static int +SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, + int count) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Point *temp = NULL; + int status; + + if (!surface) { + return -1; + } + + if (renderer->viewport.x || renderer->viewport.y) { + int i; + int x = renderer->viewport.x; + int y = renderer->viewport.y; + + temp = SDL_stack_alloc(SDL_Point, count); + for (i = 0; i < count; ++i) { + temp[i].x = x + points[i].x; + temp[i].y = y + points[i].x; + } + points = temp; + } + + /* Draw the points! */ + if (renderer->blendMode == SDL_BLENDMODE_NONE) { + Uint32 color = SDL_MapRGBA(surface->format, + renderer->r, renderer->g, renderer->b, + renderer->a); + + status = SDL_DrawPoints(surface, points, count, color); + } else { + status = SDL_BlendPoints(surface, points, count, + renderer->blendMode, + renderer->r, renderer->g, renderer->b, + renderer->a); + } + + if (temp) { + SDL_stack_free(temp); + } + return status; +} + +static int +SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, + int count) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Point *temp = NULL; + int status; + + if (!surface) { + return -1; + } + + if (renderer->viewport.x || renderer->viewport.y) { + int i; + int x = renderer->viewport.x; + int y = renderer->viewport.y; + + temp = SDL_stack_alloc(SDL_Point, count); + for (i = 0; i < count; ++i) { + temp[i].x = x + points[i].x; + temp[i].y = y + points[i].y; + } + points = temp; + } + + /* Draw the lines! */ + if (renderer->blendMode == SDL_BLENDMODE_NONE) { + Uint32 color = SDL_MapRGBA(surface->format, + renderer->r, renderer->g, renderer->b, + renderer->a); + + status = SDL_DrawLines(surface, points, count, color); + } else { + status = SDL_BlendLines(surface, points, count, + renderer->blendMode, + renderer->r, renderer->g, renderer->b, + renderer->a); + } + + if (temp) { + SDL_stack_free(temp); + } + return status; +} + +static int +SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect * rects, int count) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Rect *temp = NULL; + int status; + + if (!surface) { + return -1; + } + + if (renderer->viewport.x || renderer->viewport.y) { + int i; + int x = renderer->viewport.x; + int y = renderer->viewport.y; + + temp = SDL_stack_alloc(SDL_Rect, count); + for (i = 0; i < count; ++i) { + temp[i].x = x + rects[i].x; + temp[i].y = y + rects[i].y; + temp[i].w = rects[i].w; + temp[i].h = rects[i].h; + } + rects = temp; + } + + if (renderer->blendMode == SDL_BLENDMODE_NONE) { + Uint32 color = SDL_MapRGBA(surface->format, + renderer->r, renderer->g, renderer->b, + renderer->a); + status = SDL_FillRects(surface, rects, count, color); + } else { + status = SDL_BlendFillRects(surface, rects, count, + renderer->blendMode, + renderer->r, renderer->g, renderer->b, + renderer->a); + } + + if (temp) { + SDL_stack_free(temp); + } + return status; +} + +static int +SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, + const SDL_Rect * srcrect, const SDL_Rect * dstrect) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + SDL_Surface *src = (SDL_Surface *) texture->driverdata; + SDL_Rect final_rect = *dstrect; + + if (!surface) { + return -1; + } + + if (renderer->viewport.x || renderer->viewport.y) { + final_rect.x += renderer->viewport.x; + final_rect.y += renderer->viewport.y; + } + if ( srcrect->w == final_rect.w && srcrect->h == final_rect.h ) { + return SDL_BlitSurface(src, srcrect, surface, &final_rect); + } else { + return SDL_BlitScaled(src, srcrect, surface, &final_rect); + } +} + +static int +SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch) +{ + SDL_Surface *surface = SW_ActivateRenderer(renderer); + Uint32 src_format; + void *src_pixels; + SDL_Rect final_rect; + + if (!surface) { + return -1; + } + + if (renderer->viewport.x || renderer->viewport.y) { + final_rect.x = renderer->viewport.x + rect->x; + final_rect.y = renderer->viewport.y + rect->y; + final_rect.w = rect->w; + final_rect.h = rect->h; + rect = &final_rect; + } + + if (rect->x < 0 || rect->x+rect->w > surface->w || + rect->y < 0 || rect->y+rect->h > surface->h) { + SDL_SetError("Tried to read outside of surface bounds"); + return -1; + } + + src_format = surface->format->format; + src_pixels = (void*)((Uint8 *) surface->pixels + + rect->y * surface->pitch + + rect->x * surface->format->BytesPerPixel); + + return SDL_ConvertPixels(rect->w, rect->h, + src_format, src_pixels, surface->pitch, + format, pixels, pitch); +} + +static void +SW_RenderPresent(SDL_Renderer * renderer) +{ + SDL_Window *window = renderer->window; + + if (window) { + SDL_UpdateWindowSurface(window); + } +} + +static void +SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) +{ + SDL_Surface *surface = (SDL_Surface *) texture->driverdata; + + SDL_FreeSurface(surface); +} + +static void +SW_DestroyRenderer(SDL_Renderer * renderer) +{ + SW_RenderData *data = (SW_RenderData *) renderer->driverdata; + + if (data) { + SDL_free(data); + } + SDL_free(renderer); +} + +#endif /* !SDL_RENDER_DISABLED */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/render/software/SDL_render_sw_c.h b/project/jni/sdl-1.3/src/render/software/SDL_render_sw_c.h new file mode 100644 index 000000000..3895563fa --- /dev/null +++ b/project/jni/sdl-1.3/src/render/software/SDL_render_sw_c.h @@ -0,0 +1,24 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +extern SDL_Renderer * SW_CreateRendererForSurface(SDL_Surface * surface); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/stdlib/SDL_getenv.c b/project/jni/sdl-1.3/src/stdlib/SDL_getenv.c index 387531a88..561b38d4b 100644 --- a/project/jni/sdl-1.3/src/stdlib/SDL_getenv.c +++ b/project/jni/sdl-1.3/src/stdlib/SDL_getenv.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -27,8 +26,7 @@ #if defined(__WIN32__) && !defined(_WIN32_WCE) -#define WIN32_LEAN_AND_MEAN -#include +#include "../core/windows/SDL_windows.h" /* Note this isn't thread-safe! */ @@ -41,12 +39,12 @@ SDL_setenv(const char *name, const char *value, int overwrite) { if (!overwrite) { char ch = 0; - const size_t len = GetEnvironmentVariable(name, &ch, sizeof (ch)); + const size_t len = GetEnvironmentVariableA(name, &ch, sizeof (ch)); if (len > 0) { return 0; /* asked not to overwrite existing value. */ } } - if (!SetEnvironmentVariable(name, *value ? value : NULL)) { + if (!SetEnvironmentVariableA(name, *value ? value : NULL)) { return -1; } return 0; @@ -59,7 +57,7 @@ SDL_getenv(const char *name) size_t bufferlen; bufferlen = - GetEnvironmentVariable(name, SDL_envmem, (DWORD) SDL_envmemlen); + GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen); if (bufferlen == 0) { return NULL; } @@ -70,7 +68,7 @@ SDL_getenv(const char *name) } SDL_envmem = newmem; SDL_envmemlen = bufferlen; - GetEnvironmentVariable(name, SDL_envmem, (DWORD) SDL_envmemlen); + GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen); } return SDL_envmem; } diff --git a/project/jni/sdl-1.3/src/stdlib/SDL_iconv.c b/project/jni/sdl-1.3/src/stdlib/SDL_iconv.c index 96639b18f..225e03368 100644 --- a/project/jni/sdl-1.3/src/stdlib/SDL_iconv.c +++ b/project/jni/sdl-1.3/src/stdlib/SDL_iconv.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -32,8 +31,8 @@ iconv() may or may not use const char ** for the inbuf param. If we get this wrong, it's just a warning, so no big deal. */ -#if defined(_XGP6) || \ - defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2)) +#if defined(_XGP6) || defined(__APPLE__) || \ + (defined(__GLIBC__) && ((__GLIBC__ > 2) || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 2))) #define ICONV_INBUF_NONCONST #endif diff --git a/project/jni/sdl-1.3/src/stdlib/SDL_malloc.c b/project/jni/sdl-1.3/src/stdlib/SDL_malloc.c index fe61be9c7..fe3136f8d 100644 --- a/project/jni/sdl-1.3/src/stdlib/SDL_malloc.c +++ b/project/jni/sdl-1.3/src/stdlib/SDL_malloc.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/stdlib/SDL_stdlib.c b/project/jni/sdl-1.3/src/stdlib/SDL_stdlib.c index 93e13b3cc..70d31eb07 100644 --- a/project/jni/sdl-1.3/src/stdlib/SDL_stdlib.c +++ b/project/jni/sdl-1.3/src/stdlib/SDL_stdlib.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -35,9 +34,44 @@ __declspec(selectany) int _fltused = 1; #endif -#ifdef _WIN64 +/* The optimizer on Visual Studio 2010 generates memcpy() calls */ +#if _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) +#include -#else +#pragma function(memcpy) +void * memcpy ( void * destination, const void * source, size_t num ) +{ + const Uint8 *src = (const Uint8 *)source; + Uint8 *dst = (Uint8 *)destination; + size_t i; + + /* All WIN64 architectures have SSE, right? */ + if (!((uintptr_t) src & 15) && !((uintptr_t) dst & 15)) { + __m128 values[4]; + for (i = num / 64; i--;) { + _mm_prefetch(src, _MM_HINT_NTA); + values[0] = *(__m128 *) (src + 0); + values[1] = *(__m128 *) (src + 16); + values[2] = *(__m128 *) (src + 32); + values[3] = *(__m128 *) (src + 48); + _mm_stream_ps((float *) (dst + 0), values[0]); + _mm_stream_ps((float *) (dst + 16), values[1]); + _mm_stream_ps((float *) (dst + 32), values[2]); + _mm_stream_ps((float *) (dst + 48), values[3]); + src += 64; + dst += 64; + } + num &= 63; + } + + while (num--) { + *dst++ = *src++; + } + return destination; +} +#endif /* _MSC_VER == 1600 && defined(_WIN64) && !defined(_DEBUG) */ + +#ifdef _M_IX86 void __declspec(naked) @@ -699,7 +733,7 @@ RETZERO: /* *INDENT-ON* */ } -#endif /* _WIN64 */ +#endif /* _M_IX86 */ #endif /* MSC_VER */ diff --git a/project/jni/sdl-1.3/src/stdlib/SDL_string.c b/project/jni/sdl-1.3/src/stdlib/SDL_string.c index 02f086773..69a1c8c80 100644 --- a/project/jni/sdl-1.3/src/stdlib/SDL_string.c +++ b/project/jni/sdl-1.3/src/stdlib/SDL_string.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -32,9 +31,9 @@ #define UTF8_IsLeadByte(c) ((c) >= 0xC0 && (c) <= 0xF4) #define UTF8_IsTrailingByte(c) ((c) >= 0x80 && (c) <= 0xBF) -int UTF8_TrailingBytes(unsigned char c) +static int UTF8_TrailingBytes(unsigned char c) { - if (c >= 0xC0 && c<= 0xDF) + if (c >= 0xC0 && c <= 0xDF) return 1; else if (c >= 0xE0 && c <= 0xEF) return 2; @@ -149,7 +148,6 @@ SDL_ScanUintPtrT(const char *text, int radix, uintptr_t * valuep) } #endif -#ifdef SDL_HAS_64BIT_TYPE #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOLL) static size_t SDL_ScanLongLong(const char *text, int radix, Sint64 * valuep) @@ -222,7 +220,6 @@ SDL_ScanUnsignedLongLong(const char *text, int radix, Uint64 * valuep) return (text - textstart); } #endif -#endif /* SDL_HAS_64BIT_TYPE */ #if !defined(HAVE_SSCANF) || !defined(HAVE_STRTOD) static size_t @@ -265,31 +262,27 @@ void * SDL_memset(void *dst, int c, size_t len) { size_t left = (len % 4); - if (len >= 4) { - Uint32 value = 0; - Uint32 *dstp = (Uint32 *) dst; - int i; - for (i = 0; i < 4; ++i) { - value <<= 8; - value |= c; - } - len /= 4; - while (len--) { - *dstp++ = value; - } + Uint32 *dstp4; + Uint8 *dstp1; + Uint32 value4 = (c | (c << 8) | (c << 16) | (c << 24)); + Uint8 value1 = (Uint8) c; + + dstp4 = (Uint32 *) dst; + len /= 4; + while (len--) { + *dstp4++ = value4; } - if (left > 0) { - Uint8 value = (Uint8) c; - Uint8 *dstp = (Uint8 *) dst; - switch (left) { - case 3: - *dstp++ = value; - case 2: - *dstp++ = value; - case 1: - *dstp++ = value; - } + + dstp1 = (Uint8 *) dstp4; + switch (left) { + case 3: + *dstp1++ = value1; + case 2: + *dstp1++ = value1; + case 1: + *dstp1++ = value1; } + return dst; } #endif @@ -298,25 +291,49 @@ SDL_memset(void *dst, int c, size_t len) void * SDL_memcpy(void *dst, const void *src, size_t len) { - char *srcp = (char *) src; - char *dstp = (char *) dst; + size_t left = (len % 4); + Uint32 *srcp4, *dstp4; + Uint8 *srcp1, *dstp1; + + srcp4 = (Uint32 *) src; + dstp4 = (Uint32 *) dst; + len /= 4; while (len--) { - *dstp++ = *srcp++; + *dstp4++ = *srcp4++; } + + srcp1 = (Uint8 *) srcp4; + dstp1 = (Uint8 *) dstp4; + switch (left) { + case 3: + *dstp1++ = *srcp1++; + case 2: + *dstp1++ = *srcp1++; + case 1: + *dstp1++ = *srcp1++; + } + return dst; } #endif -#ifndef SDL_revcpy +#ifndef SDL_memmove void * -SDL_revcpy(void *dst, const void *src, size_t len) +SDL_memmove(void *dst, const void *src, size_t len) { char *srcp = (char *) src; char *dstp = (char *) dst; - srcp += len - 1; - dstp += len - 1; - while (len--) { - *dstp-- = *srcp--; + + if (src < dst) { + srcp += len - 1; + dstp += len - 1; + while (len--) { + *dstp-- = *srcp--; + } + } else { + while (len--) { + *dstp++ = *srcp++; + } } return dst; } @@ -408,7 +425,7 @@ size_t SDL_utf8strlcpy(char *dst, const char *src, size_t dst_bytes) { size_t src_bytes = SDL_strlen(src); size_t bytes = SDL_min(src_bytes, dst_bytes - 1); - int i = 0; + size_t i = 0; char trailing_bytes = 0; if (bytes) { @@ -659,8 +676,6 @@ SDL_strtoul(const char *string, char **endp, int base) } #endif -#ifdef SDL_HAS_64BIT_TYPE - #ifndef HAVE__I64TOA char * SDL_lltoa(Sint64 value, char *string, int radix) @@ -761,8 +776,6 @@ SDL_strtoull(const char *string, char **endp, int base) } #endif -#endif /* SDL_HAS_64BIT_TYPE */ - #ifndef HAVE_STRTOD double SDL_strtod(const char *string, char **endp) @@ -845,8 +858,8 @@ SDL_strncasecmp(const char *str1, const char *str2, size_t maxlen) ++str2; --maxlen; } - a = SDL_tolower(*str1); - b = SDL_tolower(*str2); + a = SDL_tolower((unsigned char) *str1); + b = SDL_tolower((unsigned char) *str2); return (int) ((unsigned char) a - (unsigned char) b); } #endif @@ -956,7 +969,6 @@ SDL_sscanf(const char *text, const char *fmt, ...) } /* Fall through to %d handling */ case 'd': -#ifdef SDL_HAS_64BIT_TYPE if (inttype == DO_LONGLONG) { Sint64 value; text += SDL_ScanLongLong(text, radix, &value); @@ -965,9 +977,7 @@ SDL_sscanf(const char *text, const char *fmt, ...) *valuep = value; ++retval; } - } else -#endif /* SDL_HAS_64BIT_TYPE */ - { + } else { long value; text += SDL_ScanLong(text, radix, &value); if (!suppress) { @@ -1011,7 +1021,6 @@ SDL_sscanf(const char *text, const char *fmt, ...) } /* Fall through to unsigned handling */ case 'u': -#ifdef SDL_HAS_64BIT_TYPE if (inttype == DO_LONGLONG) { Uint64 value; text += SDL_ScanUnsignedLongLong(text, radix, &value); @@ -1020,9 +1029,7 @@ SDL_sscanf(const char *text, const char *fmt, ...) *valuep = value; ++retval; } - } else -#endif /* SDL_HAS_64BIT_TYPE */ - { + } else { unsigned long value; text += SDL_ScanUnsignedLong(text, radix, &value); if (!suppress) { @@ -1174,7 +1181,6 @@ SDL_PrintUnsignedLong(char *text, unsigned long value, int radix, return size; } -#ifdef SDL_HAS_64BIT_TYPE static size_t SDL_PrintLongLong(char *text, Sint64 value, int radix, size_t maxlen) { @@ -1206,7 +1212,7 @@ SDL_PrintUnsignedLongLong(char *text, Uint64 value, int radix, size_t maxlen) return size; } -#endif /* SDL_HAS_64BIT_TYPE */ + static size_t SDL_PrintFloat(char *text, double arg, size_t maxlen) { @@ -1323,16 +1329,10 @@ SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap) radix, maxlen); break; case DO_LONGLONG: -#ifdef SDL_HAS_64BIT_TYPE len = SDL_PrintLongLong(text, va_arg(ap, Sint64), radix, maxlen); -#else - len = - SDL_PrintLong(text, va_arg(ap, long), - radix, maxlen); -#endif break; } done = SDL_TRUE; @@ -1372,20 +1372,11 @@ SDL_vsnprintf(char *text, size_t maxlen, const char *fmt, va_list ap) radix, maxlen); break; case DO_LONGLONG: -#ifdef SDL_HAS_64BIT_TYPE len = SDL_PrintUnsignedLongLong(text, va_arg(ap, Uint64), radix, maxlen); -#else - len = - SDL_PrintUnsignedLong(text, - va_arg(ap, - unsigned - long), - radix, maxlen); -#endif break; } if (do_lowercase) { diff --git a/project/jni/sdl-1.3/src/thread/SDL_systhread.h b/project/jni/sdl-1.3/src/thread/SDL_systhread.h index 584f20db8..6e4dba77b 100644 --- a/project/jni/sdl-1.3/src/thread/SDL_systhread.h +++ b/project/jni/sdl-1.3/src/thread/SDL_systhread.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -41,7 +40,10 @@ extern int SDL_SYS_CreateThread(SDL_Thread * thread, void *args); #endif /* This function does any necessary setup in the child thread */ -extern void SDL_SYS_SetupThread(void); +extern void SDL_SYS_SetupThread(const char *name); + +/* This function sets the current thread priority */ +extern int SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority); /* This function waits for the thread to finish and frees any data allocated by SDL_SYS_CreateThread() diff --git a/project/jni/sdl-1.3/src/thread/SDL_thread.c b/project/jni/sdl-1.3/src/thread/SDL_thread.c index 71a660e83..2f1aeb975 100644 --- a/project/jni/sdl-1.3/src/thread/SDL_thread.c +++ b/project/jni/sdl-1.3/src/thread/SDL_thread.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -27,6 +26,7 @@ #include "SDL_thread.h" #include "SDL_thread_c.h" #include "SDL_systhread.h" +#include "../SDL_error_c.h" #define ARRAY_CHUNKSIZE 32 /* The array of threads currently active in the application @@ -56,6 +56,7 @@ SDL_ThreadsInit(void) clean up threads here. If any threads are still running after this call, they will no longer have access to any per-thread data. */ +#if 0 static void SDL_ThreadsQuit(void) { @@ -67,6 +68,7 @@ SDL_ThreadsQuit(void) SDL_DestroyMutex(mutex); } } +#endif /* Routines for manipulating the thread list */ static void @@ -187,25 +189,19 @@ typedef struct void SDL_RunThread(void *data) { - thread_args *args; - int (SDLCALL * userfunc) (void *); - void *userdata; - int *statusloc; + thread_args *args = (thread_args *) data; + int (SDLCALL * userfunc) (void *) = args->func; + void *userdata = args->data; + int *statusloc = &args->info->status; /* Perform any system-dependent setup - this function cannot fail, and cannot use SDL_SetError() */ - SDL_SYS_SetupThread(); + SDL_SYS_SetupThread(args->info->name); /* Get the thread id */ - args = (thread_args *) data; args->info->threadid = SDL_ThreadID(); - /* Figure out what function to run */ - userfunc = args->func; - userdata = args->data; - statusloc = &args->info->status; - /* Wake up the parent thread */ SDL_SemPost(args->wait); @@ -216,12 +212,14 @@ SDL_RunThread(void *data) #ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD #undef SDL_CreateThread DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(int (SDLCALL * fn) (void *), void *data, +SDL_CreateThread(int (SDLCALL * fn) (void *), + const char *name, void *data, pfnSDL_CurrentBeginThread pfnBeginThread, pfnSDL_CurrentEndThread pfnEndThread) #else DECLSPEC SDL_Thread *SDLCALL -SDL_CreateThread(int (SDLCALL * fn) (void *), void *data) +SDL_CreateThread(int (SDLCALL * fn) (void *), + const char *name, void *data) #endif { SDL_Thread *thread; @@ -237,10 +235,21 @@ SDL_CreateThread(int (SDLCALL * fn) (void *), void *data) SDL_memset(thread, 0, (sizeof *thread)); thread->status = -1; + /* Set up the arguments for the thread */ + if (name != NULL) { + thread->name = SDL_strdup(name); + if (thread->name == NULL) { + SDL_OutOfMemory(); + SDL_free(thread); + return (NULL); + } + } + /* Set up the arguments for the thread */ args = (thread_args *) SDL_malloc(sizeof(*args)); if (args == NULL) { SDL_OutOfMemory(); + SDL_free(thread->name); SDL_free(thread); return (NULL); } @@ -249,6 +258,7 @@ SDL_CreateThread(int (SDLCALL * fn) (void *), void *data) args->info = thread; args->wait = SDL_CreateSemaphore(0); if (args->wait == NULL) { + SDL_free(thread->name); SDL_free(thread); SDL_free(args); return (NULL); @@ -269,6 +279,7 @@ SDL_CreateThread(int (SDLCALL * fn) (void *), void *data) } else { /* Oops, failed. Gotta free everything */ SDL_DelThread(thread); + SDL_free(thread->name); SDL_free(thread); thread = NULL; } @@ -279,19 +290,6 @@ SDL_CreateThread(int (SDLCALL * fn) (void *), void *data) return (thread); } -void -SDL_WaitThread(SDL_Thread * thread, int *status) -{ - if (thread) { - SDL_SYS_WaitThread(thread); - if (status) { - *status = thread->status; - } - SDL_DelThread(thread); - SDL_free(thread); - } -} - SDL_threadID SDL_GetThreadID(SDL_Thread * thread) { @@ -305,4 +303,30 @@ SDL_GetThreadID(SDL_Thread * thread) return id; } +const char * +SDL_GetThreadName(SDL_Thread * thread) +{ + return thread->name; +} + +int +SDL_SetThreadPriority(SDL_ThreadPriority priority) +{ + return SDL_SYS_SetThreadPriority(priority); +} + +void +SDL_WaitThread(SDL_Thread * thread, int *status) +{ + if (thread) { + SDL_SYS_WaitThread(thread); + if (status) { + *status = thread->status; + } + SDL_DelThread(thread); + SDL_free(thread->name); + SDL_free(thread); + } +} + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/SDL_thread_c.h b/project/jni/sdl-1.3/src/thread/SDL_thread_c.h index 7f4b8888e..08ebd7bc8 100644 --- a/project/jni/sdl-1.3/src/thread/SDL_thread_c.h +++ b/project/jni/sdl-1.3/src/thread/SDL_thread_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -33,10 +32,8 @@ #include "epoc/SDL_systhread_c.h" #elif SDL_THREAD_PTHREAD #include "pthread/SDL_systhread_c.h" -#elif SDL_THREAD_SPROC -#include "irix/SDL_systhread_c.h" -#elif SDL_THREAD_WIN32 -#include "win32/SDL_systhread_c.h" +#elif SDL_THREAD_WINDOWS +#include "windows/SDL_systhread_c.h" #elif SDL_THREAD_NDS #include "nds/SDL_systhread_c.h" #else @@ -52,6 +49,7 @@ struct SDL_Thread SYS_ThreadHandle handle; int status; SDL_error errbuf; + char *name; void *data; }; @@ -59,4 +57,5 @@ struct SDL_Thread extern void SDL_RunThread(void *data); #endif /* _SDL_thread_c_h */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/beos/SDL_syssem.c b/project/jni/sdl-1.3/src/thread/beos/SDL_syssem.c index 8c39d7b88..afaccaf1a 100644 --- a/project/jni/sdl-1.3/src/thread/beos/SDL_syssem.c +++ b/project/jni/sdl-1.3/src/thread/beos/SDL_syssem.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#ifdef SDL_THREAD_BEOS + /* Semaphores in the BeOS environment */ #include @@ -149,4 +150,6 @@ SDL_SemPost(SDL_sem * sem) return 0; } +#endif /* SDL_THREAD_BEOS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/beos/SDL_systhread.c b/project/jni/sdl-1.3/src/thread/beos/SDL_systhread.c index 187d94fa3..ff255ff76 100644 --- a/project/jni/sdl-1.3/src/thread/beos/SDL_systhread.c +++ b/project/jni/sdl-1.3/src/thread/beos/SDL_systhread.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#ifdef SDL_THREAD_BEOS + /* BeOS thread management routines for SDL */ #include @@ -66,8 +67,14 @@ RunThread(void *data) int SDL_SYS_CreateThread(SDL_Thread * thread, void *args) { + /* The docs say the thread name can't be longer than B_OS_NAME_LENGTH. */ + const char *threadname = thread->name ? thread->name : "SDL Thread"; + char name[B_OS_NAME_LENGTH]; + SDL_snprintf(name, sizeof (name), "%s", threadname); + name[sizeof (name) - 1] = '\0'; + /* Create the thread and go! */ - thread->handle = spawn_thread(RunThread, "SDL", B_NORMAL_PRIORITY, args); + thread->handle = spawn_thread(RunThread, name, B_NORMAL_PRIORITY, args); if ((thread->handle == B_NO_MORE_THREADS) || (thread->handle == B_NO_MEMORY)) { SDL_SetError("Not enough resources to create thread"); @@ -78,8 +85,9 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) } void -SDL_SYS_SetupThread(void) +SDL_SYS_SetupThread(const char *name) { + /* We set the thread name during SDL_SYS_CreateThread(). */ /* Mask asynchronous signals for this thread */ SDL_MaskSignals(NULL); } @@ -90,6 +98,22 @@ SDL_ThreadID(void) return ((SDL_threadID) find_thread(NULL)); } +int +SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +{ + int32 value; + + if (priority == SDL_THREAD_PRIORITY_LOW) { + value = B_LOW_PRIORITY; + } else if (priority == SDL_THREAD_PRIORITY_HIGH) { + value = B_URGENT_DISPLAY_PRIORITY; + } else { + value = B_NORMAL_PRIORITY; + } + set_thread_priority(find_thread(NULL), value); + return 0; +} + void SDL_SYS_WaitThread(SDL_Thread * thread) { @@ -98,4 +122,6 @@ SDL_SYS_WaitThread(SDL_Thread * thread) wait_for_thread(thread->handle, &the_status); } +#endif /* SDL_THREAD_BEOS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/beos/SDL_systhread_c.h b/project/jni/sdl-1.3/src/thread/beos/SDL_systhread_c.h index 587c8f5c8..f1cc8d570 100644 --- a/project/jni/sdl-1.3/src/thread/beos/SDL_systhread_c.h +++ b/project/jni/sdl-1.3/src/thread/beos/SDL_systhread_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/thread/generic/SDL_syscond.c b/project/jni/sdl-1.3/src/thread/generic/SDL_syscond.c index d2db76949..eeec26ebd 100644 --- a/project/jni/sdl-1.3/src/thread/generic/SDL_syscond.c +++ b/project/jni/sdl-1.3/src/thread/generic/SDL_syscond.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -145,18 +144,19 @@ SDL_CondBroadcast(SDL_cond * cond) Typical use: Thread A: - SDL_LockMutex(lock); - while ( ! condition ) { - SDL_CondWait(cond); - } - SDL_UnlockMutex(lock); + SDL_LockMutex(lock); + while ( ! condition ) { + SDL_CondWait(cond, lock); + } + SDL_UnlockMutex(lock); Thread B: - SDL_LockMutex(lock); - ... - condition = true; - ... - SDL_UnlockMutex(lock); + SDL_LockMutex(lock); + ... + condition = true; + ... + SDL_CondSignal(cond); + SDL_UnlockMutex(lock); */ int SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) diff --git a/project/jni/sdl-1.3/src/thread/generic/SDL_sysmutex.c b/project/jni/sdl-1.3/src/thread/generic/SDL_sysmutex.c index 115499be8..b2d3fb71b 100644 --- a/project/jni/sdl-1.3/src/thread/generic/SDL_sysmutex.c +++ b/project/jni/sdl-1.3/src/thread/generic/SDL_sysmutex.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/thread/generic/SDL_sysmutex_c.h b/project/jni/sdl-1.3/src/thread/generic/SDL_sysmutex_c.h index b1e2af9f7..998229c95 100644 --- a/project/jni/sdl-1.3/src/thread/generic/SDL_sysmutex_c.h +++ b/project/jni/sdl-1.3/src/thread/generic/SDL_sysmutex_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/generic/SDL_syssem.c b/project/jni/sdl-1.3/src/thread/generic/SDL_syssem.c index 92a0ea85b..5219a4433 100644 --- a/project/jni/sdl-1.3/src/thread/generic/SDL_syssem.c +++ b/project/jni/sdl-1.3/src/thread/generic/SDL_syssem.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/thread/generic/SDL_systhread.c b/project/jni/sdl-1.3/src/thread/generic/SDL_systhread.c index ffb17df06..ecab2909f 100644 --- a/project/jni/sdl-1.3/src/thread/generic/SDL_systhread.c +++ b/project/jni/sdl-1.3/src/thread/generic/SDL_systhread.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -34,7 +33,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) } void -SDL_SYS_SetupThread(void) +SDL_SYS_SetupThread(const char *name) { return; } @@ -45,6 +44,12 @@ SDL_ThreadID(void) return (0); } +int +SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +{ + return (0); +} + void SDL_SYS_WaitThread(SDL_Thread * thread) { diff --git a/project/jni/sdl-1.3/src/thread/generic/SDL_systhread_c.h b/project/jni/sdl-1.3/src/thread/generic/SDL_systhread_c.h index 9807b0930..3287f9357 100644 --- a/project/jni/sdl-1.3/src/thread/generic/SDL_systhread_c.h +++ b/project/jni/sdl-1.3/src/thread/generic/SDL_systhread_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/thread/irix/SDL_syssem.c b/project/jni/sdl-1.3/src/thread/irix/SDL_syssem.c deleted file mode 100644 index e83a65ed4..000000000 --- a/project/jni/sdl-1.3/src/thread/irix/SDL_syssem.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_thread.h" -#include "SDL_timer.h" - - -#include -#include -#include -#include -#include -#include - -#include "SDL_error.h" -#include "SDL_thread.h" - - -struct SDL_semaphore -{ - int id; -}; - -/* Not defined by many operating systems, use configure to detect */ -/* -#if !defined(HAVE_SEMUN) -union semun { - int val; - struct semid_ds *buf; - ushort *array; -}; -#endif -*/ - -static struct sembuf op_trywait[2] = { - {0, -1, (IPC_NOWAIT | SEM_UNDO)} /* Decrement semaphore, no block */ -}; - -static struct sembuf op_wait[2] = { - {0, -1, SEM_UNDO} /* Decrement semaphore */ -}; - -static struct sembuf op_post[1] = { - {0, 1, (IPC_NOWAIT | SEM_UNDO)} /* Increment semaphore */ -}; - -/* Create a blockable semaphore */ -SDL_sem * -SDL_CreateSemaphore(Uint32 initial_value) -{ - extern int _creating_thread_lock; /* SDL_threads.c */ - SDL_sem *sem; - union semun init; - - sem = (SDL_sem *) SDL_malloc(sizeof(*sem)); - if (sem == NULL) { - SDL_OutOfMemory(); - return (NULL); - } - sem->id = semget(IPC_PRIVATE, 1, (0600 | IPC_CREAT)); - if (sem->id < 0) { - SDL_SetError("Couldn't create semaphore"); - SDL_free(sem); - return (NULL); - } - init.val = initial_value; /* Initialize semaphore */ - semctl(sem->id, 0, SETVAL, init); - return (sem); -} - -void -SDL_DestroySemaphore(SDL_sem * sem) -{ - if (sem) { -#ifdef __IRIX__ - semctl(sem->id, 0, IPC_RMID); -#else - union semun dummy; - dummy.val = 0; - semctl(sem->id, 0, IPC_RMID, dummy); -#endif - SDL_free(sem); - } -} - -int -SDL_SemTryWait(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - retval = 0; - tryagain: - if (semop(sem->id, op_trywait, 1) < 0) { - if (errno == EINTR) { - goto tryagain; - } - retval = SDL_MUTEX_TIMEDOUT; - } - return retval; -} - -int -SDL_SemWait(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - retval = 0; - tryagain: - if (semop(sem->id, op_wait, 1) < 0) { - if (errno == EINTR) { - goto tryagain; - } - SDL_SetError("Semaphore operation error"); - retval = -1; - } - return retval; -} - -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - /* Try the easy cases first */ - if (timeout == 0) { - return SDL_SemTryWait(sem); - } - if (timeout == SDL_MUTEX_MAXWAIT) { - return SDL_SemWait(sem); - } - - /* Ack! We have to busy wait... */ - timeout += SDL_GetTicks(); - do { - retval = SDL_SemTryWait(sem); - if (retval == 0) { - break; - } - SDL_Delay(1); - } while (SDL_GetTicks() < timeout); - - return retval; -} - -Uint32 -SDL_SemValue(SDL_sem * sem) -{ - int semval; - Uint32 value; - - value = 0; - if (sem) { - tryagain: -#ifdef __IRIX__ - semval = semctl(sem->id, 0, GETVAL); -#else - { - union semun arg; - arg.val = 0; - semval = semctl(sem->id, 0, GETVAL, arg); - } -#endif - if (semval < 0) { - if (errno == EINTR) { - goto tryagain; - } - } else { - value = (Uint32) semval; - } - } - return value; -} - -int -SDL_SemPost(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - retval = 0; - tryagain: - if (semop(sem->id, op_post, 1) < 0) { - if (errno == EINTR) { - goto tryagain; - } - SDL_SetError("Semaphore operation error"); - retval = -1; - } - return retval; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/irix/SDL_systhread.c b/project/jni/sdl-1.3/src/thread/irix/SDL_systhread.c deleted file mode 100644 index b75ed3030..000000000 --- a/project/jni/sdl-1.3/src/thread/irix/SDL_systhread.c +++ /dev/null @@ -1,82 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* IRIX thread management routines for SDL */ - -#include -#include -#include -#include -#include - -#include "SDL_thread.h" -#include "../SDL_systhread.h" - - -static int sig_list[] = { - SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCLD, SIGWINCH, - SIGVTALRM, SIGPROF, 0 -}; - - -int -SDL_SYS_CreateThread(SDL_Thread * thread, void *args) -{ - /* Create the thread and go! */ - if (sproc(SDL_RunThread, PR_SALL, args) < 0) { - SDL_SetError("Not enough resources to create thread"); - return (-1); - } - return (0); -} - -void -SDL_SYS_SetupThread(void) -{ - int i; - sigset_t mask; - - /* Mask asynchronous signals for this thread */ - sigemptyset(&mask); - for (i = 0; sig_list[i]; ++i) { - sigaddset(&mask, sig_list[i]); - } - sigprocmask(SIG_BLOCK, &mask, NULL); -} - -SDL_threadID -SDL_ThreadID(void) -{ - return ((SDL_threadID) getpid()); -} - -void -SDL_WaitThread(SDL_Thread * thread, int *status) -{ - errno = 0; - while (errno != ECHILD) { - waitpid(thread->handle, NULL, 0); - } -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/irix/SDL_systhread_c.h b/project/jni/sdl-1.3/src/thread/irix/SDL_systhread_c.h deleted file mode 100644 index e2815eda3..000000000 --- a/project/jni/sdl-1.3/src/thread/irix/SDL_systhread_c.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include - -typedef pid_t SYS_ThreadHandle; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/nds/SDL_syscond.c b/project/jni/sdl-1.3/src/thread/nds/SDL_syscond.c index 7b4a515de..0892b1e70 100644 --- a/project/jni/sdl-1.3/src/thread/nds/SDL_syscond.c +++ b/project/jni/sdl-1.3/src/thread/nds/SDL_syscond.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifdef SAVE_RCSID @@ -227,3 +226,5 @@ SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) { return SDL_CondWaitTimeout(cond, mutex, SDL_MUTEX_MAXWAIT); } + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/nds/SDL_syscond_c.h b/project/jni/sdl-1.3/src/thread/nds/SDL_syscond_c.h index ce7faa515..cfa68e05a 100644 --- a/project/jni/sdl-1.3/src/thread/nds/SDL_syscond_c.h +++ b/project/jni/sdl-1.3/src/thread/nds/SDL_syscond_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifdef SAVE_RCSID diff --git a/project/jni/sdl-1.3/src/thread/nds/SDL_sysmutex.c b/project/jni/sdl-1.3/src/thread/nds/SDL_sysmutex.c index 01f2a46da..6096a8934 100644 --- a/project/jni/sdl-1.3/src/thread/nds/SDL_sysmutex.c +++ b/project/jni/sdl-1.3/src/thread/nds/SDL_sysmutex.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifdef SAVE_RCSID @@ -140,3 +139,5 @@ SDL_mutexV(SDL_mutex * mutex) return 0; #endif /* DISABLE_THREADS */ } + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/nds/SDL_sysmutex_c.h b/project/jni/sdl-1.3/src/thread/nds/SDL_sysmutex_c.h index 77545b79f..24ed63ea6 100644 --- a/project/jni/sdl-1.3/src/thread/nds/SDL_sysmutex_c.h +++ b/project/jni/sdl-1.3/src/thread/nds/SDL_sysmutex_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifdef SAVE_RCSID diff --git a/project/jni/sdl-1.3/src/thread/nds/SDL_syssem.c b/project/jni/sdl-1.3/src/thread/nds/SDL_syssem.c index 9da8da562..93593d4b8 100644 --- a/project/jni/sdl-1.3/src/thread/nds/SDL_syssem.c +++ b/project/jni/sdl-1.3/src/thread/nds/SDL_syssem.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifdef SAVE_RCSID @@ -226,3 +225,5 @@ SDL_SemPost(SDL_sem * sem) } #endif /* DISABLE_THREADS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/nds/SDL_syssem_c.h b/project/jni/sdl-1.3/src/thread/nds/SDL_syssem_c.h index d1764b1dd..8c6c75ba6 100644 --- a/project/jni/sdl-1.3/src/thread/nds/SDL_syssem_c.h +++ b/project/jni/sdl-1.3/src/thread/nds/SDL_syssem_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifdef SAVE_RCSID diff --git a/project/jni/sdl-1.3/src/thread/nds/SDL_systhread.c b/project/jni/sdl-1.3/src/thread/nds/SDL_systhread.c index 299ad0b47..0355db870 100644 --- a/project/jni/sdl-1.3/src/thread/nds/SDL_systhread.c +++ b/project/jni/sdl-1.3/src/thread/nds/SDL_systhread.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifdef SAVE_RCSID @@ -29,7 +28,7 @@ static char rcsid = #include "SDL_error.h" #include "SDL_thread.h" -#include "SDL_systhread.h" +#include "../SDL_systhread.h" int SDL_SYS_CreateThread(SDL_Thread * thread, void *args) @@ -39,7 +38,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) } void -SDL_SYS_SetupThread(void) +SDL_SYS_SetupThread(const char *name) { return; } @@ -56,8 +55,10 @@ SDL_SYS_WaitThread(SDL_Thread * thread) return; } -void -SDL_SYS_KillThread(SDL_Thread * thread) +int +SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) { - return; + return (0); } + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/nds/SDL_systhread_c.h b/project/jni/sdl-1.3/src/thread/nds/SDL_systhread_c.h index e252b8c0e..d02b54b14 100644 --- a/project/jni/sdl-1.3/src/thread/nds/SDL_systhread_c.h +++ b/project/jni/sdl-1.3/src/thread/nds/SDL_systhread_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /* Stub until we implement threads on this platform */ diff --git a/project/jni/sdl-1.3/src/thread/pthread/SDL_syscond.c b/project/jni/sdl-1.3/src/thread/pthread/SDL_syscond.c index 547daa717..9d9bb0979 100644 --- a/project/jni/sdl-1.3/src/thread/pthread/SDL_syscond.c +++ b/project/jni/sdl-1.3/src/thread/pthread/SDL_syscond.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/thread/pthread/SDL_sysmutex.c b/project/jni/sdl-1.3/src/thread/pthread/SDL_sysmutex.c index a6249b436..6d273d74b 100644 --- a/project/jni/sdl-1.3/src/thread/pthread/SDL_sysmutex.c +++ b/project/jni/sdl-1.3/src/thread/pthread/SDL_sysmutex.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -28,7 +27,7 @@ #if !SDL_THREAD_PTHREAD_RECURSIVE_MUTEX && \ !SDL_THREAD_PTHREAD_RECURSIVE_MUTEX_NP -#define FAKE_RECURSIVE_MUTEX +#define FAKE_RECURSIVE_MUTEX 1 #endif struct SDL_mutex diff --git a/project/jni/sdl-1.3/src/thread/pthread/SDL_sysmutex_c.h b/project/jni/sdl-1.3/src/thread/pthread/SDL_sysmutex_c.h index e28b11903..f14697501 100644 --- a/project/jni/sdl-1.3/src/thread/pthread/SDL_sysmutex_c.h +++ b/project/jni/sdl-1.3/src/thread/pthread/SDL_sysmutex_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/thread/pthread/SDL_syssem.c b/project/jni/sdl-1.3/src/thread/pthread/SDL_syssem.c index 0e0feaf40..9940c5f27 100644 --- a/project/jni/sdl-1.3/src/thread/pthread/SDL_syssem.c +++ b/project/jni/sdl-1.3/src/thread/pthread/SDL_syssem.c @@ -1,28 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#include #include #include +#include #include "SDL_thread.h" #include "SDL_timer.h" @@ -102,6 +103,8 @@ int SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) { int retval; + struct timeval now; + struct timespec ts_timeout; if (!sem) { SDL_SetError("Passed a NULL semaphore"); @@ -116,16 +119,34 @@ SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) return SDL_SemWait(sem); } - /* Ack! We have to busy wait... */ - /* FIXME: Use sem_timedwait()? */ - timeout += SDL_GetTicks(); + /* Setup the timeout. sem_timedwait doesn't wait for + * a lapse of time, but until we reach a certain time. + * This time is now plus the timeout. + */ + gettimeofday(&now, NULL); + + /* Add our timeout to current time */ + now.tv_usec += (timeout % 1000) * 1000; + now.tv_sec += timeout / 1000; + + /* Wrap the second if needed */ + if ( now.tv_usec >= 1000000 ) { + now.tv_usec -= 1000000; + now.tv_sec ++; + } + + /* Convert to timespec */ + ts_timeout.tv_sec = now.tv_sec; + ts_timeout.tv_nsec = now.tv_usec * 1000; + + /* Wait. */ do { - retval = SDL_SemTryWait(sem); - if (retval == 0) { - break; - } - SDL_Delay(1); - } while (SDL_GetTicks() < timeout); + retval = sem_timedwait(&sem->sem, &ts_timeout); + } while (retval < 0 && errno == EINTR); + + if (retval < 0) { + SDL_SetError("sem_timedwait() failed"); + } return retval; } diff --git a/project/jni/sdl-1.3/src/thread/pthread/SDL_systhread.c b/project/jni/sdl-1.3/src/thread/pthread/SDL_systhread.c index c4f694fbe..ef4bc2c5a 100644 --- a/project/jni/sdl-1.3/src/thread/pthread/SDL_systhread.c +++ b/project/jni/sdl-1.3/src/thread/pthread/SDL_systhread.c @@ -1,29 +1,42 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ + #include "SDL_config.h" #include -#include +#if HAVE_PTHREAD_NP_H +#include +#endif + +#include +#ifdef __LINUX__ +#include +#include +#include +#include +extern int pthread_setname_np (pthread_t __target_thread, __const char *__name) __THROW __nonnull ((2)); +#endif + +#include "SDL_platform.h" #include "SDL_thread.h" #include "../SDL_thread_c.h" #include "../SDL_systhread.h" @@ -34,20 +47,12 @@ static const int sig_list[] = { SIGVTALRM, SIGPROF, 0 }; -#ifdef __RISCOS__ -/* RISC OS needs to know the main thread for - * it's timer and event processing. */ -int riscos_using_threads = 0; -SDL_threadID riscos_main_thread = 0; /* Thread running events */ -#endif - static void * RunThread(void *data) { SDL_RunThread(data); - pthread_exit((void *) 0); - return ((void *) 0); /* Prevent compiler warning */ + return NULL; } int @@ -67,22 +72,27 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args) SDL_SetError("Not enough resources to create thread"); return (-1); } -#ifdef __RISCOS__ - if (riscos_using_threads == 0) { - riscos_using_threads = 1; - riscos_main_thread = SDL_ThreadID(); - } -#endif return (0); } void -SDL_SYS_SetupThread(void) +SDL_SYS_SetupThread(const char *name) { int i; sigset_t mask; + if (name != NULL) { +#if ( (__MACOSX__ && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1060)) || \ + (__IPHONEOS__ && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 30200)) ) + if (pthread_setname_np != NULL) { pthread_setname_np(name); } +#elif HAVE_PTHREAD_SETNAME_NP + pthread_setname_np(pthread_self(), name); +#elif HAVE_PTHREAD_SET_NAME_NP + pthread_set_name_np(pthread_self(), name); +#endif + } + /* Mask asynchronous signals for this thread */ sigemptyset(&mask); for (i = 0; sig_list[i]; ++i) { @@ -105,6 +115,53 @@ SDL_ThreadID(void) return ((SDL_threadID) pthread_self()); } +int +SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +{ +#ifdef __LINUX__ + int value; + + if (priority == SDL_THREAD_PRIORITY_LOW) { + value = 19; + } else if (priority == SDL_THREAD_PRIORITY_HIGH) { + value = -20; + } else { + value = 0; + } + if (setpriority(PRIO_PROCESS, syscall(SYS_gettid), value) < 0) { + /* Note that this fails if you're trying to set high priority + and you don't have root permission. BUT DON'T RUN AS ROOT! + */ + SDL_SetError("setpriority() failed"); + return -1; + } + return 0; +#else + struct sched_param sched; + int policy; + pthread_t thread = pthread_self(); + + if (pthread_getschedparam(thread, &policy, &sched) < 0) { + SDL_SetError("pthread_getschedparam() failed"); + return -1; + } + if (priority == SDL_THREAD_PRIORITY_LOW) { + sched.sched_priority = sched_get_priority_min(policy); + } else if (priority == SDL_THREAD_PRIORITY_HIGH) { + sched.sched_priority = sched_get_priority_max(policy); + } else { + int min_priority = sched_get_priority_min(policy); + int max_priority = sched_get_priority_max(policy); + sched.sched_priority = (min_priority + (max_priority - min_priority) / 2); + } + if (pthread_setschedparam(thread, policy, &sched) < 0) { + SDL_SetError("pthread_setschedparam() failed"); + return -1; + } + return 0; +#endif /* linux */ +} + void SDL_SYS_WaitThread(SDL_Thread * thread) { diff --git a/project/jni/sdl-1.3/src/thread/pthread/SDL_systhread_c.h b/project/jni/sdl-1.3/src/thread/pthread/SDL_systhread_c.h index 8da81da17..2cba5fe77 100644 --- a/project/jni/sdl-1.3/src/thread/pthread/SDL_systhread_c.h +++ b/project/jni/sdl-1.3/src/thread/pthread/SDL_systhread_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/thread/riscos/SDL_syscond.c b/project/jni/sdl-1.3/src/thread/riscos/SDL_syscond.c deleted file mode 100644 index 4182fa3ca..000000000 --- a/project/jni/sdl-1.3/src/thread/riscos/SDL_syscond.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* RISC OS implementations uses pthreads based on linux code */ - -#if SDL_THREADS_DISABLED -#include "../generic/SDL_syscond.c" -#else -#include -#include -#include - -#include "SDL_thread.h" -#include "SDL_sysmutex_c.h" - -struct SDL_cond -{ - pthread_cond_t cond; -}; - -/* Create a condition variable */ -SDL_cond * -SDL_CreateCond(void) -{ - SDL_cond *cond; - - cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond)); - if (cond) { - if (pthread_cond_init(&cond->cond, NULL) < 0) { - SDL_SetError("pthread_cond_init() failed"); - SDL_free(cond); - cond = NULL; - } - } - return (cond); -} - -/* Destroy a condition variable */ -void -SDL_DestroyCond(SDL_cond * cond) -{ - if (cond) { - pthread_cond_destroy(&cond->cond); - SDL_free(cond); - } -} - -/* Restart one of the threads that are waiting on the condition variable */ -int -SDL_CondSignal(SDL_cond * cond) -{ - int retval; - - if (!cond) { - SDL_SetError("Passed a NULL condition variable"); - return -1; - } - - retval = 0; - if (pthread_cond_signal(&cond->cond) != 0) { - SDL_SetError("pthread_cond_signal() failed"); - retval = -1; - } - return retval; -} - -/* Restart all threads that are waiting on the condition variable */ -int -SDL_CondBroadcast(SDL_cond * cond) -{ - int retval; - - if (!cond) { - SDL_SetError("Passed a NULL condition variable"); - return -1; - } - - retval = 0; - if (pthread_cond_broadcast(&cond->cond) != 0) { - SDL_SetError("pthread_cond_broadcast() failed"); - retval = -1; - } - return retval; -} - -int -SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms) -{ - int retval; - struct timeval delta; - struct timespec abstime; - - if (!cond) { - SDL_SetError("Passed a NULL condition variable"); - return -1; - } - - gettimeofday(&delta, NULL); - - abstime.tv_sec = delta.tv_sec + (ms / 1000); - abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000; - if (abstime.tv_nsec > 1000000000) { - abstime.tv_sec += 1; - abstime.tv_nsec -= 1000000000; - } - - tryagain: - retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime); - switch (retval) { - case EINTR: - goto tryagain; - break; - case ETIMEDOUT: - retval = SDL_MUTEX_TIMEDOUT; - break; - case 0: - break; - default: - SDL_SetError("pthread_cond_timedwait() failed"); - retval = -1; - break; - } - return retval; -} - -/* Wait on the condition variable, unlocking the provided mutex. - The mutex must be locked before entering this function! - */ -int -SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex) -{ - int retval; - - if (!cond) { - SDL_SetError("Passed a NULL condition variable"); - return -1; - } - - retval = 0; - if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) { - SDL_SetError("pthread_cond_wait() failed"); - retval = -1; - } - return retval; -} -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/riscos/SDL_sysmutex.c b/project/jni/sdl-1.3/src/thread/riscos/SDL_sysmutex.c deleted file mode 100644 index c4d842b94..000000000 --- a/project/jni/sdl-1.3/src/thread/riscos/SDL_sysmutex.c +++ /dev/null @@ -1,159 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* RISC OS implementations uses pthreads based on linux code */ - -#include "SDL_thread.h" - -#if SDL_THREADS_DISABLED -#include "../generic/SDL_sysmutex.c" -#else - -#include - -struct SDL_mutex -{ - pthread_mutex_t id; -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX - int recursive; - pthread_t owner; -#endif -}; - -SDL_mutex * -SDL_CreateMutex(void) -{ - SDL_mutex *mutex; - pthread_mutexattr_t attr; - - /* Allocate the structure */ - mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex)); - if (mutex) { - pthread_mutexattr_init(&attr); -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX - /* No extra attributes necessary */ -#else - pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); -#endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */ - if (pthread_mutex_init(&mutex->id, &attr) != 0) { - SDL_SetError("pthread_mutex_init() failed"); - SDL_free(mutex); - mutex = NULL; - } - } else { - SDL_OutOfMemory(); - } - return (mutex); -} - -void -SDL_DestroyMutex(SDL_mutex * mutex) -{ - if (mutex) { - pthread_mutex_destroy(&mutex->id); - SDL_free(mutex); - } -} - -/* Lock the mutex */ -int -SDL_mutexP(SDL_mutex * mutex) -{ - int retval; -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX - pthread_t this_thread; -#endif - - if (mutex == NULL) { - SDL_SetError("Passed a NULL mutex"); - return -1; - } - - retval = 0; -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX - this_thread = pthread_self(); - if (mutex->owner == this_thread) { - ++mutex->recursive; - } else { - /* The order of operations is important. - We set the locking thread id after we obtain the lock - so unlocks from other threads will fail. - */ - if (pthread_mutex_lock(&mutex->id) == 0) { - mutex->owner = this_thread; - mutex->recursive = 0; - } else { - SDL_SetError("pthread_mutex_lock() failed"); - retval = -1; - } - } -#else - if (pthread_mutex_lock(&mutex->id) < 0) { - SDL_SetError("pthread_mutex_lock() failed"); - retval = -1; - } -#endif - return retval; -} - -int -SDL_mutexV(SDL_mutex * mutex) -{ - int retval; - - if (mutex == NULL) { - SDL_SetError("Passed a NULL mutex"); - return -1; - } - - retval = 0; -#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX - /* We can only unlock the mutex if we own it */ - if (pthread_self() == mutex->owner) { - if (mutex->recursive) { - --mutex->recursive; - } else { - /* The order of operations is important. - First reset the owner so another thread doesn't lock - the mutex and set the ownership before we reset it, - then release the lock semaphore. - */ - mutex->owner = 0; - pthread_mutex_unlock(&mutex->id); - } - } else { - SDL_SetError("mutex not owned by this thread"); - retval = -1; - } - -#else - if (pthread_mutex_unlock(&mutex->id) < 0) { - SDL_SetError("pthread_mutex_unlock() failed"); - retval = -1; - } -#endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */ - - return retval; -} -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/riscos/SDL_sysmutex_c.h b/project/jni/sdl-1.3/src/thread/riscos/SDL_sysmutex_c.h deleted file mode 100644 index 25d8e2cfb..000000000 --- a/project/jni/sdl-1.3/src/thread/riscos/SDL_sysmutex_c.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_mutex_c_h -#define _SDL_mutex_c_h - -#if !SDL_THREADS_DISABLED -struct SDL_mutex -{ - pthread_mutex_t id; -}; -#endif - - -#endif /* _SDL_mutex_c_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/riscos/SDL_syssem.c b/project/jni/sdl-1.3/src/thread/riscos/SDL_syssem.c deleted file mode 100644 index ab481776d..000000000 --- a/project/jni/sdl-1.3/src/thread/riscos/SDL_syssem.c +++ /dev/null @@ -1,216 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* RISC OS semiphores based on linux code */ - - -#include "SDL_timer.h" -#include "SDL_thread.h" -#include "SDL_systhread_c.h" - -#if !SDL_THREADS_DISABLED - -SDL_sem * -SDL_CreateSemaphore(Uint32 initial_value) -{ - SDL_SetError("SDL not configured with thread support"); - return (SDL_sem *) 0; -} - -void -SDL_DestroySemaphore(SDL_sem * sem) -{ - return; -} - -int -SDL_SemTryWait(SDL_sem * sem) -{ - SDL_SetError("SDL not configured with thread support"); - return -1; -} - -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) -{ - SDL_SetError("SDL not configured with thread support"); - return -1; -} - -int -SDL_SemWait(SDL_sem * sem) -{ - SDL_SetError("SDL not configured with thread support"); - return -1; -} - -Uint32 -SDL_SemValue(SDL_sem * sem) -{ - return 0; -} - -int -SDL_SemPost(SDL_sem * sem) -{ - SDL_SetError("SDL not configured with thread support"); - return -1; -} - -#else - - -#include /* For getpid() */ -#include -#include - -struct SDL_semaphore -{ - sem_t *sem; - sem_t sem_data; -}; - -/* Create a semaphore, initialized with value */ -SDL_sem * -SDL_CreateSemaphore(Uint32 initial_value) -{ - SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem)); - if (sem) { - if (sem_init(&sem->sem_data, 0, initial_value) < 0) { - SDL_SetError("sem_init() failed"); - SDL_free(sem); - sem = NULL; - } else { - sem->sem = &sem->sem_data; - } - } else { - SDL_OutOfMemory(); - } - return sem; -} - -void -SDL_DestroySemaphore(SDL_sem * sem) -{ - if (sem) { - sem_destroy(sem->sem); - SDL_free(sem); - } -} - -int -SDL_SemTryWait(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - retval = SDL_MUTEX_TIMEDOUT; - if (sem_trywait(sem->sem) == 0) { - retval = 0; - } - return retval; -} - -int -SDL_SemWait(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - retval = sem_wait(sem->sem); - if (retval < 0) { - SDL_SetError("sem_wait() failed"); - } - return retval; -} - -int -SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - /* Try the easy cases first */ - if (timeout == 0) { - return SDL_SemTryWait(sem); - } - if (timeout == SDL_MUTEX_MAXWAIT) { - return SDL_SemWait(sem); - } - - /* Ack! We have to busy wait... */ - timeout += SDL_GetTicks(); - do { - retval = SDL_SemTryWait(sem); - if (retval == 0) { - break; - } - SDL_Delay(1); - } while (SDL_GetTicks() < timeout); - - return retval; -} - -Uint32 -SDL_SemValue(SDL_sem * sem) -{ - int ret = 0; - if (sem) { - sem_getvalue(sem->sem, &ret); - if (ret < 0) { - ret = 0; - } - } - return (Uint32) ret; -} - -int -SDL_SemPost(SDL_sem * sem) -{ - int retval; - - if (!sem) { - SDL_SetError("Passed a NULL semaphore"); - return -1; - } - - retval = sem_post(sem->sem); - if (retval < 0) { - SDL_SetError("sem_post() failed"); - } - return retval; -} - -#endif /* !SDL_THREADS_DISABLED */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/riscos/SDL_systhread.c b/project/jni/sdl-1.3/src/thread/riscos/SDL_systhread.c deleted file mode 100644 index 8940f2286..000000000 --- a/project/jni/sdl-1.3/src/thread/riscos/SDL_systhread.c +++ /dev/null @@ -1,141 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* RISC OS version based on pthreads linux source */ - -#include "SDL_thread.h" -#include "../SDL_systhread.h" - -#if SDL_THREADS_DISABLED - -int -SDL_SYS_CreateThread(SDL_Thread * thread, void *args) -{ - SDL_SetError - ("Threads have not been compiled into this version of the library"); - return (-1); -} - -void -SDL_SYS_SetupThread(void) -{ - return; -} - -SDL_threadID -SDL_ThreadID(void) -{ - return (0); -} - -void -SDL_SYS_WaitThread(SDL_Thread * thread) -{ - return; -} - -#else - -#include - -/* List of signals to mask in the subthreads */ -static int sig_list[] = { - SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH, - SIGVTALRM, SIGPROF, 0 -}; - -#include - -int riscos_using_threads = 0; -Uint32 riscos_main_thread = 0; /* Thread running events */ - -static void * -RunThread(void *data) -{ - SDL_RunThread(data); - pthread_exit((void *) 0); - return ((void *) 0); /* Prevent compiler warning */ -} - -int -SDL_SYS_CreateThread(SDL_Thread * thread, void *args) -{ - pthread_attr_t type; - - /* Set the thread attributes */ - if (pthread_attr_init(&type) != 0) { - SDL_SetError("Couldn't initialize pthread attributes"); - return (-1); - } - pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE); - - /* Create the thread and go! */ - if (pthread_create(&thread->handle, &type, RunThread, args) != 0) { - SDL_SetError("Not enough resources to create thread"); - return (-1); - } - - if (riscos_using_threads == 0) { - riscos_using_threads = 1; - riscos_main_thread = SDL_ThreadID(); - } - - return (0); -} - -void -SDL_SYS_SetupThread(void) -{ - int i; - sigset_t mask; - - /* Mask asynchronous signals for this thread */ - sigemptyset(&mask); - for (i = 0; sig_list[i]; ++i) { - sigaddset(&mask, sig_list[i]); - } - pthread_sigmask(SIG_BLOCK, &mask, 0); - -#ifdef PTHREAD_CANCEL_ASYNCHRONOUS - /* Allow ourselves to be asynchronously cancelled */ - { - int oldstate; - pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate); - } -#endif -} - -Uint32 -SDL_ThreadID(void) -{ - return ((Uint32) pthread_self()); -} - -void -SDL_SYS_WaitThread(SDL_Thread * thread) -{ - pthread_join(thread->handle, 0); -} - -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/riscos/SDL_systhread_c.h b/project/jni/sdl-1.3/src/thread/riscos/SDL_systhread_c.h deleted file mode 100644 index 752af0f05..000000000 --- a/project/jni/sdl-1.3/src/thread/riscos/SDL_systhread_c.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#if SDL_THREADS_DISABLED - -typedef int SYS_ThreadHandle; - -#else - -#include - -typedef pthread_t SYS_ThreadHandle; - -#endif - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/win32/SDL_sysmutex.c b/project/jni/sdl-1.3/src/thread/win32/SDL_sysmutex.c deleted file mode 100644 index d0f1c8556..000000000 --- a/project/jni/sdl-1.3/src/thread/win32/SDL_sysmutex.c +++ /dev/null @@ -1,102 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Mutex functions using the Win32 API */ - -#define WIN32_LEAN_AND_MEAN -#include - -#include "SDL_mutex.h" - - -struct SDL_mutex -{ - HANDLE id; -}; - -/* Create a mutex */ -SDL_mutex * -SDL_CreateMutex(void) -{ - SDL_mutex *mutex; - - /* Allocate mutex memory */ - mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); - if (mutex) { - /* Create the mutex, with initial value signaled */ - mutex->id = CreateMutex(NULL, FALSE, NULL); - if (!mutex->id) { - SDL_SetError("Couldn't create mutex"); - SDL_free(mutex); - mutex = NULL; - } - } else { - SDL_OutOfMemory(); - } - return (mutex); -} - -/* Free the mutex */ -void -SDL_DestroyMutex(SDL_mutex * mutex) -{ - if (mutex) { - if (mutex->id) { - CloseHandle(mutex->id); - mutex->id = 0; - } - SDL_free(mutex); - } -} - -/* Lock the mutex */ -int -SDL_mutexP(SDL_mutex * mutex) -{ - if (mutex == NULL) { - SDL_SetError("Passed a NULL mutex"); - return -1; - } - if (WaitForSingleObject(mutex->id, INFINITE) == WAIT_FAILED) { - SDL_SetError("Couldn't wait on mutex"); - return -1; - } - return (0); -} - -/* Unlock the mutex */ -int -SDL_mutexV(SDL_mutex * mutex) -{ - if (mutex == NULL) { - SDL_SetError("Passed a NULL mutex"); - return -1; - } - if (ReleaseMutex(mutex->id) == FALSE) { - SDL_SetError("Couldn't release mutex"); - return -1; - } - return (0); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/win32/SDL_systhread.c b/project/jni/sdl-1.3/src/thread/win32/SDL_systhread.c deleted file mode 100644 index 71313c3be..000000000 --- a/project/jni/sdl-1.3/src/thread/win32/SDL_systhread.c +++ /dev/null @@ -1,167 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Win32 thread management routines for SDL */ - -#define WIN32_LEAN_AND_MEAN -#include - -#include "SDL_thread.h" -#include "../SDL_thread_c.h" -#include "../SDL_systhread.h" - -#ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD -#ifndef _WIN32_WCE -/* We'll use the C library from this DLL */ -#include -#endif - -#if __GNUC__ -typedef uintptr_t (__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned - (__stdcall * - func) (void *), - void *arg, - unsigned, - unsigned - *threadID); -typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); -#elif defined(__WATCOMC__) -/* This is for Watcom targets except OS2 */ -#if __WATCOMC__ < 1240 -#define __watcall -#endif -typedef unsigned long (__watcall * pfnSDL_CurrentBeginThread) (void *, - unsigned, - unsigned - (__stdcall * - func) (void - *), - void *arg, - unsigned, - unsigned - *threadID); -typedef void (__watcall * pfnSDL_CurrentEndThread) (unsigned code); -#else -typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, - unsigned (__stdcall * - func) (void - *), - void *arg, unsigned, - unsigned *threadID); -typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); -#endif -#endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */ - - -typedef struct ThreadStartParms -{ - void *args; - pfnSDL_CurrentEndThread pfnCurrentEndThread; -} tThreadStartParms, *pThreadStartParms; - -static DWORD __stdcall -RunThread(void *data) -{ - pThreadStartParms pThreadParms = (pThreadStartParms) data; - pfnSDL_CurrentEndThread pfnCurrentEndThread = NULL; - - // Call the thread function! - SDL_RunThread(pThreadParms->args); - - // Get the current endthread we have to use! - if (pThreadParms) { - pfnCurrentEndThread = pThreadParms->pfnCurrentEndThread; - SDL_free(pThreadParms); - } - // Call endthread! - if (pfnCurrentEndThread) - (*pfnCurrentEndThread) (0); - return (0); -} - -#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD -int -SDL_SYS_CreateThread(SDL_Thread * thread, void *args, - pfnSDL_CurrentBeginThread pfnBeginThread, - pfnSDL_CurrentEndThread pfnEndThread) -{ -#else -int -SDL_SYS_CreateThread(SDL_Thread * thread, void *args) -{ -#ifdef _WIN32_WCE - pfnSDL_CurrentBeginThread pfnBeginThread = NULL; - pfnSDL_CurrentEndThread pfnEndThread = NULL; -#else - pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex; - pfnSDL_CurrentEndThread pfnEndThread = _endthreadex; -#endif -#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ - unsigned threadid; - pThreadStartParms pThreadParms = - (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms)); - if (!pThreadParms) { - SDL_OutOfMemory(); - return (-1); - } - // Save the function which we will have to call to clear the RTL of calling app! - pThreadParms->pfnCurrentEndThread = pfnEndThread; - // Also save the real parameters we have to pass to thread function - pThreadParms->args = args; - - if (pfnBeginThread) { - thread->handle = - (SYS_ThreadHandle) pfnBeginThread(NULL, 0, RunThread, - pThreadParms, 0, &threadid); - } else { - thread->handle = - CreateThread(NULL, 0, RunThread, pThreadParms, 0, &threadid); - } - if (thread->handle == NULL) { - SDL_SetError("Not enough resources to create thread"); - return (-1); - } - return (0); -} - -void -SDL_SYS_SetupThread(void) -{ - return; -} - -SDL_threadID -SDL_ThreadID(void) -{ - return ((SDL_threadID) GetCurrentThreadId()); -} - -void -SDL_SYS_WaitThread(SDL_Thread * thread) -{ - WaitForSingleObject(thread->handle, INFINITE); - CloseHandle(thread->handle); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/win32/SDL_systhread_c.h b/project/jni/sdl-1.3/src/thread/win32/SDL_systhread_c.h deleted file mode 100644 index 675e821c9..000000000 --- a/project/jni/sdl-1.3/src/thread/win32/SDL_systhread_c.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#define WIN32_LEAN_AND_MEAN -#include - -typedef HANDLE SYS_ThreadHandle; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/windows/SDL_sysmutex.c b/project/jni/sdl-1.3/src/thread/windows/SDL_sysmutex.c new file mode 100644 index 000000000..ab35a9614 --- /dev/null +++ b/project/jni/sdl-1.3/src/thread/windows/SDL_sysmutex.c @@ -0,0 +1,97 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_THREAD_WINDOWS + +/* Mutex functions using the Win32 API */ + +#include "../../core/windows/SDL_windows.h" + +#include "SDL_mutex.h" + + +struct SDL_mutex +{ + CRITICAL_SECTION cs; +}; + +/* Create a mutex */ +SDL_mutex * +SDL_CreateMutex(void) +{ + SDL_mutex *mutex; + + /* Allocate mutex memory */ + mutex = (SDL_mutex *) SDL_malloc(sizeof(*mutex)); + if (mutex) { + /* Initialize */ +#ifdef _WIN32_WCE + InitializeCriticalSection(&mutex->cs); +#else + /* On SMP systems, a non-zero spin count generally helps performance */ + InitializeCriticalSectionAndSpinCount(&mutex->cs, 2000); +#endif + } else { + SDL_OutOfMemory(); + } + return (mutex); +} + +/* Free the mutex */ +void +SDL_DestroyMutex(SDL_mutex * mutex) +{ + if (mutex) { + DeleteCriticalSection(&mutex->cs); + SDL_free(mutex); + } +} + +/* Lock the mutex */ +int +SDL_mutexP(SDL_mutex * mutex) +{ + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + EnterCriticalSection(&mutex->cs); + return (0); +} + +/* Unlock the mutex */ +int +SDL_mutexV(SDL_mutex * mutex) +{ + if (mutex == NULL) { + SDL_SetError("Passed a NULL mutex"); + return -1; + } + + LeaveCriticalSection(&mutex->cs); + return (0); +} + +#endif /* SDL_THREAD_WINDOWS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/win32/SDL_syssem.c b/project/jni/sdl-1.3/src/thread/windows/SDL_syssem.c similarity index 75% rename from project/jni/sdl-1.3/src/thread/win32/SDL_syssem.c rename to project/jni/sdl-1.3/src/thread/windows/SDL_syssem.c index 4fcb8c6e1..b1543dab9 100644 --- a/project/jni/sdl-1.3/src/thread/win32/SDL_syssem.c +++ b/project/jni/sdl-1.3/src/thread/windows/SDL_syssem.c @@ -1,30 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_THREAD_WINDOWS + /* Semaphore functions using the Win32 API */ -#define WIN32_LEAN_AND_MEAN -#include +#include "../../core/windows/SDL_windows.h" #include "SDL_thread.h" #if defined(_WIN32_WCE) && (_WIN32_WCE < 300) @@ -39,7 +39,7 @@ struct SDL_semaphore #else HANDLE id; #endif - LONG volatile count; + LONG count; }; @@ -171,4 +171,6 @@ SDL_SemPost(SDL_sem * sem) return 0; } +#endif /* SDL_THREAD_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/windows/SDL_systhread.c b/project/jni/sdl-1.3/src/thread/windows/SDL_systhread.c new file mode 100644 index 000000000..47bc0d20e --- /dev/null +++ b/project/jni/sdl-1.3/src/thread/windows/SDL_systhread.c @@ -0,0 +1,223 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_THREAD_WINDOWS + +/* Win32 thread management routines for SDL */ + +#include "SDL_thread.h" +#include "../SDL_thread_c.h" +#include "../SDL_systhread.h" +#include "SDL_systhread_c.h" + +#ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD +#ifndef _WIN32_WCE +/* We'll use the C library from this DLL */ +#include +#endif + +/* Cygwin gcc-3 ... MingW64 (even with a i386 host) does this like MSVC. */ +#if (defined(__MINGW32__) && (__GNUC__ < 4)) +typedef unsigned long (__cdecl *pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall *func)(void *), void *arg, + unsigned, unsigned *threadID); +typedef void (__cdecl *pfnSDL_CurrentEndThread)(unsigned code); + +#elif defined(__WATCOMC__) +/* This is for Watcom targets except OS2 */ +#if __WATCOMC__ < 1240 +#define __watcall +#endif +typedef unsigned long (__watcall * pfnSDL_CurrentBeginThread) (void *, + unsigned, + unsigned + (__stdcall * + func) (void + *), + void *arg, + unsigned, + unsigned + *threadID); +typedef void (__watcall * pfnSDL_CurrentEndThread) (unsigned code); + +#else +typedef uintptr_t(__cdecl * pfnSDL_CurrentBeginThread) (void *, unsigned, + unsigned (__stdcall * + func) (void + *), + void *arg, unsigned, + unsigned *threadID); +typedef void (__cdecl * pfnSDL_CurrentEndThread) (unsigned code); +#endif +#endif /* !SDL_PASSED_BEGINTHREAD_ENDTHREAD */ + + +typedef struct ThreadStartParms +{ + void *args; + pfnSDL_CurrentEndThread pfnCurrentEndThread; +} tThreadStartParms, *pThreadStartParms; + +static DWORD +RunThread(void *data) +{ + pThreadStartParms pThreadParms = (pThreadStartParms) data; + pfnSDL_CurrentEndThread pfnEndThread = pThreadParms->pfnCurrentEndThread; + void *args = pThreadParms->args; + SDL_free(pThreadParms); + SDL_RunThread(args); + if (pfnEndThread != NULL) + pfnEndThread(0); + return (0); +} + +static DWORD WINAPI +RunThreadViaCreateThread(LPVOID data) +{ + return RunThread(data); +} + +static unsigned __stdcall +RunThreadViaBeginThreadEx(void *data) +{ + return (unsigned) RunThread(data); +} + +#ifdef SDL_PASSED_BEGINTHREAD_ENDTHREAD +int +SDL_SYS_CreateThread(SDL_Thread * thread, void *args, + pfnSDL_CurrentBeginThread pfnBeginThread, + pfnSDL_CurrentEndThread pfnEndThread) +{ +#else +int +SDL_SYS_CreateThread(SDL_Thread * thread, void *args) +{ +#ifdef _WIN32_WCE + pfnSDL_CurrentBeginThread pfnBeginThread = NULL; + pfnSDL_CurrentEndThread pfnEndThread = NULL; +#else + pfnSDL_CurrentBeginThread pfnBeginThread = _beginthreadex; + pfnSDL_CurrentEndThread pfnEndThread = _endthreadex; +#endif +#endif /* SDL_PASSED_BEGINTHREAD_ENDTHREAD */ + pThreadStartParms pThreadParms = + (pThreadStartParms) SDL_malloc(sizeof(tThreadStartParms)); + if (!pThreadParms) { + SDL_OutOfMemory(); + return (-1); + } + // Save the function which we will have to call to clear the RTL of calling app! + pThreadParms->pfnCurrentEndThread = pfnEndThread; + // Also save the real parameters we have to pass to thread function + pThreadParms->args = args; + + if (pfnBeginThread) { + unsigned threadid = 0; + thread->handle = (SYS_ThreadHandle) + ((size_t) pfnBeginThread(NULL, 0, RunThreadViaBeginThreadEx, + pThreadParms, 0, &threadid)); + } else { + DWORD threadid = 0; + thread->handle = CreateThread(NULL, 0, RunThreadViaCreateThread, + pThreadParms, 0, &threadid); + } + if (thread->handle == NULL) { + SDL_SetError("Not enough resources to create thread"); + return (-1); + } + return (0); +} + +#ifdef _MSC_VER +#pragma pack(push,8) +typedef struct tagTHREADNAME_INFO +{ + DWORD dwType; /* must be 0x1000 */ + LPCSTR szName; /* pointer to name (in user addr space) */ + DWORD dwThreadID; /* thread ID (-1=caller thread) */ + DWORD dwFlags; /* reserved for future use, must be zero */ +} THREADNAME_INFO; +#pragma pack(pop) +#endif + +void +SDL_SYS_SetupThread(const char *name) +{ + if (name != NULL) { + #if 0 /* !!! FIXME: __except needs C runtime, which we don't link against. */ + #ifdef _MSC_VER /* !!! FIXME: can we do SEH on other compilers yet? */ + /* This magic tells the debugger to name a thread if it's listening. */ + THREADNAME_INFO inf; + inf.dwType = 0x1000; + inf.szName = name; + inf.dwThreadID = (DWORD) -1; + inf.dwFlags = 0; + + __try + { + RaiseException(0x406D1388, 0, sizeof(inf)/sizeof(DWORD), (DWORD*)&inf); + } + __except(EXCEPTION_CONTINUE_EXECUTION) + { + /* The program itself should ignore this bogus exception. */ + } + #endif + #endif + } +} + +SDL_threadID +SDL_ThreadID(void) +{ + return ((SDL_threadID) GetCurrentThreadId()); +} + +int +SDL_SYS_SetThreadPriority(SDL_ThreadPriority priority) +{ + int value; + + if (priority == SDL_THREAD_PRIORITY_LOW) { + value = THREAD_PRIORITY_LOWEST; + } else if (priority == SDL_THREAD_PRIORITY_HIGH) { + value = THREAD_PRIORITY_HIGHEST; + } else { + value = THREAD_PRIORITY_NORMAL; + } + if (!SetThreadPriority(GetCurrentThread(), value)) { + WIN_SetError("SetThreadPriority()"); + return -1; + } + return 0; +} + +void +SDL_SYS_WaitThread(SDL_Thread * thread) +{ + WaitForSingleObject(thread->handle, INFINITE); + CloseHandle(thread->handle); +} + +#endif /* SDL_THREAD_WINDOWS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/windows/SDL_systhread_c.h b/project/jni/sdl-1.3/src/thread/windows/SDL_systhread_c.h new file mode 100644 index 000000000..fd10a4080 --- /dev/null +++ b/project/jni/sdl-1.3/src/thread/windows/SDL_systhread_c.h @@ -0,0 +1,32 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_systhread_c_h +#define _SDL_systhread_c_h + +#include "../../core/windows/SDL_windows.h" + +typedef HANDLE SYS_ThreadHandle; + +#endif /* _SDL_systhread_c_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/win32/win_ce_semaphore.c b/project/jni/sdl-1.3/src/thread/windows/win_ce_semaphore.c similarity index 98% rename from project/jni/sdl-1.3/src/thread/win32/win_ce_semaphore.c rename to project/jni/sdl-1.3/src/thread/windows/win_ce_semaphore.c index a44fc34f5..f243682b7 100644 --- a/project/jni/sdl-1.3/src/thread/win32/win_ce_semaphore.c +++ b/project/jni/sdl-1.3/src/thread/windows/win_ce_semaphore.c @@ -26,10 +26,13 @@ 6. The wait function emulates WaitForSingleObject only. An emulation of WaitForMultipleObjects is much harder to implement outside the kernel, and it is not clear how to handle a mixture of WCE semaphores and normal - events and mutexes. */ + events and mutexes. +*/ +#include "SDL_config.h" -#define WIN32_LEAN_AND_MEAN -#include +#if SDL_THREAD_WINDOWS + +#include "../../core/windows/SDL_windows.h" #include "win_ce_semaphore.h" @@ -225,4 +228,6 @@ CleanUp(SYNCHHANDLE hSynch, DWORD Flags) return hSynch; } +#endif /* SDL_THREAD_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/thread/win32/win_ce_semaphore.h b/project/jni/sdl-1.3/src/thread/windows/win_ce_semaphore.h similarity index 100% rename from project/jni/sdl-1.3/src/thread/win32/win_ce_semaphore.h rename to project/jni/sdl-1.3/src/thread/windows/win_ce_semaphore.h diff --git a/project/jni/sdl-1.3/src/timer/SDL_systimer.h b/project/jni/sdl-1.3/src/timer/SDL_systimer.h deleted file mode 100644 index d0cfd25db..000000000 --- a/project/jni/sdl-1.3/src/timer/SDL_systimer.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* The system dependent timer handling functions */ - -#include "SDL_timer.h" -#include "SDL_timer_c.h" - - -/* Initialize the system dependent timer subsystem */ -extern int SDL_SYS_TimerInit(void); - -/* Quit the system dependent timer subsystem */ -extern void SDL_SYS_TimerQuit(void); - -/* Start a timer set up by SDL_SetTimer() */ -extern int SDL_SYS_StartTimer(void); - -/* Stop a previously started timer */ -extern void SDL_SYS_StopTimer(void); - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/SDL_timer.c b/project/jni/sdl-1.3/src/timer/SDL_timer.c index 1e0318dce..0d4ce20b5 100644 --- a/project/jni/sdl-1.3/src/timer/SDL_timer.c +++ b/project/jni/sdl-1.3/src/timer/SDL_timer.c @@ -1,300 +1,386 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #include "SDL_timer.h" #include "SDL_timer_c.h" -#include "SDL_mutex.h" -#include "SDL_systimer.h" +#include "SDL_atomic.h" +#include "SDL_cpuinfo.h" +#include "SDL_thread.h" /* #define DEBUG_TIMERS */ -int SDL_timer_started = 0; -int SDL_timer_running = 0; - -/* Data to handle a single periodic alarm */ -Uint32 SDL_alarm_interval = 0; -SDL_TimerCallback SDL_alarm_callback; - -/* Data used for a thread-based timer */ -static int SDL_timer_threaded = 0; - -struct _SDL_TimerID +typedef struct _SDL_Timer { - Uint32 interval; - SDL_NewTimerCallback cb; + int timerID; + SDL_TimerCallback callback; void *param; - Uint32 last_alarm; - struct _SDL_TimerID *next; -}; + Uint32 interval; + Uint32 scheduled; + volatile SDL_bool canceled; + struct _SDL_Timer *next; +} SDL_Timer; -static SDL_TimerID SDL_timers = NULL; -static SDL_mutex *SDL_timer_mutex; -static volatile SDL_bool list_changed = SDL_FALSE; - -/* Set whether or not the timer should use a thread. - This should not be called while the timer subsystem is running. -*/ -int -SDL_SetTimerThreaded(int value) +typedef struct _SDL_TimerMap { - int retval; + int timerID; + SDL_Timer *timer; + struct _SDL_TimerMap *next; +} SDL_TimerMap; - if (SDL_timer_started) { - SDL_SetError("Timer already initialized"); - retval = -1; - } else { - retval = 0; - SDL_timer_threaded = value; +/* The timers are kept in a sorted list */ +typedef struct { + /* Data used by the main thread */ + SDL_Thread *thread; + SDL_atomic_t nextID; + SDL_TimerMap *timermap; + SDL_mutex *timermap_lock; + + /* Padding to separate cache lines between threads */ + char cache_pad[SDL_CACHELINE_SIZE]; + + /* Data used to communicate with the timer thread */ + SDL_SpinLock lock; + SDL_sem *sem; + SDL_Timer * volatile pending; + SDL_Timer * volatile freelist; + volatile SDL_bool active; + + /* List of timers - this is only touched by the timer thread */ + SDL_Timer *timers; +} SDL_TimerData; + +static SDL_TimerData SDL_timer_data; + + +/* The idea here is that any thread might add a timer, but a single + * thread manages the active timer queue, sorted by scheduling time. + * + * Timers are removed by simply setting a canceled flag + */ + +static void +SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer) +{ + SDL_Timer *prev, *curr; + + prev = NULL; + for (curr = data->timers; curr; prev = curr, curr = curr->next) { + if ((Sint32)(timer->scheduled-curr->scheduled) < 0) { + break; + } } - return retval; + + /* Insert the timer here! */ + if (prev) { + prev->next = timer; + } else { + data->timers = timer; + } + timer->next = curr; +} + +static int +SDL_TimerThread(void *_data) +{ + SDL_TimerData *data = (SDL_TimerData *)_data; + SDL_Timer *pending; + SDL_Timer *current; + SDL_Timer *freelist_head = NULL; + SDL_Timer *freelist_tail = NULL; + Uint32 tick, now, interval, delay; + + /* Threaded timer loop: + * 1. Queue timers added by other threads + * 2. Handle any timers that should dispatch this cycle + * 3. Wait until next dispatch time or new timer arrives + */ + for ( ; ; ) { + /* Pending and freelist maintenance */ + SDL_AtomicLock(&data->lock); + { + /* Get any timers ready to be queued */ + pending = data->pending; + data->pending = NULL; + + /* Make any unused timer structures available */ + if (freelist_head) { + freelist_tail->next = data->freelist; + data->freelist = freelist_head; + } + } + SDL_AtomicUnlock(&data->lock); + + /* Sort the pending timers into our list */ + while (pending) { + current = pending; + pending = pending->next; + SDL_AddTimerInternal(data, current); + } + freelist_head = NULL; + freelist_tail = NULL; + + /* Check to see if we're still running, after maintenance */ + if (!data->active) { + break; + } + + /* Initial delay if there are no timers */ + delay = SDL_MUTEX_MAXWAIT; + + tick = SDL_GetTicks(); + + /* Process all the pending timers for this tick */ + while (data->timers) { + current = data->timers; + + if ((Sint32)(tick-current->scheduled) < 0) { + /* Scheduled for the future, wait a bit */ + delay = (current->scheduled - tick); + break; + } + + /* We're going to do something with this timer */ + data->timers = current->next; + + if (current->canceled) { + interval = 0; + } else { + interval = current->callback(current->interval, current->param); + } + + if (interval > 0) { + /* Reschedule this timer */ + current->scheduled = tick + interval; + SDL_AddTimerInternal(data, current); + } else { + if (!freelist_head) { + freelist_head = current; + } + if (freelist_tail) { + freelist_tail->next = current; + } + freelist_tail = current; + + current->canceled = SDL_TRUE; + } + } + + /* Adjust the delay based on processing time */ + now = SDL_GetTicks(); + interval = (now - tick); + if (interval > delay) { + delay = 0; + } else { + delay -= interval; + } + + /* Note that each time a timer is added, this will return + immediately, but we process the timers added all at once. + That's okay, it just means we run through the loop a few + extra times. + */ + SDL_SemWaitTimeout(data->sem, delay); + } + return 0; } int SDL_TimerInit(void) { - int retval; + SDL_TimerData *data = &SDL_timer_data; - retval = 0; - if (SDL_timer_started) { - SDL_TimerQuit(); + if (!data->active) { + const char *name = "SDLTimer"; + data->timermap_lock = SDL_CreateMutex(); + if (!data->timermap_lock) { + return -1; + } + + data->sem = SDL_CreateSemaphore(0); + if (!data->sem) { + SDL_DestroyMutex(data->timermap_lock); + return -1; + } + + data->active = SDL_TRUE; + /* !!! FIXME: this is nasty. */ +#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC) +#undef SDL_CreateThread + data->thread = SDL_CreateThread(SDL_TimerThread, name, data, NULL, NULL); +#else + data->thread = SDL_CreateThread(SDL_TimerThread, name, data); +#endif + if (!data->thread) { + SDL_TimerQuit(); + return -1; + } + + SDL_AtomicSet(&data->nextID, 1); } - if (!SDL_timer_threaded) { - retval = SDL_SYS_TimerInit(); - } - if (SDL_timer_threaded) { - SDL_timer_mutex = SDL_CreateMutex(); - } - if (retval == 0) { - SDL_timer_started = 1; - } - return (retval); + return 0; } void SDL_TimerQuit(void) { - SDL_SetTimer(0, NULL); - if (SDL_timer_threaded < 2) { - SDL_SYS_TimerQuit(); - } - if (SDL_timer_threaded) { - SDL_DestroyMutex(SDL_timer_mutex); - SDL_timer_mutex = NULL; - } - SDL_timer_started = 0; - SDL_timer_threaded = 0; -} + SDL_TimerData *data = &SDL_timer_data; + SDL_Timer *timer; + SDL_TimerMap *entry; -void -SDL_ThreadedTimerCheck(void) -{ - Uint32 now, ms; - SDL_TimerID t, prev, next; - SDL_bool removed; + if (data->active) { + data->active = SDL_FALSE; - SDL_mutexP(SDL_timer_mutex); - list_changed = SDL_FALSE; - now = SDL_GetTicks(); - for (prev = NULL, t = SDL_timers; t; t = next) { - removed = SDL_FALSE; - ms = t->interval - SDL_TIMESLICE; - next = t->next; - if ((int) (now - t->last_alarm) > (int) ms) { - struct _SDL_TimerID timer; - - if ((now - t->last_alarm) < t->interval) { - t->last_alarm += t->interval; - } else { - t->last_alarm = now; - } -#ifdef DEBUG_TIMERS - printf("Executing timer %p (thread = %lu)\n", t, SDL_ThreadID()); -#endif - timer = *t; - SDL_mutexV(SDL_timer_mutex); - ms = timer.cb(timer.interval, timer.param); - SDL_mutexP(SDL_timer_mutex); - if (list_changed) { - /* Abort, list of timers modified */ - /* FIXME: what if ms was changed? */ - break; - } - if (ms != t->interval) { - if (ms) { - t->interval = ROUND_RESOLUTION(ms); - } else { - /* Remove timer from the list */ -#ifdef DEBUG_TIMERS - printf("SDL: Removing timer %p\n", t); -#endif - if (prev) { - prev->next = next; - } else { - SDL_timers = next; - } - SDL_free(t); - --SDL_timer_running; - removed = SDL_TRUE; - } - } + /* Shutdown the timer thread */ + if (data->thread) { + SDL_SemPost(data->sem); + SDL_WaitThread(data->thread, NULL); + data->thread = NULL; } - /* Don't update prev if the timer has disappeared */ - if (!removed) { - prev = t; - } - } - SDL_mutexV(SDL_timer_mutex); -} -static SDL_TimerID -SDL_AddTimerInternal(Uint32 interval, SDL_NewTimerCallback callback, - void *param) -{ - SDL_TimerID t; - t = (SDL_TimerID) SDL_malloc(sizeof(struct _SDL_TimerID)); - if (t) { - t->interval = ROUND_RESOLUTION(interval); - t->cb = callback; - t->param = param; - t->last_alarm = SDL_GetTicks(); - t->next = SDL_timers; - SDL_timers = t; - ++SDL_timer_running; - list_changed = SDL_TRUE; + SDL_DestroySemaphore(data->sem); + data->sem = NULL; + + /* Clean up the timer entries */ + while (data->timers) { + timer = data->timers; + data->timers = timer->next; + SDL_free(timer); + } + while (data->freelist) { + timer = data->freelist; + data->freelist = timer->next; + SDL_free(timer); + } + while (data->timermap) { + entry = data->timermap; + data->timermap = entry->next; + SDL_free(entry); + } + + SDL_DestroyMutex(data->timermap_lock); + data->timermap_lock = NULL; } -#ifdef DEBUG_TIMERS - printf("SDL_AddTimer(%d) = %08x num_timers = %d\n", interval, (Uint32) t, - SDL_timer_running); -#endif - return t; } SDL_TimerID -SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param) +SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param) { - SDL_TimerID t; - if (!SDL_timer_mutex) { - if (SDL_timer_started) { - SDL_SetError("This platform doesn't support multiple timers"); - } else { - SDL_SetError("You must call SDL_Init(SDL_INIT_TIMER) first"); + SDL_TimerData *data = &SDL_timer_data; + SDL_Timer *timer; + SDL_TimerMap *entry; + + if (!data->active) { + int status = 0; + + SDL_AtomicLock(&data->lock); + if (!data->active) { + status = SDL_TimerInit(); + } + SDL_AtomicUnlock(&data->lock); + + if (status < 0) { + return 0; } - return NULL; } - if (!SDL_timer_threaded) { - SDL_SetError("Multiple timers require threaded events!"); - return NULL; + + SDL_AtomicLock(&data->lock); + timer = data->freelist; + if (timer) { + data->freelist = timer->next; } - SDL_mutexP(SDL_timer_mutex); - t = SDL_AddTimerInternal(interval, callback, param); - SDL_mutexV(SDL_timer_mutex); - return t; + SDL_AtomicUnlock(&data->lock); + + if (timer) { + SDL_RemoveTimer(timer->timerID); + } else { + timer = (SDL_Timer *)SDL_malloc(sizeof(*timer)); + if (!timer) { + SDL_OutOfMemory(); + return 0; + } + } + timer->timerID = SDL_AtomicIncRef(&data->nextID); + timer->callback = callback; + timer->param = param; + timer->interval = interval; + timer->scheduled = SDL_GetTicks() + interval; + timer->canceled = SDL_FALSE; + + entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry)); + if (!entry) { + SDL_free(timer); + SDL_OutOfMemory(); + return 0; + } + entry->timer = timer; + entry->timerID = timer->timerID; + + SDL_mutexP(data->timermap_lock); + entry->next = data->timermap; + data->timermap = entry; + SDL_mutexV(data->timermap_lock); + + /* Add the timer to the pending list for the timer thread */ + SDL_AtomicLock(&data->lock); + timer->next = data->pending; + data->pending = timer; + SDL_AtomicUnlock(&data->lock); + + /* Wake up the timer thread if necessary */ + SDL_SemPost(data->sem); + + return entry->timerID; } SDL_bool SDL_RemoveTimer(SDL_TimerID id) { - SDL_TimerID t, prev = NULL; - SDL_bool removed; + SDL_TimerData *data = &SDL_timer_data; + SDL_TimerMap *prev, *entry; + SDL_bool canceled = SDL_FALSE; - removed = SDL_FALSE; - SDL_mutexP(SDL_timer_mutex); - /* Look for id in the linked list of timers */ - for (t = SDL_timers; t; prev = t, t = t->next) { - if (t == id) { + /* Find the timer */ + SDL_mutexP(data->timermap_lock); + prev = NULL; + for (entry = data->timermap; entry; prev = entry, entry = entry->next) { + if (entry->timerID == id) { if (prev) { - prev->next = t->next; + prev->next = entry->next; } else { - SDL_timers = t->next; + data->timermap = entry->next; } - SDL_free(t); - --SDL_timer_running; - removed = SDL_TRUE; - list_changed = SDL_TRUE; break; } } -#ifdef DEBUG_TIMERS - printf("SDL_RemoveTimer(%08x) = %d num_timers = %d thread = %lu\n", - (Uint32) id, removed, SDL_timer_running, SDL_ThreadID()); -#endif - SDL_mutexV(SDL_timer_mutex); - return removed; -} + SDL_mutexV(data->timermap_lock); -/* Old style callback functions are wrapped through this */ -static Uint32 SDLCALL -callback_wrapper(Uint32 ms, void *param) -{ - SDL_TimerCallback func = (SDL_TimerCallback) param; - return (*func) (ms); -} - -int -SDL_SetTimer(Uint32 ms, SDL_TimerCallback callback) -{ - int retval; - -#ifdef DEBUG_TIMERS - printf("SDL_SetTimer(%d)\n", ms); -#endif - retval = 0; - - if (SDL_timer_threaded) { - SDL_mutexP(SDL_timer_mutex); - } - if (SDL_timer_running) { /* Stop any currently running timer */ - if (SDL_timer_threaded) { - while (SDL_timers) { - SDL_TimerID freeme = SDL_timers; - SDL_timers = SDL_timers->next; - SDL_free(freeme); - } - SDL_timer_running = 0; - list_changed = SDL_TRUE; - } else { - SDL_SYS_StopTimer(); - SDL_timer_running = 0; + if (entry) { + if (!entry->timer->canceled) { + entry->timer->canceled = SDL_TRUE; + canceled = SDL_TRUE; } + SDL_free(entry); } - if (ms) { - if (SDL_timer_threaded) { - if (SDL_AddTimerInternal - (ms, callback_wrapper, (void *) callback) == NULL) { - retval = -1; - } - } else { - SDL_timer_running = 1; - SDL_alarm_interval = ms; - SDL_alarm_callback = callback; - retval = SDL_SYS_StartTimer(); - } - } - if (SDL_timer_threaded) { - SDL_mutexV(SDL_timer_mutex); - } - - return retval; + return canceled; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/SDL_timer_c.h b/project/jni/sdl-1.3/src/timer/SDL_timer_c.h index 3e7d3ebd7..da2a1c110 100644 --- a/project/jni/sdl-1.3/src/timer/SDL_timer_c.h +++ b/project/jni/sdl-1.3/src/timer/SDL_timer_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -27,21 +26,7 @@ #define ROUND_RESOLUTION(X) \ (((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION) -extern int SDL_timer_started; -extern int SDL_timer_running; - -/* Data to handle a single periodic alarm */ -extern Uint32 SDL_alarm_interval; -extern SDL_TimerCallback SDL_alarm_callback; - -/* Set whether or not the timer should use a thread. - This should be called while the timer subsystem is running. -*/ -extern int SDL_SetTimerThreaded(int value); - extern int SDL_TimerInit(void); extern void SDL_TimerQuit(void); -/* This function is called from the SDL event thread if it is available */ -extern void SDL_ThreadedTimerCheck(void); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/beos/SDL_systimer.c b/project/jni/sdl-1.3/src/timer/beos/SDL_systimer.c index e31bdebea..1befefe22 100644 --- a/project/jni/sdl-1.3/src/timer/beos/SDL_systimer.c +++ b/project/jni/sdl-1.3/src/timer/beos/SDL_systimer.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -25,9 +24,7 @@ #include -#include "SDL_thread.h" #include "SDL_timer.h" -#include "../SDL_timer_c.h" static bigtime_t start; @@ -44,61 +41,24 @@ SDL_GetTicks(void) return ((system_time() - start) / 1000); } +Uint64 +SDL_GetPerformanceCounter(void) +{ + return system_time(); +} + +Uint64 +SDL_GetPerformanceFrequency(void) +{ + return 1000000; +} + void SDL_Delay(Uint32 ms) { snooze(ms * 1000); } -/* Data to handle a single periodic alarm */ -static int timer_alive = 0; -static SDL_Thread *timer = NULL; - -static int -RunTimer(void *unused) -{ - while (timer_alive) { - if (SDL_timer_running) { - SDL_ThreadedTimerCheck(); - } - SDL_Delay(10); - } - return (0); -} - -/* This is only called if the event thread is not running */ -int -SDL_SYS_TimerInit(void) -{ - timer_alive = 1; - timer = SDL_CreateThread(RunTimer, NULL); - if (timer == NULL) - return (-1); - return (SDL_SetTimerThreaded(1)); -} - -void -SDL_SYS_TimerQuit(void) -{ - timer_alive = 0; - if (timer) { - SDL_WaitThread(timer, NULL); - timer = NULL; - } -} - -int -SDL_SYS_StartTimer(void) -{ - SDL_SetError("Internal logic error: BeOS uses threaded timer"); - return (-1); -} - -void -SDL_SYS_StopTimer(void) -{ - return; -} - #endif /* SDL_TIMER_BEOS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/dummy/SDL_systimer.c b/project/jni/sdl-1.3/src/timer/dummy/SDL_systimer.c index f13f0d566..57d169384 100644 --- a/project/jni/sdl-1.3/src/timer/dummy/SDL_systimer.c +++ b/project/jni/sdl-1.3/src/timer/dummy/SDL_systimer.c @@ -1,30 +1,28 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED) #include "SDL_timer.h" -#include "../SDL_timer_c.h" void SDL_StartTicks(void) @@ -38,63 +36,24 @@ SDL_GetTicks(void) return 0; } +Uint64 +SDL_GetPerformanceCounter(void) +{ + return SDL_GetTicks(); +} + +Uint64 +SDL_GetPerformanceFrequency(void) +{ + return 1000; +} + void SDL_Delay(Uint32 ms) { SDL_Unsupported(); } -#include "SDL_thread.h" - -/* Data to handle a single periodic alarm */ -static int timer_alive = 0; -static SDL_Thread *timer = NULL; - -static int -RunTimer(void *unused) -{ - while (timer_alive) { - if (SDL_timer_running) { - SDL_ThreadedTimerCheck(); - } - SDL_Delay(1); - } - return (0); -} - -/* This is only called if the event thread is not running */ -int -SDL_SYS_TimerInit(void) -{ - timer_alive = 1; - timer = SDL_CreateThread(RunTimer, NULL); - if (timer == NULL) - return (-1); - return (SDL_SetTimerThreaded(1)); -} - -void -SDL_SYS_TimerQuit(void) -{ - timer_alive = 0; - if (timer) { - SDL_WaitThread(timer, NULL); - timer = NULL; - } -} - -int -SDL_SYS_StartTimer(void) -{ - SDL_SetError("Internal logic error: threaded timer in use"); - return (-1); -} - -void -SDL_SYS_StopTimer(void) -{ - return; -} - #endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/nds/SDL_systimer.c b/project/jni/sdl-1.3/src/timer/nds/SDL_systimer.c index 50791f887..7c3565013 100644 --- a/project/jni/sdl-1.3/src/timer/nds/SDL_systimer.c +++ b/project/jni/sdl-1.3/src/timer/nds/SDL_systimer.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -27,22 +26,23 @@ #include #include "SDL_timer.h" -#include "../SDL_timer_c.h" -#include "../SDL_systimer.h" -/* Data to handle a single periodic alarm */ -static int timer_alive = 0; -static Uint32 timer_ticks; +/* Will wrap after 49 days. Shouldn't be an issue. */ +static volatile Uint32 timer_ticks; + +static void +NDS_TimerInterrupt(void) +{ + timer_ticks++; +} void SDL_StartTicks(void) { - if (!timer_alive) { - SDL_SYS_TimerInit(); - SDL_SYS_StartTimer(); - } - timer_ticks = 0; + + /* Set timer 2 to fire every ms. */ + timerStart(2, ClockDivider_1024, TIMER_FREQ_1024(1000), NDS_TimerInterrupt); } Uint32 @@ -51,70 +51,28 @@ SDL_GetTicks(void) return timer_ticks; } +Uint64 +SDL_GetPerformanceCounter(void) +{ + return SDL_GetTicks(); +} + +Uint64 +SDL_GetPerformanceFrequency(void) +{ + return 1000; +} + void SDL_Delay(Uint32 ms) { Uint32 start = SDL_GetTicks(); - while (timer_alive) { + while (1) { if ((SDL_GetTicks() - start) >= ms) break; } } -static int -RunTimer(void *unused) -{ - while (timer_alive) { - if (SDL_timer_running) { - } - SDL_Delay(1); - } - return (0); -} - -void -NDS_TimerInterrupt(void) -{ - timer_ticks++; -} - -/* This is only called if the event thread is not running */ -int -SDL_SYS_TimerInit(void) -{ - timer_alive = 1; - timer_ticks = 0; - TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ; - TIMER_DATA(3) = TIMER_FREQ_1024(1000); - irqSet(IRQ_TIMER3, NDS_TimerInterrupt); - irqEnable(IRQ_TIMER3); - return 0; -} - -void -SDL_SYS_TimerQuit(void) -{ - if (timer_alive) { - TIMER_CR(3) = 0; - } - timer_alive = 0; - irqDisable(IRQ_TIMER3); -} - -int -SDL_SYS_StartTimer(void) -{ - TIMER_CR(3) |= TIMER_ENABLE; - return 0; -} - -void -SDL_SYS_StopTimer(void) -{ - TIMER_CR(3) &= ~TIMER_ENABLE; - return; -} - - #endif /* SDL_TIMER_NDS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/riscos/SDL_systimer.c b/project/jni/sdl-1.3/src/timer/riscos/SDL_systimer.c deleted file mode 100644 index 5b25160f6..000000000 --- a/project/jni/sdl-1.3/src/timer/riscos/SDL_systimer.c +++ /dev/null @@ -1,248 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifdef SDL_TIMER_RISCOS - -#include -#include -#include -#include -#include -#include - -#include "SDL_timer.h" -#include "../SDL_timer_c.h" - -#if SDL_THREADS_DISABLED -/* Timer SDL_arraysize(Timer ),start/reset time */ -static Uint32 timerStart; -/* Timer running function */ -void RISCOS_CheckTimer(); -#else -#include -extern SDL_threadID riscos_main_thread; -extern int riscos_using_threads; -extern SDL_threadID SDL_ThreadID(); -extern SDL_threadID SDL_EventThreadID(void); -#endif - - -extern void RISCOS_BackgroundTasks(void); - -/* The first ticks value of the application */ -clock_t start; - -void -SDL_StartTicks(void) -{ - /* Set first ticks value */ - start = clock(); -} - -Uint32 -SDL_GetTicks(void) -{ - clock_t ticks; - - ticks = clock() - start; - - -#if CLOCKS_PER_SEC == 1000 - - return (ticks); - -#elif CLOCKS_PER_SEC == 100 - - return (ticks * 10); - -#else - - return ticks * (1000 / CLOCKS_PER_SEC); - -#endif - -} - -void -SDL_Delay(Uint32 ms) -{ - Uint32 now, then, elapsed; -#if !SDL_THREADS_DISABLED - int is_event_thread; - if (riscos_using_threads) { - is_event_thread = 0; - if (SDL_EventThreadID()) { - if (SDL_EventThreadID() == SDL_ThreadID()) - is_event_thread = 1; - } else if (SDL_ThreadID() == riscos_main_thread) - is_event_thread = 1; - } else - is_event_thread = 1; -#endif - - /*TODO: Next version of Unixlib may allow us to use usleep here */ - /* for non event threads */ - - /* Set the timeout interval - Linux only needs to do this once */ - then = SDL_GetTicks(); - - do { - /* Do background tasks required while sleeping as we are not multithreaded */ -#if SDL_THREADS_DISABLED - RISCOS_BackgroundTasks(); -#else - /* For threaded build only run background tasks in event thread */ - if (is_event_thread) - RISCOS_BackgroundTasks(); -#endif - - /* Calculate the time interval left (in case of interrupt) */ - now = SDL_GetTicks(); - elapsed = (now - then); - then = now; - if (elapsed >= ms) { - break; - } - ms -= elapsed; -#if !SDL_THREADS_DISABLED - /* Need to yield to let other threads have a go */ - if (riscos_using_threads) - pthread_yield(); -#endif - - } while (1); -} - -#if SDL_THREADS_DISABLED - -/* Non-threaded version of timer */ - -int -SDL_SYS_TimerInit(void) -{ - return (0); -} - -void -SDL_SYS_TimerQuit(void) -{ - SDL_SetTimer(0, NULL); -} - -int -SDL_SYS_StartTimer(void) -{ - timerStart = SDL_GetTicks(); - - return (0); -} - -void -SDL_SYS_StopTimer(void) -{ - /* Don't need to do anything as we use SDL_timer_running - to detect if we need to check the timer */ -} - - -void -RISCOS_CheckTimer() -{ - if (SDL_timer_running - && SDL_GetTicks() - timerStart >= SDL_alarm_interval) { - Uint32 ms; - - ms = SDL_alarm_callback(SDL_alarm_interval); - if (ms != SDL_alarm_interval) { - if (ms) { - SDL_alarm_interval = ROUND_RESOLUTION(ms); - } else { - SDL_alarm_interval = 0; - SDL_timer_running = 0; - } - } - if (SDL_alarm_interval) - timerStart = SDL_GetTicks(); - } -} - -#else - -/* Threaded version of timer - based on code for linux */ - -#include "SDL_thread.h" - -/* Data to handle a single periodic alarm */ -static int timer_alive = 0; -static SDL_Thread *timer = NULL; - -static int -RunTimer(void *unused) -{ - while (timer_alive) { - if (SDL_timer_running) { - SDL_ThreadedTimerCheck(); - } - SDL_Delay(1); - } - return (0); -} - -/* This is only called if the event thread is not running */ -int -SDL_SYS_TimerInit(void) -{ - timer_alive = 1; - timer = SDL_CreateThread(RunTimer, NULL); - if (timer == NULL) - return (-1); - return (SDL_SetTimerThreaded(1)); -} - -void -SDL_SYS_TimerQuit(void) -{ - timer_alive = 0; - if (timer) { - SDL_WaitThread(timer, NULL); - timer = NULL; - } -} - -int -SDL_SYS_StartTimer(void) -{ - SDL_SetError("Internal logic error: RISC OS uses threaded timer"); - return (-1); -} - -void -SDL_SYS_StopTimer(void) -{ - return; -} - -#endif /* SDL_THREADS_DISABLED */ - -#endif /* SDL_TIMER_RISCOS */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/unix/SDL_systimer.c b/project/jni/sdl-1.3/src/timer/unix/SDL_systimer.c index 2a933eea2..747ba3dfc 100644 --- a/project/jni/sdl-1.3/src/timer/unix/SDL_systimer.c +++ b/project/jni/sdl-1.3/src/timer/unix/SDL_systimer.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -25,14 +24,10 @@ #include #include -#include #include -#include #include #include "SDL_timer.h" -#include "../SDL_systimer.h" -#include "../SDL_timer_c.h" /* The clock_gettime provides monotonous time, so we should use it if it's available. The clock_gettime function is behind ifdef @@ -43,10 +38,6 @@ #include #endif -#if SDL_THREADS_DISABLED -#define USE_ITIMER -#endif - /* The first ticks value of the application */ #ifdef HAVE_CLOCK_GETTIME static struct timespec start; @@ -72,6 +63,7 @@ SDL_GetTicks(void) #if HAVE_CLOCK_GETTIME Uint32 ticks; struct timespec now; + clock_gettime(CLOCK_MONOTONIC, &now); ticks = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_nsec - @@ -80,6 +72,7 @@ SDL_GetTicks(void) #else Uint32 ticks; struct timeval now; + gettimeofday(&now, NULL); ticks = (now.tv_sec - start.tv_sec) * 1000 + (now.tv_usec - @@ -88,6 +81,40 @@ SDL_GetTicks(void) #endif } +Uint64 +SDL_GetPerformanceCounter(void) +{ +#if HAVE_CLOCK_GETTIME + Uint64 ticks; + struct timespec now; + + clock_gettime(CLOCK_MONOTONIC, &now); + ticks = now.tv_sec; + ticks *= 1000000000; + ticks += now.tv_nsec; + return (ticks); +#else + Uint64 ticks; + struct timeval now; + + gettimeofday(&now, NULL); + ticks = now.tv_sec; + ticks *= 1000000; + ticks += now.tv_usec; + return (ticks); +#endif +} + +Uint64 +SDL_GetPerformanceFrequency(void) +{ +#if HAVE_CLOCK_GETTIME + return 1000000000; +#else + return 1000000; +#endif +} + void SDL_Delay(Uint32 ms) { @@ -131,118 +158,6 @@ SDL_Delay(Uint32 ms) } while (was_error && (errno == EINTR)); } -#ifdef USE_ITIMER - -static void -HandleAlarm(int sig) -{ - Uint32 ms; - - if (SDL_alarm_callback) { - ms = (*SDL_alarm_callback) (SDL_alarm_interval); - if (ms != SDL_alarm_interval) { - SDL_SetTimer(ms, SDL_alarm_callback); - } - } -} - -int -SDL_SYS_TimerInit(void) -{ - struct sigaction action; - - /* Set the alarm handler (Linux specific) */ - SDL_memset(&action, 0, sizeof(action)); - action.sa_handler = HandleAlarm; - action.sa_flags = SA_RESTART; - sigemptyset(&action.sa_mask); - sigaction(SIGALRM, &action, NULL); - return (0); -} - -void -SDL_SYS_TimerQuit(void) -{ - SDL_SetTimer(0, NULL); -} - -int -SDL_SYS_StartTimer(void) -{ - struct itimerval timer; - - timer.it_value.tv_sec = (SDL_alarm_interval / 1000); - timer.it_value.tv_usec = (SDL_alarm_interval % 1000) * 1000; - timer.it_interval.tv_sec = (SDL_alarm_interval / 1000); - timer.it_interval.tv_usec = (SDL_alarm_interval % 1000) * 1000; - setitimer(ITIMER_REAL, &timer, NULL); - return (0); -} - -void -SDL_SYS_StopTimer(void) -{ - struct itimerval timer; - - SDL_memset(&timer, 0, (sizeof timer)); - setitimer(ITIMER_REAL, &timer, NULL); -} - -#else /* USE_ITIMER */ - -#include "SDL_thread.h" - -/* Data to handle a single periodic alarm */ -static int timer_alive = 0; -static SDL_Thread *timer = NULL; - -static int -RunTimer(void *unused) -{ - while (timer_alive) { - if (SDL_timer_running) { - SDL_ThreadedTimerCheck(); - } - SDL_Delay(1); - } - return (0); -} - -/* This is only called if the event thread is not running */ -int -SDL_SYS_TimerInit(void) -{ - timer_alive = 1; - timer = SDL_CreateThread(RunTimer, NULL); - if (timer == NULL) - return (-1); - return (SDL_SetTimerThreaded(1)); -} - -void -SDL_SYS_TimerQuit(void) -{ - timer_alive = 0; - if (timer) { - SDL_WaitThread(timer, NULL); - timer = NULL; - } -} - -int -SDL_SYS_StartTimer(void) -{ - SDL_SetError("Internal logic error: Linux uses threaded timer"); - return (-1); -} - -void -SDL_SYS_StopTimer(void) -{ - return; -} - -#endif /* USE_ITIMER */ - #endif /* SDL_TIMER_UNIX */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/win32/SDL_systimer.c b/project/jni/sdl-1.3/src/timer/win32/SDL_systimer.c deleted file mode 100644 index 6372bebd9..000000000 --- a/project/jni/sdl-1.3/src/timer/win32/SDL_systimer.c +++ /dev/null @@ -1,165 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifdef SDL_TIMER_WIN32 - -#define WIN32_LEAN_AND_MEAN -#include -#include - -#include "SDL_timer.h" -#include "../SDL_timer_c.h" - -#ifdef _WIN32_WCE -#error This is WinCE. Please use src/timer/wince/SDL_systimer.c instead. -#endif - -#define TIME_WRAP_VALUE (~(DWORD)0) - -/* The first (low-resolution) ticks value of the application */ -static DWORD start; - -#ifndef USE_GETTICKCOUNT -/* Store if a high-resolution performance counter exists on the system */ -static BOOL hires_timer_available; -/* The first high-resolution ticks value of the application */ -static LARGE_INTEGER hires_start_ticks; -/* The number of ticks per second of the high-resolution performance counter */ -static LARGE_INTEGER hires_ticks_per_second; -#endif - -void -SDL_StartTicks(void) -{ - /* Set first ticks value */ -#ifdef USE_GETTICKCOUNT - start = GetTickCount(); -#else -#if 0 /* Apparently there are problems with QPC on Win2K */ - if (QueryPerformanceFrequency(&hires_ticks_per_second) == TRUE) { - hires_timer_available = TRUE; - QueryPerformanceCounter(&hires_start_ticks); - } else -#endif - { - hires_timer_available = FALSE; - timeBeginPeriod(1); /* use 1 ms timer precision */ - start = timeGetTime(); - } -#endif -} - -Uint32 -SDL_GetTicks(void) -{ - DWORD now, ticks; -#ifndef USE_GETTICKCOUNT - LARGE_INTEGER hires_now; -#endif - -#ifdef USE_GETTICKCOUNT - now = GetTickCount(); -#else - if (hires_timer_available) { - QueryPerformanceCounter(&hires_now); - - hires_now.QuadPart -= hires_start_ticks.QuadPart; - hires_now.QuadPart *= 1000; - hires_now.QuadPart /= hires_ticks_per_second.QuadPart; - - return (DWORD) hires_now.QuadPart; - } else { - now = timeGetTime(); - } -#endif - - if (now < start) { - ticks = (TIME_WRAP_VALUE - start) + now; - } else { - ticks = (now - start); - } - return (ticks); -} - -void -SDL_Delay(Uint32 ms) -{ - Sleep(ms); -} - -/* Data to handle a single periodic alarm */ -static UINT timerID = 0; - -static void CALLBACK -HandleAlarm(UINT uID, UINT uMsg, DWORD_PTR dwUser, - DWORD_PTR dw1, DWORD_PTR dw2) -{ - SDL_ThreadedTimerCheck(); -} - - -int -SDL_SYS_TimerInit(void) -{ - MMRESULT result; - - /* Set timer resolution */ - result = timeBeginPeriod(TIMER_RESOLUTION); - if (result != TIMERR_NOERROR) { - SDL_SetError("Warning: Can't set %d ms timer resolution", - TIMER_RESOLUTION); - } - /* Allow 10 ms of drift so we don't chew on CPU */ - timerID = - timeSetEvent(TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC); - if (!timerID) { - SDL_SetError("timeSetEvent() failed"); - return (-1); - } - return (SDL_SetTimerThreaded(1)); -} - -void -SDL_SYS_TimerQuit(void) -{ - if (timerID) { - timeKillEvent(timerID); - } - timeEndPeriod(TIMER_RESOLUTION); -} - -int -SDL_SYS_StartTimer(void) -{ - SDL_SetError("Internal logic error: Win32 uses threaded timer"); - return (-1); -} - -void -SDL_SYS_StopTimer(void) -{ - return; -} - -#endif /* SDL_TIMER_WIN32 */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/wince/SDL_systimer.c b/project/jni/sdl-1.3/src/timer/wince/SDL_systimer.c index 8ecb71416..18cd58428 100644 --- a/project/jni/sdl-1.3/src/timer/wince/SDL_systimer.c +++ b/project/jni/sdl-1.3/src/timer/wince/SDL_systimer.c @@ -1,35 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifdef SDL_TIMER_WINCE -#define WIN32_LEAN_AND_MEAN -#include -#include +#include "../../core/windows/SDL_windows.h" -#include "SDL_thread.h" #include "SDL_timer.h" -#include "../SDL_timer_c.h" static Uint64 start_date; static Uint64 start_ticks; @@ -70,6 +65,14 @@ wce_rel_date(void) return ((Sint32) (wce_date() - start_date)); } +/* Recard start-time of application for reference */ +void +SDL_StartTicks(void) +{ + start_date = wce_date(); + start_ticks = wce_ticks(); +} + /* Return time in ms relative to when SDL was started */ Uint32 SDL_GetTicks() @@ -83,6 +86,18 @@ SDL_GetTicks() return ((Uint32) wce_rel_ticks()); } +Uint64 +SDL_GetPerformanceCounter(void) +{ + return SDL_GetTicks(); +} + +Uint64 +SDL_GetPerformanceFrequency(void) +{ + return 1000; +} + /* Give up approx. givem milliseconds to the OS. */ void SDL_Delay(Uint32 ms) @@ -90,122 +105,6 @@ SDL_Delay(Uint32 ms) Sleep(ms); } -/* Recard start-time of application for reference */ -void -SDL_StartTicks(void) -{ - start_date = wce_date(); - start_ticks = wce_ticks(); -} - -static UINT WIN_timer; - -#if ( _WIN32_WCE <= 420 ) - -static HANDLE timersThread = 0; -static HANDLE timersQuitEvent = 0; - -DWORD -TimersThreadProc(void *data) -{ - while (WaitForSingleObject(timersQuitEvent, 10) == WAIT_TIMEOUT) { - SDL_ThreadedTimerCheck(); - } - return 0; -} - -int -SDL_SYS_TimerInit(void) -{ - // create a thread to process a threaded timers - // SetTimer does not suit the needs because - // TimerCallbackProc will be called only when WM_TIMER occured - - timersQuitEvent = CreateEvent(0, TRUE, FALSE, 0); - if (!timersQuitEvent) { - SDL_SetError("Cannot create event for timers thread"); - return -1; - } - timersThread = CreateThread(NULL, 0, TimersThreadProc, 0, 0, 0); - if (!timersThread) { - SDL_SetError - ("Cannot create timers thread, check amount of RAM available"); - return -1; - } - SetThreadPriority(timersThread, THREAD_PRIORITY_HIGHEST); - - return (SDL_SetTimerThreaded(1)); -} - -void -SDL_SYS_TimerQuit(void) -{ - SetEvent(timersQuitEvent); - if (WaitForSingleObject(timersThread, 2000) == WAIT_TIMEOUT) - TerminateThread(timersThread, 0); - CloseHandle(timersThread); - CloseHandle(timersQuitEvent); - return; -} - -#else - -#pragma comment(lib, "mmtimer.lib") - -/* Data to handle a single periodic alarm */ -static UINT timerID = 0; - -static void CALLBACK -HandleAlarm(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2) -{ - SDL_ThreadedTimerCheck(); -} - - -int -SDL_SYS_TimerInit(void) -{ - MMRESULT result; - - /* Set timer resolution */ - result = timeBeginPeriod(TIMER_RESOLUTION); - if (result != TIMERR_NOERROR) { - SDL_SetError("Warning: Can't set %d ms timer resolution", - TIMER_RESOLUTION); - } - /* Allow 10 ms of drift so we don't chew on CPU */ - timerID = - timeSetEvent(TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC); - if (!timerID) { - SDL_SetError("timeSetEvent() failed"); - return (-1); - } - return (SDL_SetTimerThreaded(1)); -} - -void -SDL_SYS_TimerQuit(void) -{ - if (timerID) { - timeKillEvent(timerID); - } - timeEndPeriod(TIMER_RESOLUTION); -} - -#endif - -int -SDL_SYS_StartTimer(void) -{ - SDL_SetError("Internal logic error: WinCE uses threaded timer"); - return (-1); -} - -void -SDL_SYS_StopTimer(void) -{ - return; -} - #endif /* SDL_TIMER_WINCE */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/timer/windows/SDL_systimer.c b/project/jni/sdl-1.3/src/timer/windows/SDL_systimer.c new file mode 100644 index 000000000..e74f59b5a --- /dev/null +++ b/project/jni/sdl-1.3/src/timer/windows/SDL_systimer.c @@ -0,0 +1,131 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifdef SDL_TIMER_WINDOWS + +#include "../../core/windows/SDL_windows.h" +#include + +#include "SDL_timer.h" + +#ifdef _WIN32_WCE +#error This is WinCE. Please use src/timer/wince/SDL_systimer.c instead. +#endif + +#define TIME_WRAP_VALUE (~(DWORD)0) + +/* The first (low-resolution) ticks value of the application */ +static DWORD start; + +#ifndef USE_GETTICKCOUNT +/* Store if a high-resolution performance counter exists on the system */ +static BOOL hires_timer_available; +/* The first high-resolution ticks value of the application */ +static LARGE_INTEGER hires_start_ticks; +/* The number of ticks per second of the high-resolution performance counter */ +static LARGE_INTEGER hires_ticks_per_second; +#endif + +void +SDL_StartTicks(void) +{ + /* Set first ticks value */ +#ifdef USE_GETTICKCOUNT + start = GetTickCount(); +#else +#if 0 /* Apparently there are problems with QPC on Win2K */ + if (QueryPerformanceFrequency(&hires_ticks_per_second) == TRUE) { + hires_timer_available = TRUE; + QueryPerformanceCounter(&hires_start_ticks); + } else +#endif + { + hires_timer_available = FALSE; + timeBeginPeriod(1); /* use 1 ms timer precision */ + start = timeGetTime(); + } +#endif +} + +Uint32 +SDL_GetTicks(void) +{ + DWORD now, ticks; +#ifndef USE_GETTICKCOUNT + LARGE_INTEGER hires_now; +#endif + +#ifdef USE_GETTICKCOUNT + now = GetTickCount(); +#else + if (hires_timer_available) { + QueryPerformanceCounter(&hires_now); + + hires_now.QuadPart -= hires_start_ticks.QuadPart; + hires_now.QuadPart *= 1000; + hires_now.QuadPart /= hires_ticks_per_second.QuadPart; + + return (DWORD) hires_now.QuadPart; + } else { + now = timeGetTime(); + } +#endif + + if (now < start) { + ticks = (TIME_WRAP_VALUE - start) + now; + } else { + ticks = (now - start); + } + return (ticks); +} + +Uint64 +SDL_GetPerformanceCounter(void) +{ + LARGE_INTEGER counter; + + if (!QueryPerformanceCounter(&counter)) { + return SDL_GetTicks(); + } + return counter.QuadPart; +} + +Uint64 +SDL_GetPerformanceFrequency(void) +{ + LARGE_INTEGER frequency; + + if (!QueryPerformanceFrequency(&frequency)) { + return 1000; + } + return frequency.QuadPart; +} + +void +SDL_Delay(Uint32 ms) +{ + Sleep(ms); +} + +#endif /* SDL_TIMER_WINDOWS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_RLEaccel.c b/project/jni/sdl-1.3/src/video/SDL_RLEaccel.c index 39a24c75f..562341d0f 100644 --- a/project/jni/sdl-1.3/src/video/SDL_RLEaccel.c +++ b/project/jni/sdl-1.3/src/video/SDL_RLEaccel.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -610,17 +609,19 @@ SDL_RLEBlit(SDL_Surface * src, SDL_Rect * srcrect, typedef struct { Uint8 BytesPerPixel; - Uint8 Rloss; - Uint8 Gloss; - Uint8 Bloss; - Uint8 Rshift; - Uint8 Gshift; - Uint8 Bshift; - Uint8 Ashift; + Uint8 padding[3]; Uint32 Rmask; Uint32 Gmask; Uint32 Bmask; Uint32 Amask; + Uint8 Rloss; + Uint8 Gloss; + Uint8 Bloss; + Uint8 Aloss; + Uint8 Rshift; + Uint8 Gshift; + Uint8 Bshift; + Uint8 Ashift; } RLEDestFormat; /* blit a pixel-alpha RLE surface clipped at the right and/or left edges */ @@ -983,10 +984,9 @@ copy_32(void *dst, Uint32 * src, int n, Uint32 *d = dst; for (i = 0; i < n; i++) { unsigned r, g, b, a; - Uint32 pixel; RGBA_FROM_8888(*src, sfmt, r, g, b, a); - PIXEL_FROM_RGB(pixel, dfmt, r, g, b); - *d++ = pixel | a << 24; + PIXEL_FROM_RGBA(*d, dfmt, r, g, b, a); + d++; src++; } return n * 4; @@ -1094,17 +1094,18 @@ RLEAlphaSurface(SDL_Surface * surface) /* save the destination format so we can undo the encoding later */ RLEDestFormat *r = (RLEDestFormat *) rlebuf; r->BytesPerPixel = df->BytesPerPixel; - r->Rloss = df->Rloss; - r->Gloss = df->Gloss; - r->Bloss = df->Bloss; - r->Rshift = df->Rshift; - r->Gshift = df->Gshift; - r->Bshift = df->Bshift; - r->Ashift = df->Ashift; r->Rmask = df->Rmask; r->Gmask = df->Gmask; r->Bmask = df->Bmask; r->Amask = df->Amask; + r->Rloss = df->Rloss; + r->Gloss = df->Gloss; + r->Bloss = df->Bloss; + r->Aloss = df->Aloss; + r->Rshift = df->Rshift; + r->Gshift = df->Gshift; + r->Bshift = df->Bshift; + r->Ashift = df->Ashift; } dst = rlebuf + sizeof(RLEDestFormat); diff --git a/project/jni/sdl-1.3/src/video/SDL_RLEaccel_c.h b/project/jni/sdl-1.3/src/video/SDL_RLEaccel_c.h index 3ef6fe8b8..71e0018e6 100644 --- a/project/jni/sdl-1.3/src/video/SDL_RLEaccel_c.h +++ b/project/jni/sdl-1.3/src/video/SDL_RLEaccel_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/SDL_alphamult.c b/project/jni/sdl-1.3/src/video/SDL_alphamult.c deleted file mode 100644 index 7b35a866a..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_alphamult.c +++ /dev/null @@ -1,60 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_blit.h" -#include "SDL_alphamult.h" - -/* Functions to pre-multiply the alpha channel into the color channels */ - -#define DEFINE_PREMULTIPLY_FUNC(fmt) \ -void \ -SDL_PreMultiplyAlpha##fmt(int w, int h, Uint32 *pixels, int pitch) \ -{ \ - pitch /= 4; \ - while (h--) { \ - int n; \ - Uint32 *row = pixels; \ - Uint32 pixel; \ - unsigned r, g, b, a; \ - \ - for (n = w; n--; ) { \ - pixel = *row; \ - RGBA_FROM_##fmt(pixel, r, g, b, a); \ - r = (r * a) / 255; \ - g = (g * a) / 255; \ - b = (b * a) / 255; \ - fmt##_FROM_RGBA(*row, r, g, b, a); \ - ++row; \ - } \ - pixels += pitch; \ - } \ -} - -/* *INDENT-OFF* */ -DEFINE_PREMULTIPLY_FUNC(ARGB8888) -DEFINE_PREMULTIPLY_FUNC(RGBA8888) -DEFINE_PREMULTIPLY_FUNC(ABGR8888) -DEFINE_PREMULTIPLY_FUNC(BGRA8888) -/* *INDENT-ON* */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_alphamult.h b/project/jni/sdl-1.3/src/video/SDL_alphamult.h deleted file mode 100644 index e4796c286..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_alphamult.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* Functions to pre-multiply the alpha channel into the color channels */ - -#define DEFINE_PREMULTIPLY_FUNC(fmt) \ -void \ -SDL_PreMultiplyAlpha##fmt(int w, int h, Uint32 *pixels, int pitch); - -/* *INDENT-OFF* */ -DEFINE_PREMULTIPLY_FUNC(ARGB8888) -DEFINE_PREMULTIPLY_FUNC(RGBA8888) -DEFINE_PREMULTIPLY_FUNC(ABGR8888) -DEFINE_PREMULTIPLY_FUNC(BGRA8888) -/* *INDENT-ON* */ - -#undef DEFINE_PREMULTIPLY_FUNC - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_blendrect.c b/project/jni/sdl-1.3/src/video/SDL_blendrect.c deleted file mode 100644 index 850177d47..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_blendrect.c +++ /dev/null @@ -1,75 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" - - -int -SDL_BlendRect(SDL_Surface * dst, const SDL_Rect * rect, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - SDL_Rect full_rect; - SDL_Point points[5]; - - if (!dst) { - SDL_SetError("Passed NULL destination surface"); - return -1; - } - - /* If 'rect' == NULL, then outline the whole surface */ - if (!rect) { - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = dst->w; - full_rect.h = dst->h; - rect = &full_rect; - } - - points[0].x = rect->x; - points[0].y = rect->y; - points[1].x = rect->x+rect->w-1; - points[1].y = rect->y; - points[2].x = rect->x+rect->w-1; - points[2].y = rect->y+rect->h-1; - points[3].x = rect->x; - points[3].y = rect->y+rect->h-1; - points[4].x = rect->x; - points[4].y = rect->y; - return SDL_BlendLines(dst, points, 5, blendMode, r, g, b, a); -} - -int -SDL_BlendRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, - SDL_BlendMode blendMode, Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - int i; - - for (i = 0; i < count; ++i) { - if (SDL_BlendRect(dst, rects[i], blendMode, r, g, b, a) < 0) { - return -1; - } - } - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_blit.c b/project/jni/sdl-1.3/src/video/SDL_blit.c index a935666a0..775b6c380 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit.c +++ b/project/jni/sdl-1.3/src/video/SDL_blit.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -183,7 +182,7 @@ SDL_ChooseBlitFunc(Uint32 src_format, Uint32 dst_format, int flags, /* Check blend flags */ flagcheck = (flags & - (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)); + (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)); if ((flagcheck & entries[i].flags) != flagcheck) { continue; } @@ -239,12 +238,7 @@ SDL_CalculateBlit(SDL_Surface * surface) /* Choose a standard blit function */ if (map->identity && !(map->info.flags & ~SDL_COPY_RLE_DESIRED)) { - /* Handle overlapping blits on the same surface */ - if (surface == dst) { - blit = SDL_BlitCopyOverlap; - } else { - blit = SDL_BlitCopy; - } + blit = SDL_BlitCopy; } else if (surface->format->BitsPerPixel < 8) { blit = SDL_CalculateBlit0(surface); } else if (surface->format->BytesPerPixel == 1) { @@ -255,18 +249,8 @@ SDL_CalculateBlit(SDL_Surface * surface) blit = SDL_CalculateBlitN(surface); } if (blit == NULL) { - Uint32 src_format = - SDL_MasksToPixelFormatEnum(surface->format->BitsPerPixel, - surface->format->Rmask, - surface->format->Gmask, - surface->format->Bmask, - surface->format->Amask); - Uint32 dst_format = - SDL_MasksToPixelFormatEnum(dst->format->BitsPerPixel, - dst->format->Rmask, - dst->format->Gmask, - dst->format->Bmask, - dst->format->Amask); + Uint32 src_format = surface->format->format; + Uint32 dst_format = dst->format->format; blit = SDL_ChooseBlitFunc(src_format, dst_format, map->info.flags, diff --git a/project/jni/sdl-1.3/src/video/SDL_blit.h b/project/jni/sdl-1.3/src/video/SDL_blit.h index 21f1ba62a..1deb98ed6 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit.h +++ b/project/jni/sdl-1.3/src/video/SDL_blit.h @@ -1,61 +1,41 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef _SDL_blit_h #define _SDL_blit_h -#ifdef __MINGW32__ -#include <_mingw.h> -#endif - -#if defined(__MINGW32__) && defined(__MINGW64_VERSION_MAJOR) -#include -#else -#ifdef __MMX__ -#include -#endif -#ifdef __3dNOW__ -#include -#endif -#ifdef __SSE__ -#include -#endif -#ifdef __SSE2__ -#include -#endif -#endif - #include "SDL_cpuinfo.h" #include "SDL_endian.h" -#include "SDL_video.h" +#include "SDL_surface.h" + +/* Table to do pixel byte expansion */ +extern Uint8* SDL_expand_byte[9]; /* SDL blit copy flags */ #define SDL_COPY_MODULATE_COLOR 0x00000001 #define SDL_COPY_MODULATE_ALPHA 0x00000002 -#define SDL_COPY_MASK 0x00000010 -#define SDL_COPY_BLEND 0x00000020 -#define SDL_COPY_ADD 0x00000040 -#define SDL_COPY_MOD 0x00000080 +#define SDL_COPY_BLEND 0x00000010 +#define SDL_COPY_ADD 0x00000020 +#define SDL_COPY_MOD 0x00000040 #define SDL_COPY_COLORKEY 0x00000100 #define SDL_COPY_NEAREST 0x00000200 #define SDL_COPY_RLE_DESIRED 0x00001000 @@ -112,7 +92,7 @@ typedef struct SDL_BlitMap /* the version count matches the destination; mismatch indicates an invalid mapping */ - unsigned int format_version; + Uint32 palette_version; } SDL_BlitMap; /* Functions found in SDL_blit.c */ @@ -136,29 +116,24 @@ extern SDL_BlitFunc SDL_CalculateBlitA(SDL_Surface * surface); #define DECLARE_ALIGNED(t,v,a) t v #endif -#define FORMAT_EQUAL(A, B) \ - ((A)->BitsPerPixel == (B)->BitsPerPixel \ - && ((A)->Rmask == (B)->Rmask) && ((A)->Amask == (B)->Amask)) - /* Load pixel of the specified format from a buffer and get its R-G-B values */ -/* FIXME: rescale values to 0..255 here? */ #define RGB_FROM_PIXEL(Pixel, fmt, r, g, b) \ { \ - r = (((Pixel&fmt->Rmask)>>fmt->Rshift)<Rloss); \ - g = (((Pixel&fmt->Gmask)>>fmt->Gshift)<Gloss); \ - b = (((Pixel&fmt->Bmask)>>fmt->Bshift)<Bloss); \ + r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ + g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ + b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ } #define RGB_FROM_RGB565(Pixel, r, g, b) \ { \ - r = (((Pixel&0xF800)>>11)<<3); \ - g = (((Pixel&0x07E0)>>5)<<2); \ - b = ((Pixel&0x001F)<<3); \ + r = SDL_expand_byte[3][((Pixel&0xF800)>>11)]; \ + g = SDL_expand_byte[2][((Pixel&0x07E0)>>5)]; \ + b = SDL_expand_byte[3][(Pixel&0x001F)]; \ } #define RGB_FROM_RGB555(Pixel, r, g, b) \ { \ - r = (((Pixel&0x7C00)>>10)<<3); \ - g = (((Pixel&0x03E0)>>5)<<3); \ - b = ((Pixel&0x001F)<<3); \ + r = SDL_expand_byte[3][((Pixel&0x7C00)>>10)]; \ + g = SDL_expand_byte[3][((Pixel&0x03E0)>>5)]; \ + b = SDL_expand_byte[3][(Pixel&0x001F)]; \ } #define RGB_FROM_RGB888(Pixel, r, g, b) \ { \ @@ -188,7 +163,7 @@ do { \ break; \ \ default: \ - Pixel; /* stop gcc complaints */ \ + Pixel = 0; /* stop gcc complaints */ \ break; \ } \ } while (0) @@ -202,6 +177,7 @@ do { \ break; \ \ case 3: { \ + Pixel = 0; \ if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ r = *((buf)+fmt->Rshift/8); \ g = *((buf)+fmt->Gshift/8); \ @@ -220,7 +196,9 @@ do { \ break; \ \ default: \ - Pixel; /* stop gcc complaints */ \ + /* stop gcc complaints */ \ + Pixel = 0; \ + r = g = b = 0; \ break; \ } \ } while (0) @@ -230,7 +208,8 @@ do { \ { \ Pixel = ((r>>fmt->Rloss)<Rshift)| \ ((g>>fmt->Gloss)<Gshift)| \ - ((b>>fmt->Bloss)<Bshift); \ + ((b>>fmt->Bloss)<Bshift)| \ + fmt->Amask; \ } #define RGB565_FROM_RGB(Pixel, r, g, b) \ { \ @@ -267,7 +246,7 @@ do { \ Uint16 Pixel; \ \ PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ - *((Uint16 *)(buf)) = Pixel; \ + *((Uint16 *)(buf)) = Pixel; \ } \ break; \ \ @@ -293,51 +272,14 @@ do { \ break; \ } \ } -#define ASSEMBLE_RGB_AMASK(buf, bpp, fmt, r, g, b, Amask) \ -{ \ - switch (bpp) { \ - case 2: { \ - Uint16 *bufp; \ - Uint16 Pixel; \ - \ - bufp = (Uint16 *)buf; \ - PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ - *bufp = Pixel | (*bufp & Amask); \ - } \ - break; \ - \ - case 3: { \ - if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ - *((buf)+fmt->Rshift/8) = r; \ - *((buf)+fmt->Gshift/8) = g; \ - *((buf)+fmt->Bshift/8) = b; \ - } else { \ - *((buf)+2-fmt->Rshift/8) = r; \ - *((buf)+2-fmt->Gshift/8) = g; \ - *((buf)+2-fmt->Bshift/8) = b; \ - } \ - } \ - break; \ - \ - case 4: { \ - Uint32 *bufp; \ - Uint32 Pixel; \ - \ - bufp = (Uint32 *)buf; \ - PIXEL_FROM_RGB(Pixel, fmt, r, g, b); \ - *bufp = Pixel | (*bufp & Amask); \ - } \ - break; \ - } \ -} /* FIXME: Should we rescale alpha into 0..255 here? */ #define RGBA_FROM_PIXEL(Pixel, fmt, r, g, b, a) \ { \ - r = ((Pixel&fmt->Rmask)>>fmt->Rshift)<Rloss; \ - g = ((Pixel&fmt->Gmask)>>fmt->Gshift)<Gloss; \ - b = ((Pixel&fmt->Bmask)>>fmt->Bshift)<Bloss; \ - a = ((Pixel&fmt->Amask)>>fmt->Ashift)<Aloss; \ + r = SDL_expand_byte[fmt->Rloss][((Pixel&fmt->Rmask)>>fmt->Rshift)]; \ + g = SDL_expand_byte[fmt->Gloss][((Pixel&fmt->Gmask)>>fmt->Gshift)]; \ + b = SDL_expand_byte[fmt->Bloss][((Pixel&fmt->Bmask)>>fmt->Bshift)]; \ + a = SDL_expand_byte[fmt->Aloss][((Pixel&fmt->Amask)>>fmt->Ashift)]; \ } #define RGBA_FROM_8888(Pixel, fmt, r, g, b, a) \ { \ @@ -383,6 +325,7 @@ do { \ break; \ \ case 3: { \ + Pixel = 0; \ if (SDL_BYTEORDER == SDL_LIL_ENDIAN) { \ r = *((buf)+fmt->Rshift/8); \ g = *((buf)+fmt->Gshift/8); \ @@ -402,7 +345,9 @@ do { \ break; \ \ default: \ - Pixel; /* stop gcc complaints */ \ + /* stop gcc complaints */ \ + Pixel = 0; \ + r = g = b = a = 0; \ break; \ } \ } while (0) @@ -422,7 +367,7 @@ do { \ Uint16 Pixel; \ \ PIXEL_FROM_RGBA(Pixel, fmt, r, g, b, a); \ - *((Uint16 *)(buf)) = Pixel; \ + *((Uint16 *)(buf)) = Pixel; \ } \ break; \ \ diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_0.c b/project/jni/sdl-1.3/src/video/SDL_blit_0.c index 200869b35..ad9aa78a2 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_0.c +++ b/project/jni/sdl-1.3/src/video/SDL_blit_0.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_1.c b/project/jni/sdl-1.3/src/video/SDL_blit_1.c index adc0663a5..d6c1d17f0 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_1.c +++ b/project/jni/sdl-1.3/src/video/SDL_blit_1.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -476,7 +475,6 @@ Blit1toNAlphaKey(SDL_BlitInfo * info) int srcskip = info->src_skip; Uint8 *dst = info->dst; int dstskip = info->dst_skip; - SDL_PixelFormat *srcfmt = info->src_fmt; SDL_PixelFormat *dstfmt = info->dst_fmt; const SDL_Color *srcpal = info->src_fmt->palette->colors; Uint32 ckey = info->colorkey; diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_A.c b/project/jni/sdl-1.3/src/video/SDL_blit_A.c index 50f5545b8..d0e9a46b1 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_A.c +++ b/project/jni/sdl-1.3/src/video/SDL_blit_A.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -97,7 +96,6 @@ BlitNto1PixelAlpha(SDL_BlitInfo * info) SDL_PixelFormat *dstfmt = info->dst_fmt; int srcbpp = srcfmt->BytesPerPixel; - /* FIXME: fix alpha bit field expansion here too? */ while (height--) { /* *INDENT-OFF* */ DUFFS_LOOP4( @@ -499,10 +497,11 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt) */ /* ARGB */ const static struct SDL_PixelFormat default_pixel_format = { - NULL, 0, 0, + 0, NULL, 0, 0, 0, 0, 0, 0, 16, 8, 0, 24, - 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 + 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, + 0, NULL }; if (!srcfmt) { srcfmt = &default_pixel_format; @@ -2081,11 +2080,6 @@ BlitNtoNPixelAlpha(SDL_BlitInfo * info) srcbpp = srcfmt->BytesPerPixel; dstbpp = dstfmt->BytesPerPixel; - /* FIXME: for 8bpp source alpha, this doesn't get opaque values - quite right. for <8bpp source alpha, it gets them very wrong - (check all macros!) - It is unclear whether there is a good general solution that doesn't - need a branch (or a divide). */ while (height--) { /* *INDENT-OFF* */ DUFFS_LOOP4( diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_N.c b/project/jni/sdl-1.3/src/video/SDL_blit_N.c index 600153f6c..762a67939 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_N.c +++ b/project/jni/sdl-1.3/src/video/SDL_blit_N.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -29,12 +28,6 @@ /* Functions to blit from N-bit surfaces to other surfaces */ #if SDL_ALTIVEC_BLITTERS -#if __MWERKS__ -#pragma altivec_model on -#endif -#ifdef HAVE_ALTIVEC_H -#include -#endif #define assert(X) #ifdef __MACOSX__ #include @@ -114,10 +107,11 @@ calc_swizzle32(const SDL_PixelFormat * srcfmt, const SDL_PixelFormat * dstfmt) */ /* ARGB */ const static const struct SDL_PixelFormat default_pixel_format = { - NULL, 32, 4, + 0, NULL, 0, 0, 0, 0, 0, 0, 16, 8, 0, 24, - 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000 + 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000, + 0, NULL }; if (!srcfmt) { srcfmt = &default_pixel_format; @@ -2128,7 +2122,6 @@ BlitNtoNCopyAlpha(SDL_BlitInfo * info) int dstbpp = dstfmt->BytesPerPixel; int c; - /* FIXME: should map alpha to [0..255] correctly! */ while (height--) { for (c = width; c; --c) { Uint32 Pixel; @@ -2310,7 +2303,6 @@ BlitNtoNKeyCopyAlpha(SDL_BlitInfo * info) dstbpp = dstfmt->BytesPerPixel; ckey &= rgbmask; - /* FIXME: should map alpha to [0..255] correctly! */ while (height--) { /* *INDENT-OFF* */ DUFFS_LOOP( diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_auto.c b/project/jni/sdl-1.3/src/video/SDL_blit_auto.c index bc07d7332..287f0449e 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_auto.c +++ b/project/jni/sdl-1.3/src/video/SDL_blit_auto.c @@ -1,24 +1,23 @@ /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -30,7 +29,6 @@ static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; int srcy, srcx; int posy, posx; int incy, incx; @@ -41,7 +39,7 @@ static void SDL_Blit_RGB888_RGB888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -92,14 +90,7 @@ static void SDL_Blit_RGB888_RGB888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -143,7 +134,7 @@ static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -172,14 +163,7 @@ static void SDL_Blit_RGB888_RGB888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -260,7 +244,7 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -334,14 +318,7 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -389,7 +366,7 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -426,14 +403,7 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -462,7 +432,6 @@ static void SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -475,7 +444,7 @@ static void SDL_Blit_RGB888_BGR888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -529,14 +498,7 @@ static void SDL_Blit_RGB888_BGR888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -580,7 +542,7 @@ static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -609,14 +571,7 @@ static void SDL_Blit_RGB888_BGR888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -697,7 +652,7 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -771,14 +726,7 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -826,7 +774,7 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -863,14 +811,7 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -899,7 +840,6 @@ static void SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -912,7 +852,7 @@ static void SDL_Blit_RGB888_ARGB8888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -966,14 +906,7 @@ static void SDL_Blit_RGB888_ARGB8888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1017,7 +950,7 @@ static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1046,14 +979,7 @@ static void SDL_Blit_RGB888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1134,7 +1060,7 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1208,14 +1134,7 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1263,7 +1182,7 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1300,14 +1219,7 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1336,7 +1248,6 @@ static void SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -1349,7 +1260,7 @@ static void SDL_Blit_BGR888_RGB888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1403,14 +1314,7 @@ static void SDL_Blit_BGR888_RGB888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1454,7 +1358,7 @@ static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1483,14 +1387,7 @@ static void SDL_Blit_BGR888_RGB888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1571,7 +1468,7 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1645,14 +1542,7 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1700,7 +1590,7 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1737,14 +1627,7 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1773,7 +1656,6 @@ static void SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; int srcy, srcx; int posy, posx; int incy, incx; @@ -1784,7 +1666,7 @@ static void SDL_Blit_BGR888_BGR888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1835,14 +1717,7 @@ static void SDL_Blit_BGR888_BGR888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -1886,7 +1761,7 @@ static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -1915,14 +1790,7 @@ static void SDL_Blit_BGR888_BGR888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2003,7 +1871,7 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2077,14 +1945,7 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2132,7 +1993,7 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2169,14 +2030,7 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2205,7 +2059,6 @@ static void SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -2218,7 +2071,7 @@ static void SDL_Blit_BGR888_ARGB8888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2272,14 +2125,7 @@ static void SDL_Blit_BGR888_ARGB8888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2323,7 +2169,7 @@ static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2352,14 +2198,7 @@ static void SDL_Blit_BGR888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2440,7 +2279,7 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2514,14 +2353,7 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2569,7 +2401,7 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2606,14 +2438,7 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2642,7 +2467,6 @@ static void SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -2655,7 +2479,7 @@ static void SDL_Blit_ARGB8888_RGB888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2709,14 +2533,7 @@ static void SDL_Blit_ARGB8888_RGB888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2760,7 +2577,7 @@ static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2789,14 +2606,7 @@ static void SDL_Blit_ARGB8888_RGB888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -2877,7 +2687,7 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -2951,14 +2761,7 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3006,7 +2809,7 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3043,14 +2846,7 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3079,7 +2875,6 @@ static void SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -3092,7 +2887,7 @@ static void SDL_Blit_ARGB8888_BGR888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3146,14 +2941,7 @@ static void SDL_Blit_ARGB8888_BGR888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3197,7 +2985,7 @@ static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3226,14 +3014,7 @@ static void SDL_Blit_ARGB8888_BGR888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3314,7 +3095,7 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3388,14 +3169,7 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3443,7 +3217,7 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3480,14 +3254,7 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3516,7 +3283,6 @@ static void SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; int srcy, srcx; int posy, posx; int incy, incx; @@ -3527,7 +3293,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3578,14 +3344,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3629,7 +3388,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3658,14 +3417,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3746,7 +3498,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3820,14 +3572,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3875,7 +3620,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -3912,14 +3657,7 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -3948,7 +3686,6 @@ static void SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -3961,7 +3698,7 @@ static void SDL_Blit_RGBA8888_RGB888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4015,14 +3752,7 @@ static void SDL_Blit_RGBA8888_RGB888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4066,7 +3796,7 @@ static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4095,14 +3825,7 @@ static void SDL_Blit_RGBA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4183,7 +3906,7 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4257,14 +3980,7 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4312,7 +4028,7 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4349,14 +4065,7 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4385,7 +4094,6 @@ static void SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -4398,7 +4106,7 @@ static void SDL_Blit_RGBA8888_BGR888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4452,14 +4160,7 @@ static void SDL_Blit_RGBA8888_BGR888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4503,7 +4204,7 @@ static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4532,14 +4233,7 @@ static void SDL_Blit_RGBA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4620,7 +4314,7 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4694,14 +4388,7 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4749,7 +4436,7 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4786,14 +4473,7 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4822,7 +4502,6 @@ static void SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -4835,7 +4514,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4889,14 +4568,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -4940,7 +4612,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -4969,14 +4641,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5057,7 +4722,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -5131,14 +4796,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5186,7 +4844,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -5223,14 +4881,7 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5259,7 +4910,6 @@ static void SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -5272,7 +4922,7 @@ static void SDL_Blit_ABGR8888_RGB888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -5326,14 +4976,7 @@ static void SDL_Blit_ABGR8888_RGB888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5377,7 +5020,7 @@ static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -5406,14 +5049,7 @@ static void SDL_Blit_ABGR8888_RGB888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5494,7 +5130,7 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -5568,14 +5204,7 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5623,7 +5252,7 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -5660,14 +5289,7 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5696,7 +5318,6 @@ static void SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -5709,7 +5330,7 @@ static void SDL_Blit_ABGR8888_BGR888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -5763,14 +5384,7 @@ static void SDL_Blit_ABGR8888_BGR888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5814,7 +5428,7 @@ static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -5843,14 +5457,7 @@ static void SDL_Blit_ABGR8888_BGR888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -5931,7 +5538,7 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6005,14 +5612,7 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6060,7 +5660,7 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6097,14 +5697,7 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6133,7 +5726,6 @@ static void SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -6146,7 +5738,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6200,14 +5792,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6251,7 +5836,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6280,14 +5865,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6368,7 +5946,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6442,14 +6020,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6497,7 +6068,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6534,14 +6105,7 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6570,7 +6134,6 @@ static void SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -6583,7 +6146,7 @@ static void SDL_Blit_BGRA8888_RGB888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6637,14 +6200,7 @@ static void SDL_Blit_BGRA8888_RGB888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6688,7 +6244,7 @@ static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6717,14 +6273,7 @@ static void SDL_Blit_BGRA8888_RGB888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6805,7 +6354,7 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6879,14 +6428,7 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -6934,7 +6476,7 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -6971,14 +6513,7 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7007,7 +6542,6 @@ static void SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -7020,7 +6554,7 @@ static void SDL_Blit_BGRA8888_BGR888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -7074,14 +6608,7 @@ static void SDL_Blit_BGRA8888_BGR888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7125,7 +6652,7 @@ static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -7154,14 +6681,7 @@ static void SDL_Blit_BGRA8888_BGR888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7242,7 +6762,7 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -7316,14 +6836,7 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7371,7 +6884,7 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -7408,14 +6921,7 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7444,7 +6950,6 @@ static void SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale(SDL_BlitInfo *info) static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info) { - const int flags = info->flags; Uint32 pixel; Uint32 R, G, B, A; int srcy, srcx; @@ -7457,7 +6962,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -7511,14 +7016,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7562,7 +7060,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -7591,14 +7089,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7679,7 +7170,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -7753,14 +7244,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7808,7 +7292,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint32 *src; + Uint32 *src = 0; Uint32 *dst = (Uint32 *)info->dst; int n = info->dst_w; srcx = -1; @@ -7845,14 +7329,7 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) srcB = (srcB * srcA) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; @@ -7881,131 +7358,131 @@ static void SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale(SDL_BlitInfo *info) SDL_BlitFuncEntry SDL_GeneratedBlitFuncTable[] = { { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Scale }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Blend_Scale }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Scale }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_RGB888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Scale }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Blend_Scale }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Scale }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_BGR888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Scale }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Blend_Scale }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate }, { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Scale }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend }, - { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGB888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGB888_ARGB8888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Scale }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Blend_Scale }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Scale }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_RGB888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Scale }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Blend_Scale }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Scale }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_BGR888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Scale }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Blend_Scale }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate }, { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Scale }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend }, - { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGR888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGR888_ARGB8888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Scale }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Blend_Scale }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Scale }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_RGB888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Scale }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Blend_Scale }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Scale }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_BGR888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Scale }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Blend_Scale }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate }, { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Scale }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend }, - { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ARGB8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ARGB8888_ARGB8888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Scale }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Blend_Scale }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Scale }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_RGB888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Scale }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Blend_Scale }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Scale }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_BGR888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Scale }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Blend_Scale }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate }, { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Scale }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend }, - { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_RGBA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_RGBA8888_ARGB8888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Scale }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Blend_Scale }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Scale }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_RGB888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Scale }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Blend_Scale }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Scale }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_BGR888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Scale }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Blend_Scale }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate }, { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Scale }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend }, - { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_ABGR8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_ABGR8888_ARGB8888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Scale }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Blend_Scale }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Scale }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_RGB888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_RGB888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Scale }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Blend_Scale }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Scale }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_BGR888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_BGR888_Modulate_Blend_Scale }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Scale }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Blend_Scale }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate }, { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Scale }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend }, - { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend }, + { SDL_PIXELFORMAT_BGRA8888, SDL_PIXELFORMAT_ARGB8888, (SDL_COPY_MODULATE_COLOR | SDL_COPY_MODULATE_ALPHA | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD | SDL_COPY_NEAREST), SDL_CPU_ANY, SDL_Blit_BGRA8888_ARGB8888_Modulate_Blend_Scale }, { 0, 0, 0, 0, NULL } }; diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_auto.h b/project/jni/sdl-1.3/src/video/SDL_blit_auto.h index 47d004ad1..4137c5b9e 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_auto.h +++ b/project/jni/sdl-1.3/src/video/SDL_blit_auto.h @@ -1,24 +1,23 @@ /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_copy.c b/project/jni/sdl-1.3/src/video/SDL_blit_copy.c index 2c8e7de7c..a9f98eb73 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_copy.c +++ b/project/jni/sdl-1.3/src/video/SDL_blit_copy.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -57,45 +56,41 @@ SDL_memcpySSE(Uint8 * dst, const Uint8 * src, int len) #ifdef _MSC_VER #pragma warning(disable:4799) #endif -/* This assumes 8-byte aligned src and dst */ static __inline__ void SDL_memcpyMMX(Uint8 * dst, const Uint8 * src, int len) { + const int remain = (len & 63); int i; - __m64 values[8]; - for (i = len / 64; i--;) { -#ifdef __SSE__ - _mm_prefetch(src, _MM_HINT_NTA); -#endif - values[0] = *(__m64 *) (src + 0); - values[1] = *(__m64 *) (src + 8); - values[2] = *(__m64 *) (src + 16); - values[3] = *(__m64 *) (src + 24); - values[4] = *(__m64 *) (src + 32); - values[5] = *(__m64 *) (src + 40); - values[6] = *(__m64 *) (src + 48); - values[7] = *(__m64 *) (src + 56); - _mm_stream_pi((__m64 *) (dst + 0), values[0]); - _mm_stream_pi((__m64 *) (dst + 8), values[1]); - _mm_stream_pi((__m64 *) (dst + 16), values[2]); - _mm_stream_pi((__m64 *) (dst + 24), values[3]); - _mm_stream_pi((__m64 *) (dst + 32), values[4]); - _mm_stream_pi((__m64 *) (dst + 40), values[5]); - _mm_stream_pi((__m64 *) (dst + 48), values[6]); - _mm_stream_pi((__m64 *) (dst + 56), values[7]); - src += 64; - dst += 64; + __m64* d64 = (__m64*)dst; + __m64* s64 = (__m64*)src; + + for(i= len / 64; i--;) { + d64[0] = s64[0]; + d64[1] = s64[1]; + d64[2] = s64[2]; + d64[3] = s64[3]; + d64[4] = s64[4]; + d64[5] = s64[5]; + d64[6] = s64[6]; + d64[7] = s64[7]; + + d64 += 8; + s64 += 8; } - if (len & 63) - SDL_memcpy(dst, src, len & 63); + if (remain) + { + const int skip = len - remain; + SDL_memcpy(dst + skip, src + skip, remain); + } } #endif /* __MMX__ */ void SDL_BlitCopy(SDL_BlitInfo * info) { + SDL_bool overlap; Uint8 *src, *dst; int w, h; int srcskip, dstskip; @@ -107,6 +102,21 @@ SDL_BlitCopy(SDL_BlitInfo * info) srcskip = info->src_pitch; dstskip = info->dst_pitch; + /* Properly handle overlapping blits */ + if (src < dst) { + overlap = (dst < (src + h*srcskip)); + } else { + overlap = (src < (dst + h*dstskip)); + } + if (overlap) { + while (h--) { + SDL_memmove(dst, src, w); + src += srcskip; + dst += dstskip; + } + return; + } + #ifdef __SSE__ if (SDL_HasSSE() && !((uintptr_t) src & 15) && !(srcskip & 15) && @@ -121,9 +131,7 @@ SDL_BlitCopy(SDL_BlitInfo * info) #endif #ifdef __MMX__ - if (SDL_HasMMX() && - !((uintptr_t) src & 7) && !(srcskip & 7) && - !((uintptr_t) dst & 7) && !(dstskip & 7)) { + if (SDL_HasMMX() && !(srcskip & 7) && !(dstskip & 7)) { while (h--) { SDL_memcpyMMX(dst, src, w); src += srcskip; @@ -141,29 +149,4 @@ SDL_BlitCopy(SDL_BlitInfo * info) } } -void -SDL_BlitCopyOverlap(SDL_BlitInfo * info) -{ - Uint8 *src, *dst; - int w, h; - int skip; - - w = info->dst_w * info->dst_fmt->BytesPerPixel; - h = info->dst_h; - src = info->src; - dst = info->dst; - skip = info->src_pitch; - if ((dst < src) || (dst >= (src + h * skip))) { - SDL_BlitCopy(info); - } else { - src += ((h - 1) * skip); - dst += ((h - 1) * skip); - while (h--) { - SDL_revcpy(dst, src, w); - src -= skip; - dst -= skip; - } - } -} - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_copy.h b/project/jni/sdl-1.3/src/video/SDL_blit_copy.h index 9f79f67fd..84fbef57f 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_copy.h +++ b/project/jni/sdl-1.3/src/video/SDL_blit_copy.h @@ -1,26 +1,24 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ void SDL_BlitCopy(SDL_BlitInfo * info); -void SDL_BlitCopyOverlap(SDL_BlitInfo * info); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_slow.c b/project/jni/sdl-1.3/src/video/SDL_blit_slow.c index d9b43fd23..6e0b924b9 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_slow.c +++ b/project/jni/sdl-1.3/src/video/SDL_blit_slow.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -54,7 +53,7 @@ SDL_Blit_Slow(SDL_BlitInfo * info) incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - Uint8 *src; + Uint8 *src = 0; Uint8 *dst = (Uint8 *) info->dst; int n = info->dst_w; srcx = -1; @@ -117,22 +116,13 @@ SDL_Blit_Slow(SDL_BlitInfo * info) srcB = (srcB * srcA) / 255; } } - switch (flags & - (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | - SDL_COPY_MOD)) { + switch (flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) { case 0: dstR = srcR; dstG = srcG; dstB = srcB; dstA = srcA; break; - case SDL_COPY_MASK: - if (srcA) { - dstR = srcR; - dstG = srcG; - dstB = srcB; - } - break; case SDL_COPY_BLEND: dstR = srcR + ((255 - srcA) * dstR) / 255; dstG = srcG + ((255 - srcA) * dstG) / 255; diff --git a/project/jni/sdl-1.3/src/video/SDL_blit_slow.h b/project/jni/sdl-1.3/src/video/SDL_blit_slow.h index 4b64d2ba8..87b179381 100644 --- a/project/jni/sdl-1.3/src/video/SDL_blit_slow.h +++ b/project/jni/sdl-1.3/src/video/SDL_blit_slow.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/SDL_bmp.c b/project/jni/sdl-1.3/src/video/SDL_bmp.c index e52da0020..f73c84a16 100644 --- a/project/jni/sdl-1.3/src/video/SDL_bmp.c +++ b/project/jni/sdl-1.3/src/video/SDL_bmp.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -37,6 +36,8 @@ #include "SDL_endian.h" #include "SDL_pixels_c.h" +#define SAVE_32BIT_BMP + /* Compression encodings for BMP files */ #ifndef BI_RGB #define BI_RGB 0 @@ -50,7 +51,7 @@ SDL_Surface * SDL_LoadBMP_RW(SDL_RWops * src, int freesrc) { SDL_bool was_error; - long fp_offset; + long fp_offset = 0; int bmpPitch; int i, pad; SDL_Surface *surface; @@ -437,17 +438,15 @@ SDL_SaveBMP_RW(SDL_Surface * saveme, SDL_RWops * dst, int freedst) /* If the surface has a colorkey or alpha channel we'll save a 32-bit BMP with alpha channel, otherwise save a 24-bit BMP. */ if (save32bit) { - SDL_InitFormat(&format, 32, - 0x00FF0000, 0x0000FF00, 0x000000FF, - 0xFF000000); - } else { - SDL_InitFormat(&format, 24, + SDL_InitFormat(&format, #if SDL_BYTEORDER == SDL_LIL_ENDIAN - 0x00FF0000, 0x0000FF00, 0x000000FF, + SDL_PIXELFORMAT_ARGB8888 #else - 0x000000FF, 0x0000FF00, 0x00FF0000, + SDL_PIXELFORMAT_BGRA8888 #endif - 0); + ); + } else { + SDL_InitFormat(&format, SDL_PIXELFORMAT_BGR24); } surface = SDL_ConvertSurface(saveme, &format, 0); if (!surface) { diff --git a/project/jni/sdl-1.3/src/video/SDL_clipboard.c b/project/jni/sdl-1.3/src/video/SDL_clipboard.c index a414fa5ec..3cc233a89 100644 --- a/project/jni/sdl-1.3/src/video/SDL_clipboard.c +++ b/project/jni/sdl-1.3/src/video/SDL_clipboard.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -36,6 +35,9 @@ SDL_SetClipboardText(const char *text) if (_this->SetClipboardText) { return _this->SetClipboardText(_this, text); } else { + if (_this->clipboard_text) { + SDL_free(_this->clipboard_text); + } _this->clipboard_text = SDL_strdup(text); return 0; } @@ -65,7 +67,7 @@ SDL_HasClipboardText(void) if (_this->HasClipboardText) { return _this->HasClipboardText(_this); } else { - if (_this->clipboard_text) { + if ((_this->clipboard_text) && (SDL_strlen(_this->clipboard_text)>0)) { return SDL_TRUE; } else { return SDL_FALSE; diff --git a/project/jni/sdl-1.3/src/video/SDL_drawrect.c b/project/jni/sdl-1.3/src/video/SDL_drawrect.c deleted file mode 100644 index 5685fa7aa..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_drawrect.c +++ /dev/null @@ -1,74 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" - - -int -SDL_DrawRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color) -{ - SDL_Rect full_rect; - SDL_Point points[5]; - - if (!dst) { - SDL_SetError("Passed NULL destination surface"); - return -1; - } - - /* If 'rect' == NULL, then outline the whole surface */ - if (!rect) { - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = dst->w; - full_rect.h = dst->h; - rect = &full_rect; - } - - points[0].x = rect->x; - points[0].y = rect->y; - points[1].x = rect->x+rect->w-1; - points[1].y = rect->y; - points[2].x = rect->x+rect->w-1; - points[2].y = rect->y+rect->h-1; - points[3].x = rect->x; - points[3].y = rect->y+rect->h-1; - points[4].x = rect->x; - points[4].y = rect->y; - return SDL_DrawLines(dst, points, 5, color); -} - -int -SDL_DrawRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, - Uint32 color) -{ - int i; - - for (i = 0; i < count; ++i) { - if (SDL_DrawRect(dst, rects[i], color) < 0) { - return -1; - } - } - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_fillrect.c b/project/jni/sdl-1.3/src/video/SDL_fillrect.c index 05675a03c..c1ea905c7 100644 --- a/project/jni/sdl-1.3/src/video/SDL_fillrect.c +++ b/project/jni/sdl-1.3/src/video/SDL_fillrect.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -417,14 +416,19 @@ SDL_FillRect(SDL_Surface * dst, const SDL_Rect * rect, Uint32 color) } int -SDL_FillRects(SDL_Surface * dst, const SDL_Rect ** rects, int count, +SDL_FillRects(SDL_Surface * dst, const SDL_Rect * rects, int count, Uint32 color) { int i; int status = 0; + if (!rects) { + SDL_SetError("SDL_FillRects() passed NULL rects"); + return -1; + } + for (i = 0; i < count; ++i) { - status = SDL_FillRect(dst, rects[i], color); + status += SDL_FillRect(dst, &rects[i], color); } return status; } diff --git a/project/jni/sdl-1.3/src/video/SDL_gamma.c b/project/jni/sdl-1.3/src/video/SDL_gamma.c deleted file mode 100644 index 4e60c273c..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_gamma.c +++ /dev/null @@ -1,236 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Gamma correction support */ - -#include "SDL_sysvideo.h" - - -static void -CalculateGammaRamp(float gamma, Uint16 * ramp) -{ - int i; - - /* 0.0 gamma is all black */ - if (gamma <= 0.0f) { - for (i = 0; i < 256; ++i) { - ramp[i] = 0; - } - return; - } else - /* 1.0 gamma is identity */ - if (gamma == 1.0f) { - for (i = 0; i < 256; ++i) { - ramp[i] = (i << 8) | i; - } - return; - } else - /* Calculate a real gamma ramp */ - { - int value; - gamma = 1.0f / gamma; - for (i = 0; i < 256; ++i) { - value = - (int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5); - if (value > 65535) { - value = 65535; - } - ramp[i] = (Uint16) value; - } - } -} - -static void -CalculateGammaFromRamp(float *gamma, Uint16 * ramp) -{ - /* The following is adapted from a post by Garrett Bass on OpenGL - Gamedev list, March 4, 2000. - */ - float sum = 0.0f; - int i, count = 0; - - *gamma = 1.0; - for (i = 1; i < 256; ++i) { - if ((ramp[i] != 0) && (ramp[i] != 65535)) { - double B = (double) i / 256.0; - double A = ramp[i] / 65535.0; - sum += (float) (SDL_log(A) / SDL_log(B)); - count++; - } - } - if (count && sum > 0.0f) { - *gamma = 1.0f / (sum / count); - } -} - -int -SDL_SetGamma(float red, float green, float blue) -{ - Uint16 ramp[3][256]; - - CalculateGammaRamp(red, ramp[0]); - CalculateGammaRamp(green, ramp[1]); - CalculateGammaRamp(blue, ramp[2]); - - return SDL_SetGammaRamp(ramp[0], ramp[1], ramp[2]); -} - -/* Calculating the gamma by integrating the gamma ramps isn't exact, - so this function isn't officially supported. -*/ -int -SDL_GetGamma(float *red, float *green, float *blue) -{ - int succeeded; - Uint16 ramp[3][256]; - - succeeded = SDL_GetGammaRamp(ramp[0], ramp[1], ramp[2]); - if (succeeded >= 0) { - CalculateGammaFromRamp(red, ramp[0]); - CalculateGammaFromRamp(green, ramp[1]); - CalculateGammaFromRamp(blue, ramp[2]); - } - return succeeded; -} - -static void -SDL_UninitializedVideo() -{ - SDL_SetError("Video subsystem has not been initialized"); -} - -int -SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue) -{ - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - int succeeded; - - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - - /* Lazily allocate the gamma tables */ - if (!display->gamma) { - if (SDL_GetGammaRampForDisplay(display, NULL, NULL, NULL) < 0) { - return -1; - } - } - - /* Fill the gamma table with the new values */ - if (red) { - SDL_memcpy(&display->gamma[0 * 256], red, 256 * sizeof(*display->gamma)); - } - if (green) { - SDL_memcpy(&display->gamma[1 * 256], green, 256 * sizeof(*display->gamma)); - } - if (blue) { - SDL_memcpy(&display->gamma[2 * 256], blue, 256 * sizeof(*display->gamma)); - } - - /* Try to set the gamma ramp in the driver */ - succeeded = -1; - if (_this && _this->SetDisplayGammaRamp) { - if (SDL_GetFocusWindow()) { - succeeded = - _this->SetDisplayGammaRamp(_this, display, display->gamma); - } else { - succeeded = 0; - } - } else { - SDL_SetError("Gamma ramp manipulation not supported"); - } - return succeeded; -} - -int -SDL_SetGammaRamp(const Uint16 * red, const Uint16 * green, const Uint16 * blue) -{ - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - return SDL_SetGammaRampForDisplay(SDL_CurrentDisplay, red, green, blue); -} - -int -SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue) -{ - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - - /* Lazily allocate the gamma table */ - if (!display->gamma) { - size_t rampsize = (3 * 256 * sizeof(*display->gamma)); - - display->gamma = SDL_malloc(rampsize * 2); - if (!display->gamma) { - SDL_OutOfMemory(); - return -1; - } - if (_this && _this->GetDisplayGammaRamp) { - /* Get the real hardware gamma */ - _this->GetDisplayGammaRamp(_this, display, display->gamma); - } else { - /* Assume an identity gamma */ - int i; - for (i = 0; i < 256; ++i) { - display->gamma[0 * 256 + i] = (i << 8) | i; - display->gamma[1 * 256 + i] = (i << 8) | i; - display->gamma[2 * 256 + i] = (i << 8) | i; - } - } - display->saved_gamma = display->gamma + (3 * 256); - SDL_memcpy(display->saved_gamma, display->gamma, rampsize); - } - - /* Just copy from our internal table */ - if (red) { - SDL_memcpy(red, &display->gamma[0 * 256], 256 * sizeof(*red)); - } - if (green) { - SDL_memcpy(green, &display->gamma[1 * 256], 256 * sizeof(*green)); - } - if (blue) { - SDL_memcpy(blue, &display->gamma[2 * 256], 256 * sizeof(*blue)); - } - return 0; -} - -int -SDL_GetGammaRamp(Uint16 * red, Uint16 * green, Uint16 * blue) -{ - SDL_VideoDevice *_this = SDL_GetVideoDevice(); - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - return SDL_GetGammaRampForDisplay(SDL_CurrentDisplay, red, green, blue); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_glesfuncs.h b/project/jni/sdl-1.3/src/video/SDL_glesfuncs.h deleted file mode 100644 index d8dc79dd5..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_glesfuncs.h +++ /dev/null @@ -1,229 +0,0 @@ -/* list of OpenGL ES functions sorted alphabetically - If you need to use a GLES function from the SDL video subsystem, - change it's entry from SDL_PROC_UNUSED to SDL_PROC and rebuild. -*/ -#define SDL_PROC_UNUSED(ret,func,params) - -SDL_PROC_UNUSED(void, glAlphaFunc, (GLenum func, GLclampf ref)) -SDL_PROC(void, glClearColor, - (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha)) -SDL_PROC_UNUSED(void, glClearDepthf, (GLclampf depth)) -SDL_PROC_UNUSED(void, glClipPlanef, (GLenum plane, const GLfloat * equation)) -SDL_PROC(void, glColor4f, - (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) -SDL_PROC_UNUSED(void, glDepthRangef, (GLclampf zNear, GLclampf zFar)) -SDL_PROC_UNUSED(void, glFogf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glFogfv, (GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glFrustumf, - (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar)) -SDL_PROC_UNUSED(void, glGetClipPlanef, (GLenum pname, GLfloat eqn[4])) -SDL_PROC(void, glGetFloatv, (GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glGetLightfv, - (GLenum light, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glGetMaterialfv, - (GLenum face, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glGetTexEnvfv, - (GLenum env, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glGetTexParameterfv, - (GLenum target, GLenum pname, GLfloat * params)) -SDL_PROC_UNUSED(void, glLightModelf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glLightModelfv, (GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glLightf, (GLenum light, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glLightfv, - (GLenum light, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glLineWidth, (GLfloat width)) -SDL_PROC_UNUSED(void, glLoadMatrixf, (const GLfloat * m)) -SDL_PROC_UNUSED(void, glMaterialf, (GLenum face, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glMaterialfv, - (GLenum face, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glMultMatrixf, (const GLfloat * m)) -SDL_PROC_UNUSED(void, glMultiTexCoord4f, - (GLenum target, GLfloat s, GLfloat t, GLfloat r, GLfloat q)) -SDL_PROC_UNUSED(void, glNormal3f, (GLfloat nx, GLfloat ny, GLfloat nz)) -SDL_PROC(void, glOrthof, - (GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, - GLfloat zNear, GLfloat zFar)) -SDL_PROC_UNUSED(void, glPointParameterf, (GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glPointParameterfv, - (GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glPointSize, (GLfloat size)) -SDL_PROC_UNUSED(void, glPolygonOffset, (GLfloat factor, GLfloat units)) -SDL_PROC_UNUSED(void, glRotatef, - (GLfloat angle, GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC_UNUSED(void, glScalef, (GLfloat x, GLfloat y, GLfloat z)) -SDL_PROC(void, glTexEnvf, (GLenum target, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glTexEnvfv, - (GLenum target, GLenum pname, const GLfloat * params)) -SDL_PROC(void, glTexParameterf, (GLenum target, GLenum pname, GLfloat param)) -SDL_PROC_UNUSED(void, glTexParameterfv, - (GLenum target, GLenum pname, const GLfloat * params)) -SDL_PROC_UNUSED(void, glTranslatef, (GLfloat x, GLfloat y, GLfloat z)) - -/* Available in both Common and Common-Lite profiles */ -SDL_PROC_UNUSED(void, glActiveTexture, (GLenum texture)) -SDL_PROC_UNUSED(void, glAlphaFuncx, (GLenum func, GLclampx ref)) -SDL_PROC_UNUSED(void, glBindBuffer, (GLenum target, GLuint buffer)) -SDL_PROC(void, glBindTexture, (GLenum target, GLuint texture)) -SDL_PROC(void, glBlendFunc, (GLenum sfactor, GLenum dfactor)) -SDL_PROC_UNUSED(void, glBufferData, - (GLenum target, GLsizeiptr size, const GLvoid * data, - GLenum usage)) -SDL_PROC_UNUSED(void, glBufferSubData, - (GLenum target, GLintptr offset, GLsizeiptr size, - const GLvoid * data)) -SDL_PROC(void, glClear, (GLbitfield mask)) -SDL_PROC_UNUSED(void, glClearColorx, - (GLclampx red, GLclampx green, GLclampx blue, GLclampx alpha)) -SDL_PROC_UNUSED(void, glClearDepthx, (GLclampx depth)) -SDL_PROC_UNUSED(void, glClearStencil, (GLint s)) -SDL_PROC_UNUSED(void, glClientActiveTexture, (GLenum texture)) -SDL_PROC_UNUSED(void, glClipPlanex, (GLenum plane, const GLfixed * equation)) -SDL_PROC_UNUSED(void, glColor4ub, - (GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha)) -SDL_PROC_UNUSED(void, glColor4x, - (GLfixed red, GLfixed green, GLfixed blue, GLfixed alpha)) -SDL_PROC_UNUSED(void, glColorMask, - (GLboolean red, GLboolean green, GLboolean blue, - GLboolean alpha)) -SDL_PROC(void, glColorPointer, - (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED(void, glCompressedTexImage2D, - (GLenum target, GLint level, GLenum internalformat, - GLsizei width, GLsizei height, GLint border, - GLsizei imageSize, const GLvoid * data)) -SDL_PROC_UNUSED(void, glCompressedTexSubImage2D, - (GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, GLenum format, - GLsizei imageSize, const GLvoid * data)) -SDL_PROC_UNUSED(void, glCopyTexImage2D, - (GLenum target, GLint level, GLenum internalformat, GLint x, - GLint y, GLsizei width, GLsizei height, GLint border)) -SDL_PROC_UNUSED(void, glCopyTexSubImage2D, - (GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLint x, GLint y, GLsizei width, GLsizei height)) -SDL_PROC_UNUSED(void, glCullFace, (GLenum mode)) -SDL_PROC_UNUSED(void, glDeleteBuffers, (GLsizei n, const GLuint * buffers)) -SDL_PROC_UNUSED(void, glDeleteTextures, (GLsizei n, const GLuint * textures)) -SDL_PROC_UNUSED(void, glDepthFunc, (GLenum func)) -SDL_PROC_UNUSED(void, glDepthMask, (GLboolean flag)) -SDL_PROC_UNUSED(void, glDepthRangex, (GLclampx zNear, GLclampx zFar)) -SDL_PROC(void, glDisable, (GLenum cap)) -SDL_PROC(void, glDisableClientState, (GLenum array)) -SDL_PROC(void, glDrawArrays, (GLenum mode, GLint first, GLsizei count)) -SDL_PROC_UNUSED(void, glDrawElements, - (GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices)) -SDL_PROC(void, glEnable, (GLenum cap)) -SDL_PROC(void, glEnableClientState, (GLenum array)) -SDL_PROC_UNUSED(void, glFinish, (void)) -SDL_PROC_UNUSED(void, glFlush, (void)) -SDL_PROC_UNUSED(void, glFogx, (GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glFogxv, (GLenum pname, const GLfixed * params)) -SDL_PROC_UNUSED(void, glFrontFace, (GLenum mode)) -SDL_PROC_UNUSED(void, glFrustumx, - (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, - GLfixed zNear, GLfixed zFar)) -SDL_PROC_UNUSED(void, glGetBooleanv, (GLenum pname, GLboolean * params)) -SDL_PROC_UNUSED(void, glGetBufferParameteriv, - (GLenum target, GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetClipPlanex, (GLenum pname, GLfixed eqn[4])) -SDL_PROC_UNUSED(void, glGenBuffers, (GLsizei n, GLuint * buffers)) -SDL_PROC(void, glGenTextures, (GLsizei n, GLuint * textures)) -SDL_PROC(GLenum, glGetError, (void)) -SDL_PROC_UNUSED(void, glGetFixedv, (GLenum pname, GLfixed * params)) -SDL_PROC(void, glGetIntegerv, (GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetLightxv, - (GLenum light, GLenum pname, GLfixed * params)) -SDL_PROC_UNUSED(void, glGetMaterialxv, - (GLenum face, GLenum pname, GLfixed * params)) -SDL_PROC_UNUSED(void, glGetPointerv, (GLenum pname, void **params)) -SDL_PROC_UNUSED(const GLubyte *, glGetString, (GLenum name)) -SDL_PROC_UNUSED(void, glGetTexEnviv, - (GLenum env, GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetTexEnvxv, - (GLenum env, GLenum pname, GLfixed * params)) -SDL_PROC_UNUSED(void, glGetTexParameteriv, - (GLenum target, GLenum pname, GLint * params)) -SDL_PROC_UNUSED(void, glGetTexParameterxv, - (GLenum target, GLenum pname, GLfixed * params)) -SDL_PROC_UNUSED(void, glHint, (GLenum target, GLenum mode)) -SDL_PROC_UNUSED(GLboolean, glIsBuffer, (GLuint buffer)) -SDL_PROC_UNUSED(GLboolean, glIsEnabled, (GLenum cap)) -SDL_PROC_UNUSED(GLboolean, glIsTexture, (GLuint texture)) -SDL_PROC_UNUSED(void, glLightModelx, (GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glLightModelxv, (GLenum pname, const GLfixed * params)) -SDL_PROC_UNUSED(void, glLightx, (GLenum light, GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glLightxv, - (GLenum light, GLenum pname, const GLfixed * params)) -SDL_PROC_UNUSED(void, glLineWidthx, (GLfixed width)) -SDL_PROC(void, glLoadIdentity, (void)) -SDL_PROC_UNUSED(void, glLoadMatrixx, (const GLfixed * m)) -SDL_PROC_UNUSED(void, glLogicOp, (GLenum opcode)) -SDL_PROC_UNUSED(void, glMaterialx, (GLenum face, GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glMaterialxv, - (GLenum face, GLenum pname, const GLfixed * params)) -SDL_PROC(void, glMatrixMode, (GLenum mode)) -SDL_PROC_UNUSED(void, glMultMatrixx, (const GLfixed * m)) -SDL_PROC_UNUSED(void, glMultiTexCoord4x, - (GLenum target, GLfixed s, GLfixed t, GLfixed r, GLfixed q)) -SDL_PROC_UNUSED(void, glNormal3x, (GLfixed nx, GLfixed ny, GLfixed nz)) -SDL_PROC_UNUSED(void, glNormalPointer, - (GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED(void, glOrthox, - (GLfixed left, GLfixed right, GLfixed bottom, GLfixed top, - GLfixed zNear, GLfixed zFar)) -SDL_PROC(void, glPixelStorei, (GLenum pname, GLint param)) -SDL_PROC_UNUSED(void, glPointParameterx, (GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glPointParameterxv, - (GLenum pname, const GLfixed * params)) -SDL_PROC_UNUSED(void, glPointSizex, (GLfixed size)) -SDL_PROC_UNUSED(void, glPolygonOffsetx, (GLfixed factor, GLfixed units)) -SDL_PROC_UNUSED(void, glPopMatrix, (void)) -SDL_PROC_UNUSED(void, glPushMatrix, (void)) -SDL_PROC_UNUSED(void, glReadPixels, - (GLint x, GLint y, GLsizei width, GLsizei height, - GLenum format, GLenum type, GLvoid * pixels)) -SDL_PROC_UNUSED(void, glRotatex, - (GLfixed angle, GLfixed x, GLfixed y, GLfixed z)) -SDL_PROC_UNUSED(void, glSampleCoverage, (GLclampf value, GLboolean invert)) -SDL_PROC_UNUSED(void, glSampleCoveragex, (GLclampx value, GLboolean invert)) -SDL_PROC_UNUSED(void, glScalex, (GLfixed x, GLfixed y, GLfixed z)) -SDL_PROC(void, glScissor, (GLint x, GLint y, GLsizei width, GLsizei height)) -SDL_PROC_UNUSED(void, glShadeModel, (GLenum mode)) -SDL_PROC_UNUSED(void, glStencilFunc, (GLenum func, GLint ref, GLuint mask)) -SDL_PROC_UNUSED(void, glStencilMask, (GLuint mask)) -SDL_PROC_UNUSED(void, glStencilOp, (GLenum fail, GLenum zfail, GLenum zpass)) -SDL_PROC(void, glTexCoordPointer, - (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC_UNUSED(void, glTexEnvi, (GLenum target, GLenum pname, GLint param)) -SDL_PROC_UNUSED(void, glTexEnvx, (GLenum target, GLenum pname, GLfixed param)) -SDL_PROC_UNUSED(void, glTexEnviv, - (GLenum target, GLenum pname, const GLint * params)) -SDL_PROC_UNUSED(void, glTexEnvxv, - (GLenum target, GLenum pname, const GLfixed * params)) -SDL_PROC(void, glTexImage2D, - (GLenum target, GLint level, GLint internalformat, GLsizei width, - GLsizei height, GLint border, GLenum format, GLenum type, - const GLvoid * pixels)) -SDL_PROC(void, glTexParameteri, (GLenum target, GLenum pname, GLint param)) -SDL_PROC_UNUSED(void, glTexParameterx, - (GLenum target, GLenum pname, GLfixed param)) -SDL_PROC(void, glTexParameteriv, - (GLenum target, GLenum pname, const GLint * params)) -SDL_PROC_UNUSED(void, glTexParameterxv, - (GLenum target, GLenum pname, const GLfixed * params)) -SDL_PROC(void, glTexSubImage2D, - (GLenum target, GLint level, GLint xoffset, GLint yoffset, - GLsizei width, GLsizei height, GLenum format, GLenum type, - const GLvoid * pixels)) -SDL_PROC_UNUSED(void, glTranslatex, (GLfixed x, GLfixed y, GLfixed z)) -SDL_PROC(void, glVertexPointer, - (GLint size, GLenum type, GLsizei stride, const GLvoid * pointer)) -SDL_PROC(void, glViewport, (GLint x, GLint y, GLsizei width, GLsizei height)) - -/* extension functions used */ -SDL_PROC(void, glDrawTexiOES, - (GLint x, GLint y, GLint z, GLint width, GLint height)) - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_leaks.h b/project/jni/sdl-1.3/src/video/SDL_leaks.h deleted file mode 100644 index 8e017c89b..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_leaks.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Define this if you want surface leak detection code enabled */ -/*#define CHECK_LEAKS*/ - -/* Global variables used to check leaks in code using SDL */ - -#ifdef CHECK_LEAKS -extern int surfaces_allocated; -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_pixels.c b/project/jni/sdl-1.3/src/video/SDL_pixels.c index f5e2dcb34..30af46f1c 100644 --- a/project/jni/sdl-1.3/src/video/SDL_pixels.c +++ b/project/jni/sdl-1.3/src/video/SDL_pixels.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -30,11 +29,55 @@ #include "SDL_pixels_c.h" #include "SDL_RLEaccel_c.h" -struct SDL_PaletteWatch -{ - SDL_PaletteChangedFunc callback; - void *userdata; - struct SDL_PaletteWatch *next; + +/* Lookup tables to expand partial bytes to the full 0..255 range */ + +static Uint8 lookup_0[] = { +0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 191, 192, 193, 194, 195, 196, 197, 198, 199, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, 224, 225, 226, 227, 228, 229, 230, 231, 232, 233, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 249, 250, 251, 252, 253, 254, 255 +}; + +static Uint8 lookup_1[] = { +0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 42, 44, 46, 48, 50, 52, 54, 56, 58, 60, 62, 64, 66, 68, 70, 72, 74, 76, 78, 80, 82, 84, 86, 88, 90, 92, 94, 96, 98, 100, 102, 104, 106, 108, 110, 112, 114, 116, 118, 120, 122, 124, 126, 128, 130, 132, 134, 136, 138, 140, 142, 144, 146, 148, 150, 152, 154, 156, 158, 160, 162, 164, 166, 168, 170, 172, 174, 176, 178, 180, 182, 184, 186, 188, 190, 192, 194, 196, 198, 200, 202, 204, 206, 208, 210, 212, 214, 216, 218, 220, 222, 224, 226, 228, 230, 232, 234, 236, 238, 240, 242, 244, 246, 248, 250, 252, 255 +}; + +static Uint8 lookup_2[] = { +0, 4, 8, 12, 16, 20, 24, 28, 32, 36, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80, 85, 89, 93, 97, 101, 105, 109, 113, 117, 121, 125, 129, 133, 137, 141, 145, 149, 153, 157, 161, 165, 170, 174, 178, 182, 186, 190, 194, 198, 202, 206, 210, 214, 218, 222, 226, 230, 234, 238, 242, 246, 250, 255 +}; + +static Uint8 lookup_3[] = { +0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255 +}; + +static Uint8 lookup_4[] = { +0, 17, 34, 51, 68, 85, 102, 119, 136, 153, 170, 187, 204, 221, 238, 255 +}; + +static Uint8 lookup_5[] = { +0, 36, 72, 109, 145, 182, 218, 255 +}; + +static Uint8 lookup_6[] = { +0, 85, 170, 255 +}; + +static Uint8 lookup_7[] = { +0, 255 +}; + +static Uint8 lookup_8[] = { +255 +}; + +Uint8* SDL_expand_byte[9] = { + lookup_0, + lookup_1, + lookup_2, + lookup_3, + lookup_4, + lookup_5, + lookup_6, + lookup_7, + lookup_8 }; /* Helper functions */ @@ -66,7 +109,9 @@ SDL_GetPixelFormatName(Uint32 format) CASE(SDL_PIXELFORMAT_RGB24) CASE(SDL_PIXELFORMAT_BGR24) CASE(SDL_PIXELFORMAT_RGB888) + CASE(SDL_PIXELFORMAT_RGBX8888) CASE(SDL_PIXELFORMAT_BGR888) + CASE(SDL_PIXELFORMAT_BGRX8888) CASE(SDL_PIXELFORMAT_ARGB8888) CASE(SDL_PIXELFORMAT_RGBA8888) CASE(SDL_PIXELFORMAT_ABGR8888) @@ -89,6 +134,12 @@ SDL_PixelFormatEnumToMasks(Uint32 format, int *bpp, Uint32 * Rmask, { Uint32 masks[4]; + /* This function doesn't work with FourCC pixel formats */ + if (SDL_ISPIXELFORMAT_FOURCC(format)) { + SDL_SetError("FOURCC pixel formats are not supported"); + return SDL_FALSE; + } + /* Initialize the values here */ if (SDL_BYTESPERPIXEL(format) <= 2) { *bpp = SDL_BITSPERPIXEL(format); @@ -241,54 +292,119 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { switch (bpp) { + case 1: + /* SDL defaults to MSB ordering */ + return SDL_PIXELFORMAT_INDEX1MSB; + case 4: + /* SDL defaults to MSB ordering */ + return SDL_PIXELFORMAT_INDEX4MSB; case 8: - switch (Rmask) { - case 0: + if (Rmask == 0) { return SDL_PIXELFORMAT_INDEX8; - case 0xE0: + } + if (Rmask == 0xE0 && + Gmask == 0x1C && + Bmask == 0x03 && + Amask == 0x00) { return SDL_PIXELFORMAT_RGB332; } break; case 12: - switch (Rmask) { - case 0x0F00: + if (Rmask == 0) { + return SDL_PIXELFORMAT_RGB444; + } + if (Rmask == 0x0F00 && + Gmask == 0x00F0 && + Bmask == 0x000F && + Amask == 0x0000) { return SDL_PIXELFORMAT_RGB444; } break; case 15: - switch (Rmask) { - case 0x001F: - return SDL_PIXELFORMAT_BGR555; - case 0x7C00: + if (Rmask == 0) { return SDL_PIXELFORMAT_RGB555; } - break; + /* Fall through to 16-bit checks */ case 16: - switch (Rmask) { - case 0xF000: - return SDL_PIXELFORMAT_RGBA4444; - case 0x0F00: + if (Rmask == 0) { + return SDL_PIXELFORMAT_RGB565; + } + if (Rmask == 0x7C00 && + Gmask == 0x03E0 && + Bmask == 0x001F && + Amask == 0x0000) { + return SDL_PIXELFORMAT_RGB555; + } + if (Rmask == 0x001F && + Gmask == 0x03E0 && + Bmask == 0x7C00 && + Amask == 0x0000) { + return SDL_PIXELFORMAT_BGR555; + } + if (Rmask == 0x0F00 && + Gmask == 0x00F0 && + Bmask == 0x000F && + Amask == 0xF000) { return SDL_PIXELFORMAT_ARGB4444; - case 0x00F0: - return SDL_PIXELFORMAT_BGRA4444; - case 0x000F: + } + if (Rmask == 0xF000 && + Gmask == 0x0F00 && + Bmask == 0x00F0 && + Amask == 0x000F) { + return SDL_PIXELFORMAT_RGBA4444; + } + if (Rmask == 0x000F && + Gmask == 0x00F0 && + Bmask == 0x0F00 && + Amask == 0xF000) { return SDL_PIXELFORMAT_ABGR4444; - case 0x001F: - if (Gmask == 0x07E0) { - return SDL_PIXELFORMAT_BGR565; - } - return SDL_PIXELFORMAT_ABGR1555; - case 0x7C00: + } + if (Rmask == 0x00F0 && + Gmask == 0x0F00 && + Bmask == 0xF000 && + Amask == 0x000F) { + return SDL_PIXELFORMAT_BGRA4444; + } + if (Rmask == 0x7C00 && + Gmask == 0x03E0 && + Bmask == 0x001F && + Amask == 0x8000) { return SDL_PIXELFORMAT_ARGB1555; - case 0xF800: - if (Gmask == 0x07E0) { - return SDL_PIXELFORMAT_RGB565; - } + } + if (Rmask == 0xF800 && + Gmask == 0x07C0 && + Bmask == 0x003E && + Amask == 0x0001) { return SDL_PIXELFORMAT_RGBA5551; } + if (Rmask == 0x001F && + Gmask == 0x03E0 && + Bmask == 0x7C00 && + Amask == 0x8000) { + return SDL_PIXELFORMAT_ABGR1555; + } + if (Rmask == 0x003E && + Gmask == 0x07C0 && + Bmask == 0xF800 && + Amask == 0x0001) { + return SDL_PIXELFORMAT_BGRA5551; + } + if (Rmask == 0xF800 && + Gmask == 0x07E0 && + Bmask == 0x001F && + Amask == 0x0000) { + return SDL_PIXELFORMAT_RGB565; + } + if (Rmask == 0x001F && + Gmask == 0x07E0 && + Bmask == 0xF800 && + Amask == 0x0000) { + return SDL_PIXELFORMAT_BGR565; + } break; case 24: switch (Rmask) { + case 0: case 0x00FF0000: #if SDL_BYTEORDER == SDL_BIG_ENDIAN return SDL_PIXELFORMAT_RGB24; @@ -301,44 +417,197 @@ SDL_MasksToPixelFormatEnum(int bpp, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, #else return SDL_PIXELFORMAT_RGB24; #endif - case 0x00000000: - /* FIXME: At this point we can't distinguish */ - /* if this format is RGB24 or BGR24 */ - return SDL_PIXELFORMAT_RGB24; } case 32: - switch (Rmask) { - case 0xFF000000: - if (Amask == 0x000000FF) { - return SDL_PIXELFORMAT_RGBA8888; - } - break; - case 0x00FF0000: - if (Amask == 0xFF000000) { - return SDL_PIXELFORMAT_ARGB8888; - } else { - return SDL_PIXELFORMAT_RGB888; - } - break; - case 0x0000FF00: - if (Amask == 0x000000FF) { - return SDL_PIXELFORMAT_BGRA8888; - } - break; - case 0x000000FF: - if (Amask == 0xFF000000) { - return SDL_PIXELFORMAT_ABGR8888; - } else { - return SDL_PIXELFORMAT_BGR888; - } - break; - case 0x3FF00000: + if (Rmask == 0) { + return SDL_PIXELFORMAT_RGB888; + } + if (Rmask == 0x00FF0000 && + Gmask == 0x0000FF00 && + Bmask == 0x000000FF && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_RGB888; + } + if (Rmask == 0xFF000000 && + Gmask == 0x00FF0000 && + Bmask == 0x0000FF00 && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_RGBX8888; + } + if (Rmask == 0x000000FF && + Gmask == 0x0000FF00 && + Bmask == 0x00FF0000 && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_BGR888; + } + if (Rmask == 0x0000FF00 && + Gmask == 0x00FF0000 && + Bmask == 0xFF000000 && + Amask == 0x00000000) { + return SDL_PIXELFORMAT_BGRX8888; + } + if (Rmask == 0x00FF0000 && + Gmask == 0x0000FF00 && + Bmask == 0x000000FF && + Amask == 0xFF000000) { + return SDL_PIXELFORMAT_ARGB8888; + } + if (Rmask == 0xFF000000 && + Gmask == 0x00FF0000 && + Bmask == 0x0000FF00 && + Amask == 0x000000FF) { + return SDL_PIXELFORMAT_RGBA8888; + } + if (Rmask == 0x000000FF && + Gmask == 0x0000FF00 && + Bmask == 0x00FF0000 && + Amask == 0xFF000000) { + return SDL_PIXELFORMAT_ABGR8888; + } + if (Rmask == 0x0000FF00 && + Gmask == 0x00FF0000 && + Bmask == 0xFF000000 && + Amask == 0x000000FF) { + return SDL_PIXELFORMAT_BGRA8888; + } + if (Rmask == 0x3FF00000 && + Gmask == 0x000FFC00 && + Bmask == 0x000003FF && + Amask == 0xC0000000) { return SDL_PIXELFORMAT_ARGB2101010; } } return SDL_PIXELFORMAT_UNKNOWN; } +static SDL_PixelFormat *formats; + +SDL_PixelFormat * +SDL_AllocFormat(Uint32 pixel_format) +{ + SDL_PixelFormat *format; + + /* Look it up in our list of previously allocated formats */ + for (format = formats; format; format = format->next) { + if (pixel_format == format->format) { + ++format->refcount; + return format; + } + } + + /* Allocate an empty pixel format structure, and initialize it */ + format = SDL_malloc(sizeof(*format)); + if (format == NULL) { + SDL_OutOfMemory(); + return NULL; + } + if (SDL_InitFormat(format, pixel_format) < 0) { + SDL_free(format); + return NULL; + } + + if (!SDL_ISPIXELFORMAT_INDEXED(pixel_format)) { + /* Cache the RGB formats */ + format->next = formats; + formats = format; + } + return format; +} + +int +SDL_InitFormat(SDL_PixelFormat * format, Uint32 pixel_format) +{ + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + Uint32 mask; + + if (!SDL_PixelFormatEnumToMasks(pixel_format, &bpp, + &Rmask, &Gmask, &Bmask, &Amask)) { + return -1; + } + + /* Set up the format */ + SDL_zerop(format); + format->format = pixel_format; + format->BitsPerPixel = bpp; + format->BytesPerPixel = (bpp + 7) / 8; + + format->Rmask = Rmask; + format->Rshift = 0; + format->Rloss = 8; + if (Rmask) { + for (mask = Rmask; !(mask & 0x01); mask >>= 1) + ++format->Rshift; + for (; (mask & 0x01); mask >>= 1) + --format->Rloss; + } + + format->Gmask = Gmask; + format->Gshift = 0; + format->Gloss = 8; + if (Gmask) { + for (mask = Gmask; !(mask & 0x01); mask >>= 1) + ++format->Gshift; + for (; (mask & 0x01); mask >>= 1) + --format->Gloss; + } + + format->Bmask = Bmask; + format->Bshift = 0; + format->Bloss = 8; + if (Bmask) { + for (mask = Bmask; !(mask & 0x01); mask >>= 1) + ++format->Bshift; + for (; (mask & 0x01); mask >>= 1) + --format->Bloss; + } + + format->Amask = Amask; + format->Ashift = 0; + format->Aloss = 8; + if (Amask) { + for (mask = Amask; !(mask & 0x01); mask >>= 1) + ++format->Ashift; + for (; (mask & 0x01); mask >>= 1) + --format->Aloss; + } + + format->palette = NULL; + format->refcount = 1; + format->next = NULL; + + return 0; +} + +void +SDL_FreeFormat(SDL_PixelFormat *format) +{ + SDL_PixelFormat *prev; + + if (!format) { + return; + } + if (--format->refcount > 0) { + return; + } + + /* Remove this format from our list */ + if (format == formats) { + formats = format->next; + } else if (formats) { + for (prev = formats; prev->next; prev = prev->next) { + if (prev->next == format) { + prev->next = format->next; + break; + } + } + } + + if (format->palette) { + SDL_FreePalette(format->palette); + } + SDL_free(format); +} SDL_Palette * SDL_AllocPalette(int ncolors) @@ -357,7 +626,7 @@ SDL_AllocPalette(int ncolors) return NULL; } palette->ncolors = ncolors; - palette->watch = NULL; + palette->version = 1; palette->refcount = 1; SDL_memset(palette->colors, 0xFF, ncolors * sizeof(*palette->colors)); @@ -366,59 +635,39 @@ SDL_AllocPalette(int ncolors) } int -SDL_AddPaletteWatch(SDL_Palette * palette, SDL_PaletteChangedFunc callback, - void *userdata) +SDL_SetPixelFormatPalette(SDL_PixelFormat * format, SDL_Palette *palette) { - SDL_PaletteWatch *watch; - - if (!palette) { + if (!format) { + SDL_SetError("SDL_SetPixelFormatPalette() passed NULL format"); return -1; } - watch = (SDL_PaletteWatch *) SDL_malloc(sizeof(*watch)); - if (!watch) { - SDL_OutOfMemory(); + if (palette && palette->ncolors != (1 << format->BitsPerPixel)) { + SDL_SetError("SDL_SetPixelFormatPalette() passed a palette that doesn't match the format"); return -1; } - watch->callback = callback; - watch->userdata = userdata; - watch->next = palette->watch; - palette->watch = watch; - ++palette->refcount; + if (format->palette == palette) { + return 0; + } + + if (format->palette) { + SDL_FreePalette(format->palette); + } + + format->palette = palette; + + if (format->palette) { + ++format->palette->refcount; + } + return 0; } -void -SDL_DelPaletteWatch(SDL_Palette * palette, SDL_PaletteChangedFunc callback, - void *userdata) -{ - SDL_PaletteWatch *prev, *watch; - - if (!palette) { - return; - } - - for (prev = NULL, watch = palette->watch; watch; - prev = watch, watch = watch->next) { - if (watch->callback == callback && watch->userdata == userdata) { - if (prev) { - prev->next = watch->next; - } else { - palette->watch = watch->next; - } - SDL_free(watch); - SDL_FreePalette(palette); - return; - } - } -} - int SDL_SetPaletteColors(SDL_Palette * palette, const SDL_Color * colors, int firstcolor, int ncolors) { - SDL_PaletteWatch *watch; int status = 0; /* Verify the parameters */ @@ -434,11 +683,9 @@ SDL_SetPaletteColors(SDL_Palette * palette, const SDL_Color * colors, SDL_memcpy(palette->colors + firstcolor, colors, ncolors * sizeof(*colors)); } - - for (watch = palette->watch; watch; watch = watch->next) { - if (watch->callback(watch->userdata, palette) < 0) { - status = -1; - } + ++palette->version; + if (!palette->version) { + palette->version = 1; } return status; @@ -459,133 +706,6 @@ SDL_FreePalette(SDL_Palette * palette) SDL_free(palette); } -/* - * Allocate a pixel format structure and fill it according to the given info. - */ -SDL_PixelFormat * -SDL_AllocFormat(int bpp, - Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) -{ - SDL_PixelFormat *format; - - /* Allocate an empty pixel format structure */ - format = SDL_malloc(sizeof(*format)); - if (format == NULL) { - SDL_OutOfMemory(); - return (NULL); - } - - /* Set up the format */ - return SDL_InitFormat(format, bpp, Rmask, Gmask, Bmask, Amask); -} - -SDL_PixelFormat * -SDL_InitFormat(SDL_PixelFormat * format, int bpp, Uint32 Rmask, Uint32 Gmask, - Uint32 Bmask, Uint32 Amask) -{ - Uint32 mask; - - /* Set up the format */ - SDL_zerop(format); - format->BitsPerPixel = bpp; - format->BytesPerPixel = (bpp + 7) / 8; - if (Rmask || Bmask || Gmask) { /* Packed pixels with custom mask */ - format->Rshift = 0; - format->Rloss = 8; - if (Rmask) { - for (mask = Rmask; !(mask & 0x01); mask >>= 1) - ++format->Rshift; - for (; (mask & 0x01); mask >>= 1) - --format->Rloss; - } - format->Gshift = 0; - format->Gloss = 8; - if (Gmask) { - for (mask = Gmask; !(mask & 0x01); mask >>= 1) - ++format->Gshift; - for (; (mask & 0x01); mask >>= 1) - --format->Gloss; - } - format->Bshift = 0; - format->Bloss = 8; - if (Bmask) { - for (mask = Bmask; !(mask & 0x01); mask >>= 1) - ++format->Bshift; - for (; (mask & 0x01); mask >>= 1) - --format->Bloss; - } - format->Ashift = 0; - format->Aloss = 8; - if (Amask) { - for (mask = Amask; !(mask & 0x01); mask >>= 1) - ++format->Ashift; - for (; (mask & 0x01); mask >>= 1) - --format->Aloss; - } - format->Rmask = Rmask; - format->Gmask = Gmask; - format->Bmask = Bmask; - format->Amask = Amask; - } else if (bpp > 8) { /* Packed pixels with standard mask */ - /* R-G-B */ - if (bpp > 24) - bpp = 24; - format->Rloss = 8 - (bpp / 3); - format->Gloss = 8 - (bpp / 3) - (bpp % 3); - format->Bloss = 8 - (bpp / 3); - format->Rshift = ((bpp / 3) + (bpp % 3)) + (bpp / 3); - format->Gshift = (bpp / 3); - format->Bshift = 0; - format->Rmask = ((0xFF >> format->Rloss) << format->Rshift); - format->Gmask = ((0xFF >> format->Gloss) << format->Gshift); - format->Bmask = ((0xFF >> format->Bloss) << format->Bshift); - } else { - /* Palettized formats have no mask info */ - format->Rloss = 8; - format->Gloss = 8; - format->Bloss = 8; - format->Aloss = 8; - format->Rshift = 0; - format->Gshift = 0; - format->Bshift = 0; - format->Ashift = 0; - format->Rmask = 0; - format->Gmask = 0; - format->Bmask = 0; - format->Amask = 0; - } - format->palette = NULL; - - return format; -} - -/* - * Change any previous mappings from/to the new surface format - */ -void -SDL_FormatChanged(SDL_Surface * surface) -{ - static int format_version = 0; - ++format_version; - if (format_version < 0) { /* It wrapped... */ - format_version = 1; - } - surface->format_version = format_version; - SDL_InvalidateMap(surface->map); -} - -/* - * Free a previously allocated format structure - */ -void -SDL_FreeFormat(SDL_PixelFormat * format) -{ - if (!format) { - return; - } - SDL_free(format); -} - /* * Calculate an 8-bit (3 red, 3 green, 2 blue) dithered palette of colors */ @@ -634,7 +754,7 @@ SDL_CalculatePitch(SDL_Surface * surface) default: break; } -#ifdef ANDROID +#ifdef __ANDROID__ if( surface->format->BytesPerPixel != 2 ) /* Avoid extra memcpy() when calling SDL_UpdateTexture() */ #endif pitch = (pitch + 3) & ~3; /* 4-byte aligning */ @@ -704,25 +824,21 @@ SDL_GetRGB(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g, Uint8 * b) { if (format->palette == NULL) { - /* - * This makes sure that the result is mapped to the - * interval [0..255], and the maximum value for each - * component is 255. This is important to make sure - * that white is indeed reported as (255, 255, 255). - * This only works for RGB bit fields at least 4 bit - * wide, which is almost always the case. - */ unsigned v; v = (pixel & format->Rmask) >> format->Rshift; - *r = (v << format->Rloss) + (v >> (8 - (format->Rloss << 1))); + *r = SDL_expand_byte[format->Rloss][v]; v = (pixel & format->Gmask) >> format->Gshift; - *g = (v << format->Gloss) + (v >> (8 - (format->Gloss << 1))); + *g = SDL_expand_byte[format->Gloss][v]; v = (pixel & format->Bmask) >> format->Bshift; - *b = (v << format->Bloss) + (v >> (8 - (format->Bloss << 1))); + *b = SDL_expand_byte[format->Bloss][v]; } else { - *r = format->palette->colors[pixel].r; - *g = format->palette->colors[pixel].g; - *b = format->palette->colors[pixel].b; + if (pixel < (unsigned)format->palette->ncolors) { + *r = format->palette->colors[pixel].r; + *g = format->palette->colors[pixel].g; + *b = format->palette->colors[pixel].b; + } else { + *r = *g = *b = 0; + } } } @@ -731,47 +847,24 @@ SDL_GetRGBA(Uint32 pixel, const SDL_PixelFormat * format, Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) { if (format->palette == NULL) { - /* - * This makes sure that the result is mapped to the - * interval [0..255], and the maximum value for each - * component is 255. This is important to make sure - * that white is indeed reported as (255, 255, 255), - * and that opaque alpha is 255. - * This only works for RGB bit fields at least 4 bit - * wide, which is almost always the case. - */ unsigned v; v = (pixel & format->Rmask) >> format->Rshift; - *r = (v << format->Rloss) + (v >> (8 - (format->Rloss << 1))); + *r = SDL_expand_byte[format->Rloss][v]; v = (pixel & format->Gmask) >> format->Gshift; - *g = (v << format->Gloss) + (v >> (8 - (format->Gloss << 1))); + *g = SDL_expand_byte[format->Gloss][v]; v = (pixel & format->Bmask) >> format->Bshift; - *b = (v << format->Bloss) + (v >> (8 - (format->Bloss << 1))); - if (format->Amask) { - v = (pixel & format->Amask) >> format->Ashift; - *a = (v << format->Aloss) + (v >> (8 - (format->Aloss << 1))); - } else { - *a = SDL_ALPHA_OPAQUE; - } + *b = SDL_expand_byte[format->Bloss][v]; + v = (pixel & format->Amask) >> format->Ashift; + *a = SDL_expand_byte[format->Aloss][v]; } else { - *r = format->palette->colors[pixel].r; - *g = format->palette->colors[pixel].g; - *b = format->palette->colors[pixel].b; - *a = SDL_ALPHA_OPAQUE; - } -} - -/* Apply gamma to a set of colors - this is easy. :) */ -void -SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors, SDL_Color * output, - int ncolors) -{ - int i; - - for (i = 0; i < ncolors; ++i) { - output[i].r = gamma[0 * 256 + colors[i].r] >> 8; - output[i].g = gamma[1 * 256 + colors[i].g] >> 8; - output[i].b = gamma[2 * 256 + colors[i].b] >> 8; + if (pixel < (unsigned)format->palette->ncolors) { + *r = format->palette->colors[pixel].r; + *g = format->palette->colors[pixel].g; + *b = format->palette->colors[pixel].b; + *a = SDL_ALPHA_OPAQUE; + } else { + *r = *g = *b = *a = 0; + } } } @@ -879,7 +972,7 @@ SDL_InvalidateMap(SDL_BlitMap * map) return; } map->dst = NULL; - map->format_version = (unsigned int) -1; + map->palette_version = 0; if (map->info.table) { SDL_free(map->info.table); map->info.table = NULL; @@ -904,10 +997,8 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) map->identity = 0; srcfmt = src->format; dstfmt = dst->format; - switch (srcfmt->BytesPerPixel) { - case 1: - switch (dstfmt->BytesPerPixel) { - case 1: + if (SDL_ISPIXELFORMAT_INDEXED(srcfmt->format)) { + if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) { /* Palette --> Palette */ map->info.table = Map1to1(srcfmt->palette, dstfmt->palette, &map->identity); @@ -918,9 +1009,7 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) } if (srcfmt->BitsPerPixel != dstfmt->BitsPerPixel) map->identity = 0; - break; - - default: + } else { /* Palette --> BitField */ map->info.table = Map1toN(srcfmt, src->map->info.r, src->map->info.g, @@ -928,12 +1017,9 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) if (map->info.table == NULL) { return (-1); } - break; } - break; - default: - switch (dstfmt->BytesPerPixel) { - case 1: + } else { + if (SDL_ISPIXELFORMAT_INDEXED(dstfmt->format)) { /* BitField --> Palette */ map->info.table = MapNto1(srcfmt, dstfmt, &map->identity); if (!map->identity) { @@ -942,18 +1028,21 @@ SDL_MapSurface(SDL_Surface * src, SDL_Surface * dst) } } map->identity = 0; /* Don't optimize to copy */ - break; - default: + } else { /* BitField --> BitField */ - if (FORMAT_EQUAL(srcfmt, dstfmt)) + if (srcfmt == dstfmt) { map->identity = 1; - break; + } } - break; } map->dst = dst; - map->format_version = dst->format_version; + + if (dstfmt->palette) { + map->palette_version = dstfmt->palette->version; + } else { + map->palette_version = 0; + } /* Choose your blitters wisely */ return (SDL_CalculateBlit(src)); @@ -968,4 +1057,36 @@ SDL_FreeBlitMap(SDL_BlitMap * map) } } +void +SDL_CalculateGammaRamp(float gamma, Uint16 * ramp) +{ + int i; + + /* 0.0 gamma is all black */ + if (gamma <= 0.0f) { + for (i = 0; i < 256; ++i) { + ramp[i] = 0; + } + return; + } else if (gamma == 1.0f) { + /* 1.0 gamma is identity */ + for (i = 0; i < 256; ++i) { + ramp[i] = (i << 8) | i; + } + return; + } else { + /* Calculate a real gamma ramp */ + int value; + gamma = 1.0f / gamma; + for (i = 0; i < 256; ++i) { + value = + (int) (SDL_pow((double) i / 256.0, gamma) * 65535.0 + 0.5); + if (value > 65535) { + value = 65535; + } + ramp[i] = (Uint16) value; + } + } +} + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_pixels_c.h b/project/jni/sdl-1.3/src/video/SDL_pixels_c.h index f307400e9..d4e60d7e1 100644 --- a/project/jni/sdl-1.3/src/video/SDL_pixels_c.h +++ b/project/jni/sdl-1.3/src/video/SDL_pixels_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -26,14 +25,7 @@ #include "SDL_blit.h" /* Pixel format functions */ -extern SDL_PixelFormat *SDL_AllocFormat(int bpp, - Uint32 Rmask, Uint32 Gmask, - Uint32 Bmask, Uint32 Amask); -extern SDL_PixelFormat *SDL_InitFormat(SDL_PixelFormat * format, int bpp, - Uint32 Rmask, Uint32 Gmask, - Uint32 Bmask, Uint32 Amask); -extern void SDL_FormatChanged(SDL_Surface * surface); -extern void SDL_FreeFormat(SDL_PixelFormat * format); +extern int SDL_InitFormat(SDL_PixelFormat * format, Uint32 pixel_format); /* Blit mapping functions */ extern SDL_BlitMap *SDL_AllocBlitMap(void); @@ -45,6 +37,5 @@ extern void SDL_FreeBlitMap(SDL_BlitMap * map); extern int SDL_CalculatePitch(SDL_Surface * surface); extern void SDL_DitherColors(SDL_Color * colors, int bpp); extern Uint8 SDL_FindColor(SDL_Palette * pal, Uint8 r, Uint8 g, Uint8 b); -extern void SDL_ApplyGamma(Uint16 * gamma, SDL_Color * colors, - SDL_Color * output, int ncolors); + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_rect.c b/project/jni/sdl-1.3/src/video/SDL_rect.c index cb84e6ee6..fba69fc2d 100644 --- a/project/jni/sdl-1.3/src/video/SDL_rect.c +++ b/project/jni/sdl-1.3/src/video/SDL_rect.c @@ -1,34 +1,44 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_video.h" +#include "SDL_rect.h" #include "SDL_rect_c.h" + SDL_bool SDL_HasIntersection(const SDL_Rect * A, const SDL_Rect * B) { int Amin, Amax, Bmin, Bmax; + if (!A || !B) { + // TODO error message + return SDL_FALSE; + } + + /* Special cases for empty rects */ + if (SDL_RectEmpty(A) || SDL_RectEmpty(B)) { + return SDL_FALSE; + } + /* Horizontal intersection */ Amin = A->x; Amax = Amin + A->w; @@ -61,6 +71,16 @@ SDL_IntersectRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result) { int Amin, Amax, Bmin, Bmax; + if (!A || !B || !result) { + // TODO error message + return SDL_FALSE; + } + + /* Special cases for empty rects */ + if (SDL_RectEmpty(A) || SDL_RectEmpty(B)) { + return SDL_FALSE; + } + /* Horizontal intersection */ Amin = A->x; Amax = Amin + A->w; @@ -93,6 +113,28 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result) { int Amin, Amax, Bmin, Bmax; + if (!A || !B || !result) { + return; + } + + /* Special cases for empty Rects */ + if (SDL_RectEmpty(A)) { + if (SDL_RectEmpty(B)) { + /* A and B empty */ + return; + } else { + /* A empty, B not empty */ + *result = *B; + return; + } + } else { + if (SDL_RectEmpty(B)) { + /* A not empty, B empty */ + *result = *A; + return; + } + } + /* Horizontal union */ Amin = A->x; Amax = Amin + A->w; @@ -105,7 +147,7 @@ SDL_UnionRect(const SDL_Rect * A, const SDL_Rect * B, SDL_Rect * result) Amax = Bmax; result->w = Amax - Amin; - /* Vertical intersection */ + /* Vertical union */ Amin = A->y; Amax = Amin + A->h; Bmin = B->y; @@ -128,17 +170,28 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip, int maxy = 0; int x, y, i; + if (!points) { + /* TODO error message */ + return SDL_FALSE; + } + if (count < 1) { + /* TODO error message */ return SDL_FALSE; } if (clip) { SDL_bool added = SDL_FALSE; - int clip_minx = clip->x; - int clip_miny = clip->y; - int clip_maxx = clip->x+clip->w-1; - int clip_maxy = clip->y+clip->h-1; + const int clip_minx = clip->x; + const int clip_miny = clip->y; + const int clip_maxx = clip->x+clip->w-1; + const int clip_maxy = clip->y+clip->h-1; + /* Special case for empty rectangle */ + if (SDL_RectEmpty(clip)) { + return SDL_FALSE; + } + for (i = 0; i < count; ++i) { x = points[i].x; y = points[i].y; @@ -148,6 +201,12 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip, continue; } if (!added) { + /* Special case: if no result was requested, we are done */ + if (result == NULL) { + return SDL_TRUE; + } + + /* First point added */ minx = maxx = x; miny = maxy = y; added = SDL_TRUE; @@ -168,6 +227,11 @@ SDL_EnclosePoints(const SDL_Point * points, int count, const SDL_Rect * clip, return SDL_FALSE; } } else { + /* Special case: if no result was requested, we are done */ + if (result == NULL) { + return SDL_TRUE; + } + /* No clipping, always add the first point */ minx = maxx = points[0].x; miny = maxy = points[0].y; @@ -235,9 +299,15 @@ SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2, int outcode1, outcode2; if (!rect || !X1 || !Y1 || !X2 || !Y2) { + // TODO error message return SDL_FALSE; } + /* Special case for empty rect */ + if (SDL_RectEmpty(rect)) { + return SDL_FALSE; + } + x1 = *X1; y1 = *Y1; x2 = *X2; @@ -340,66 +410,57 @@ SDL_IntersectRectAndLine(const SDL_Rect * rect, int *X1, int *Y1, int *X2, return SDL_TRUE; } -void -SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect) +SDL_bool +SDL_GetSpanEnclosingRect(int width, int height, + int numrects, SDL_Rect * rects, SDL_Rect *span) { - SDL_DirtyRect *dirty; + int i; + int span_y1, span_y2; + int rect_y1, rect_y2; - /* FIXME: At what point is this optimization too expensive? */ - for (dirty = list->list; dirty; dirty = dirty->next) { - if (SDL_HasIntersection(&dirty->rect, rect)) { - SDL_UnionRect(&dirty->rect, rect, &dirty->rect); - return; + if (width < 1 || height < 1) { + // TODO error message + return SDL_FALSE; + } + + if (!rects || !span) { + // TODO error message + return SDL_FALSE; + } + + if (numrects < 1) { + // TODO error message + return SDL_FALSE; + } + + /* Initialize to empty rect */ + span_y1 = height; + span_y2 = 0; + + for (i = 0; i < numrects; ++i) { + rect_y1 = rects[i].y; + rect_y2 = rect_y1 + rects[i].h; + + /* Clip out of bounds rectangles, and expand span rect */ + if (rect_y1 < 0) { + span_y1 = 0; + } else if (rect_y1 < span_y1) { + span_y1 = rect_y1; + } + if (rect_y2 > height) { + span_y2 = height; + } else if (rect_y2 > span_y2) { + span_y2 = rect_y2; } } - - if (list->free) { - dirty = list->free; - list->free = dirty->next; - } else { - dirty = (SDL_DirtyRect *) SDL_malloc(sizeof(*dirty)); - if (!dirty) { - return; - } - } - dirty->rect = *rect; - dirty->next = list->list; - list->list = dirty; -} - -void -SDL_ClearDirtyRects(SDL_DirtyRectList * list) -{ - SDL_DirtyRect *prev, *curr; - - /* Skip to the end of the free list */ - prev = NULL; - for (curr = list->free; curr; curr = curr->next) { - prev = curr; - } - - /* Add the list entries to the end */ - if (prev) { - prev->next = list->list; - } else { - list->free = list->list; - } - list->list = NULL; -} - -void -SDL_FreeDirtyRects(SDL_DirtyRectList * list) -{ - while (list->list) { - SDL_DirtyRect *elem = list->list; - list->list = elem->next; - SDL_free(elem); - } - while (list->free) { - SDL_DirtyRect *elem = list->free; - list->free = elem->next; - SDL_free(elem); + if (span_y2 > span_y1) { + span->x = 0; + span->y = span_y1; + span->w = width; + span->h = (span_y2 - span_y1); + return SDL_TRUE; } + return SDL_FALSE; } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_rect_c.h b/project/jni/sdl-1.3/src/video/SDL_rect_c.h index 2f444760f..7c74f3d4b 100644 --- a/project/jni/sdl-1.3/src/video/SDL_rect_c.h +++ b/project/jni/sdl-1.3/src/video/SDL_rect_c.h @@ -1,40 +1,25 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -typedef struct SDL_DirtyRect -{ - SDL_Rect rect; - struct SDL_DirtyRect *next; -} SDL_DirtyRect; - -typedef struct SDL_DirtyRectList -{ - SDL_DirtyRect *list; - SDL_DirtyRect *free; -} SDL_DirtyRectList; - -extern void SDL_AddDirtyRect(SDL_DirtyRectList * list, const SDL_Rect * rect); -extern void SDL_ClearDirtyRects(SDL_DirtyRectList * list); -extern void SDL_FreeDirtyRects(SDL_DirtyRectList * list); +extern SDL_bool SDL_GetSpanEnclosingRect(int width, int height, int numrects, SDL_Rect * rects, SDL_Rect *span); /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_renderer_gl.c b/project/jni/sdl-1.3/src/video/SDL_renderer_gl.c deleted file mode 100644 index e3938b1af..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_renderer_gl.c +++ /dev/null @@ -1,1564 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_OGL - -#include "SDL_video.h" -#include "SDL_opengl.h" -#include "SDL_sysvideo.h" -#include "SDL_pixels_c.h" -#include "SDL_rect_c.h" -#include "SDL_yuv_sw_c.h" - -#ifdef __MACOSX__ -#include -#endif - - -/* OpenGL renderer implementation */ - -/* Details on optimizing the texture path on Mac OS X: - http://developer.apple.com/documentation/GraphicsImaging/Conceptual/OpenGL-MacProgGuide/opengl_texturedata/chapter_10_section_2.html -*/ - -/* !!! FIXME: this should go in a higher level than the GL renderer. */ -static __inline__ int -bytes_per_pixel(const Uint32 format) -{ - if (!SDL_ISPIXELFORMAT_FOURCC(format)) { - return SDL_BYTESPERPIXEL(format); - } - - /* FOURCC format */ - switch (format) { - case SDL_PIXELFORMAT_YV12: - case SDL_PIXELFORMAT_IYUV: - case SDL_PIXELFORMAT_YUY2: - case SDL_PIXELFORMAT_UYVY: - case SDL_PIXELFORMAT_YVYU: - return 2; - default: - return 1; /* shouldn't ever hit this. */ - } -} - - -static const float inv255f = 1.0f / 255.0f; - -static SDL_Renderer *GL_CreateRenderer(SDL_Window * window, Uint32 flags); -static int GL_ActivateRenderer(SDL_Renderer * renderer); -static int GL_DisplayModeChanged(SDL_Renderer * renderer); -static int GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int GL_QueryTexturePixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int GL_SetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); -static int GL_GetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors); -static int GL_SetTextureColorMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GL_SetTextureAlphaMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GL_SetTextureBlendMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GL_SetTextureScaleMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); -static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch); -static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static void GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects); -static int GL_RenderClear(SDL_Renderer * renderer); -static int GL_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int GL_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int GL_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int GL_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect); -static int GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, void * pixels, int pitch); -static int GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, const void * pixels, int pitch); -static void GL_RenderPresent(SDL_Renderer * renderer); -static void GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static void GL_DestroyRenderer(SDL_Renderer * renderer); - - -SDL_RenderDriver GL_RenderDriver = { - GL_CreateRenderer, - { - "opengl", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD | - SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | - SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | - SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), - (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), - 15, - { - SDL_PIXELFORMAT_INDEX1LSB, - SDL_PIXELFORMAT_INDEX1MSB, - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB332, - SDL_PIXELFORMAT_RGB444, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB24, - SDL_PIXELFORMAT_BGR24, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_BGR888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_ARGB2101010}, - 0, - 0} -}; - -typedef struct -{ - SDL_GLContext context; - SDL_bool updateSize; - SDL_bool GL_ARB_texture_rectangle_supported; - SDL_bool GL_EXT_paletted_texture_supported; - SDL_bool GL_APPLE_ycbcr_422_supported; - SDL_bool GL_MESA_ycbcr_texture_supported; - SDL_bool GL_ARB_fragment_program_supported; - int blendMode; - int scaleMode; - - /* OpenGL functions */ -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; -#include "SDL_glfuncs.h" -#undef SDL_PROC - - PFNGLCOLORTABLEEXTPROC glColorTableEXT; - void (*glTextureRangeAPPLE) (GLenum target, GLsizei length, - const GLvoid * pointer); - - PFNGLGETPROGRAMIVARBPROC glGetProgramivARB; - PFNGLGETPROGRAMSTRINGARBPROC glGetProgramStringARB; - PFNGLPROGRAMLOCALPARAMETER4FVARBPROC glProgramLocalParameter4fvARB; - PFNGLDELETEPROGRAMSARBPROC glDeleteProgramsARB; - PFNGLGENPROGRAMSARBPROC glGenProgramsARB; - PFNGLBINDPROGRAMARBPROC glBindProgramARB; - PFNGLPROGRAMSTRINGARBPROC glProgramStringARB; - - /* (optional) fragment programs */ - GLuint fragment_program_mask; - GLuint fragment_program_UYVY; -} GL_RenderData; - -typedef struct -{ - GLuint texture; - GLuint shader; - GLenum type; - GLfloat texw; - GLfloat texh; - GLenum format; - GLenum formattype; - Uint8 *palette; - void *pixels; - int pitch; - SDL_DirtyRectList dirty; - int HACK_RYAN_FIXME; -} GL_TextureData; - - -static void -GL_SetError(const char *prefix, GLenum result) -{ - const char *error; - - switch (result) { - case GL_NO_ERROR: - error = "GL_NO_ERROR"; - break; - case GL_INVALID_ENUM: - error = "GL_INVALID_ENUM"; - break; - case GL_INVALID_VALUE: - error = "GL_INVALID_VALUE"; - break; - case GL_INVALID_OPERATION: - error = "GL_INVALID_OPERATION"; - break; - case GL_STACK_OVERFLOW: - error = "GL_STACK_OVERFLOW"; - break; - case GL_STACK_UNDERFLOW: - error = "GL_STACK_UNDERFLOW"; - break; - case GL_OUT_OF_MEMORY: - error = "GL_OUT_OF_MEMORY"; - break; - case GL_TABLE_TOO_LARGE: - error = "GL_TABLE_TOO_LARGE"; - break; - default: - error = "UNKNOWN"; - break; - } - SDL_SetError("%s: %s", prefix, error); -} - -static int -GL_LoadFunctions(GL_RenderData * data) -{ -#if defined(__QNXNTO__) && (_NTO_VERSION < 630) -#define __SDL_NOGETPROCADDR__ -#endif -#ifdef __SDL_NOGETPROCADDR__ -#define SDL_PROC(ret,func,params) data->func=func; -#else -#define SDL_PROC(ret,func,params) \ - do { \ - data->func = SDL_GL_GetProcAddress(#func); \ - if ( ! data->func ) { \ - SDL_SetError("Couldn't load GL function %s: %s\n", #func, SDL_GetError()); \ - return -1; \ - } \ - } while ( 0 ); -#endif /* __SDL_NOGETPROCADDR__ */ - -#include "SDL_glfuncs.h" -#undef SDL_PROC - return 0; -} - -SDL_Renderer * -GL_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - SDL_Renderer *renderer; - GL_RenderData *data; - GLint value; - int doublebuffer; - - /* Render directly to the window, unless we're compositing */ -#ifndef __MACOSX__ - if (flags & SDL_RENDERER_SINGLEBUFFER) { - SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 0); - } -#endif - if (!(window->flags & SDL_WINDOW_OPENGL)) { - if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) { - return NULL; - } - } - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (GL_RenderData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - GL_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - - renderer->ActivateRenderer = GL_ActivateRenderer; - renderer->DisplayModeChanged = GL_DisplayModeChanged; - renderer->CreateTexture = GL_CreateTexture; - renderer->QueryTexturePixels = GL_QueryTexturePixels; - renderer->SetTexturePalette = GL_SetTexturePalette; - renderer->GetTexturePalette = GL_GetTexturePalette; - renderer->SetTextureColorMod = GL_SetTextureColorMod; - renderer->SetTextureAlphaMod = GL_SetTextureAlphaMod; - renderer->SetTextureBlendMode = GL_SetTextureBlendMode; - renderer->SetTextureScaleMode = GL_SetTextureScaleMode; - renderer->UpdateTexture = GL_UpdateTexture; - renderer->LockTexture = GL_LockTexture; - renderer->UnlockTexture = GL_UnlockTexture; - renderer->DirtyTexture = GL_DirtyTexture; - renderer->RenderClear = GL_RenderClear; - renderer->RenderDrawPoints = GL_RenderDrawPoints; - renderer->RenderDrawLines = GL_RenderDrawLines; - renderer->RenderDrawRects = GL_RenderDrawRects; - renderer->RenderFillRects = GL_RenderFillRects; - renderer->RenderCopy = GL_RenderCopy; - renderer->RenderReadPixels = GL_RenderReadPixels; - renderer->RenderWritePixels = GL_RenderWritePixels; - renderer->RenderPresent = GL_RenderPresent; - renderer->DestroyTexture = GL_DestroyTexture; - renderer->DestroyRenderer = GL_DestroyRenderer; - renderer->info = GL_RenderDriver.info; - renderer->window = window; - renderer->driverdata = data; - - renderer->info.flags = - (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED); - - if (GL_LoadFunctions(data) < 0) { - GL_DestroyRenderer(renderer); - return NULL; - } - - data->context = SDL_GL_CreateContext(window); - if (!data->context) { - GL_DestroyRenderer(renderer); - return NULL; - } - if (SDL_GL_MakeCurrent(window, data->context) < 0) { - GL_DestroyRenderer(renderer); - return NULL; - } -#ifdef __MACOSX__ - /* Enable multi-threaded rendering */ - /* Disabled until Ryan finishes his VBO/PBO code... - CGLEnable(CGLGetCurrentContext(), kCGLCEMPEngine); - */ -#endif - - if (flags & SDL_RENDERER_PRESENTVSYNC) { - SDL_GL_SetSwapInterval(1); - } else { - SDL_GL_SetSwapInterval(0); - } - if (SDL_GL_GetSwapInterval() > 0) { - renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; - } - - if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) { - if (!doublebuffer) { - renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER; - } - } - - data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); - renderer->info.max_texture_width = value; - data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); - renderer->info.max_texture_height = value; - - if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") - || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { - data->GL_ARB_texture_rectangle_supported = SDL_TRUE; - } - if (SDL_GL_ExtensionSupported("GL_EXT_paletted_texture")) { - data->GL_EXT_paletted_texture_supported = SDL_TRUE; - data->glColorTableEXT = - (PFNGLCOLORTABLEEXTPROC) SDL_GL_GetProcAddress("glColorTableEXT"); - } else { - /* Don't advertise support for 8-bit indexed texture format */ - Uint32 i, j; - SDL_RendererInfo *info = &renderer->info; - for (i = 0, j = 0; i < info->num_texture_formats; ++i) { - if (info->texture_formats[i] != SDL_PIXELFORMAT_INDEX8) { - info->texture_formats[j++] = info->texture_formats[i]; - } - } - --info->num_texture_formats; - } - if (SDL_GL_ExtensionSupported("GL_APPLE_ycbcr_422")) { - data->GL_APPLE_ycbcr_422_supported = SDL_TRUE; - } - if (SDL_GL_ExtensionSupported("GL_MESA_ycbcr_texture")) { - data->GL_MESA_ycbcr_texture_supported = SDL_TRUE; - } - if (SDL_GL_ExtensionSupported("GL_APPLE_texture_range")) { - data->glTextureRangeAPPLE = - (void (*)(GLenum, GLsizei, const GLvoid *)) - SDL_GL_GetProcAddress("glTextureRangeAPPLE"); - } - - /* we might use fragment programs for YUV data, etc. */ - if (SDL_GL_ExtensionSupported("GL_ARB_fragment_program")) { - /* !!! FIXME: this doesn't check for errors. */ - /* !!! FIXME: this should really reuse the glfuncs.h stuff. */ - data->glGetProgramivARB = (PFNGLGETPROGRAMIVARBPROC) - SDL_GL_GetProcAddress("glGetProgramivARB"); - data->glGetProgramStringARB = (PFNGLGETPROGRAMSTRINGARBPROC) - SDL_GL_GetProcAddress("glGetProgramStringARB"); - data->glProgramLocalParameter4fvARB = - (PFNGLPROGRAMLOCALPARAMETER4FVARBPROC) - SDL_GL_GetProcAddress("glProgramLocalParameter4fvARB"); - data->glDeleteProgramsARB = (PFNGLDELETEPROGRAMSARBPROC) - SDL_GL_GetProcAddress("glDeleteProgramsARB"); - data->glGenProgramsARB = (PFNGLGENPROGRAMSARBPROC) - SDL_GL_GetProcAddress("glGenProgramsARB"); - data->glBindProgramARB = (PFNGLBINDPROGRAMARBPROC) - SDL_GL_GetProcAddress("glBindProgramARB"); - data->glProgramStringARB = (PFNGLPROGRAMSTRINGARBPROC) - SDL_GL_GetProcAddress("glProgramStringARB"); - data->GL_ARB_fragment_program_supported = SDL_TRUE; - } - - /* Set up parameters for rendering */ - data->blendMode = -1; - data->scaleMode = -1; - data->glDisable(GL_DEPTH_TEST); - data->glDisable(GL_CULL_FACE); - /* This ended up causing video discrepancies between OpenGL and Direct3D */ - /*data->glEnable(GL_LINE_SMOOTH);*/ - if (data->GL_ARB_texture_rectangle_supported) { - data->glEnable(GL_TEXTURE_RECTANGLE_ARB); - } else { - data->glEnable(GL_TEXTURE_2D); - } - data->updateSize = SDL_TRUE; - - return renderer; -} - -static int -GL_ActivateRenderer(SDL_Renderer * renderer) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - - if (SDL_GL_MakeCurrent(window, data->context) < 0) { - return -1; - } - if (data->updateSize) { - data->glMatrixMode(GL_PROJECTION); - data->glLoadIdentity(); - data->glMatrixMode(GL_MODELVIEW); - data->glLoadIdentity(); - data->glViewport(0, 0, window->w, window->h); - data->glOrtho(0.0, (GLdouble) window->w, - (GLdouble) window->h, 0.0, 0.0, 1.0); - data->updateSize = SDL_FALSE; - } - return 0; -} - -static int -GL_DisplayModeChanged(SDL_Renderer * renderer) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - - /* Rebind the context to the window area and update matrices */ - data->updateSize = SDL_TRUE; - return GL_ActivateRenderer(renderer); -} - -static __inline__ int -power_of_2(int input) -{ - int value = 1; - - while (value < input) { - value <<= 1; - } - return value; -} - - -//#define DEBUG_PROGRAM_COMPILE 1 - -static void -set_shader_error(GL_RenderData * data, const char *prefix) -{ - GLint pos = 0; - const GLubyte *errstr; - data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); - errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB); - SDL_SetError("%s: shader compile error at position %d: %s", - prefix, (int) pos, (const char *) errstr); -} - -static GLuint -compile_shader(GL_RenderData * data, GLenum shader_type, const char *_code) -{ - const int have_texture_rects = data->GL_ARB_texture_rectangle_supported; - const char *replacement = have_texture_rects ? "RECT" : "2D"; - const size_t replacementlen = SDL_strlen(replacement); - const char *token = "%TEXTURETARGET%"; - const size_t tokenlen = SDL_strlen(token); - char *code = NULL; - char *ptr = NULL; - GLuint program = 0; - - /* - * The TEX instruction needs a different target depending on what we use. - * To handle this, we use "%TEXTURETARGET%" and replace the string before - * compiling the shader. - */ - code = SDL_strdup(_code); - if (code == NULL) - return 0; - - for (ptr = SDL_strstr(code, token); ptr; ptr = SDL_strstr(ptr + 1, token)) { - SDL_memcpy(ptr, replacement, replacementlen); - SDL_memmove(ptr + replacementlen, ptr + tokenlen, - SDL_strlen(ptr + tokenlen) + 1); - } - -#if DEBUG_PROGRAM_COMPILE - printf("compiling shader:\n%s\n\n", code); -#endif - - data->glGetError(); /* flush any existing error state. */ - data->glGenProgramsARB(1, &program); - data->glBindProgramARB(shader_type, program); - data->glProgramStringARB(shader_type, GL_PROGRAM_FORMAT_ASCII_ARB, - (GLsizei)SDL_strlen(code), code); - - SDL_free(code); - - if (data->glGetError() == GL_INVALID_OPERATION) { -#if DEBUG_PROGRAM_COMPILE - GLint pos = 0; - const GLubyte *errstr; - data->glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &pos); - errstr = data->glGetString(GL_PROGRAM_ERROR_STRING_ARB); - printf("program compile error at position %d: %s\n\n", - (int) pos, (const char *) errstr); -#endif - data->glBindProgramARB(shader_type, 0); - data->glDeleteProgramsARB(1, &program); - return 0; - } - - return program; -} - - -/* - * Fragment program that implements mask semantics - */ -static const char *fragment_program_mask_source_code = "!!ARBfp1.0\n" -"OUTPUT output = result.color;\n" -"TEMP value;\n" -"TEX value, fragment.texcoord[0], texture[0], %TEXTURETARGET%;\n" -"MUL value, fragment.color, value;\n" -"SGE value.a, value.a, 0.001;\n" -"MOV output, value;\n" -"END"; - -/* - * Fragment program that renders from UYVY textures. - * The UYVY to RGB equasion is: - * R = 1.164(Y-16) + 1.596(Cr-128) - * G = 1.164(Y-16) - 0.813(Cr-128) - 0.391(Cb-128) - * B = 1.164(Y-16) + 2.018(Cb-128) - * Byte layout is Cb, Y1, Cr, Y2, stored in the R, G, B, A channels. - * 4 bytes == 2 pixels: Y1/Cb/Cr, Y2/Cb/Cr - * - * !!! FIXME: this ignores blendmodes, etc. - * !!! FIXME: this could be more efficient...use a dot product for green, etc. - */ -static const char *fragment_program_UYVY_source_code = "!!ARBfp1.0\n" - /* outputs... */ - "OUTPUT outcolor = result.color;\n" - /* scratch registers... */ - "TEMP uyvy;\n" "TEMP luminance;\n" "TEMP work;\n" - /* Halve the coordinates to grab the correct 32 bits for the fragment. */ - "MUL work, fragment.texcoord, { 0.5, 1.0, 1.0, 1.0 };\n" - /* Sample the YUV texture. Cb, Y1, Cr, Y2, are stored in x, y, z, w. */ - "TEX uyvy, work, texture[0], %TEXTURETARGET%;\n" - /* Do subtractions (128/255, 16/255, 128/255, 16/255) */ - "SUB uyvy, uyvy, { 0.501960784313726, 0.06274509803922, 0.501960784313726, 0.06274509803922 };\n" - /* Choose the luminance component by texcoord. */ - /* !!! FIXME: laziness wins out for now... just average Y1 and Y2. */ - "ADD luminance, uyvy.yyyy, uyvy.wwww;\n" - "MUL luminance, luminance, { 0.5, 0.5, 0.5, 0.5 };\n" - /* Multiply luminance by its magic value. */ - "MUL luminance, luminance, { 1.164, 1.164, 1.164, 1.164 };\n" - /* uyvy.xyzw becomes Cr/Cr/Cb/Cb, with multiplications. */ - "MUL uyvy, uyvy.zzxx, { 1.596, -0.813, 2.018, -0.391 };\n" - /* Add luminance to Cr and Cb, store to RGB channels. */ - "ADD work.rgb, luminance, uyvy;\n" - /* Do final addition for Green channel. (!!! FIXME: this should be a DPH?) */ - "ADD work.g, work.g, uyvy.w;\n" - /* Make sure alpha channel is fully opaque. (!!! FIXME: blend modes!) */ - "MOV work.a, { 1.0 };\n" - /* Store out the final fragment color... */ - "MOV outcolor, work;\n" - /* ...and we're done! */ - "END\n"; - -static __inline__ SDL_bool -convert_format(GL_RenderData *renderdata, Uint32 pixel_format, - GLint* internalFormat, GLenum* format, GLenum* type) -{ - switch (pixel_format) { - case SDL_PIXELFORMAT_INDEX1LSB: - case SDL_PIXELFORMAT_INDEX1MSB: - *internalFormat = GL_RGB; - *format = GL_COLOR_INDEX; - *type = GL_BITMAP; - break; - case SDL_PIXELFORMAT_INDEX8: - if (!renderdata->GL_EXT_paletted_texture_supported) { - return SDL_FALSE; - } - *internalFormat = GL_COLOR_INDEX8_EXT; - *format = GL_COLOR_INDEX; - *type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_RGB332: - *internalFormat = GL_R3_G3_B2; - *format = GL_RGB; - *type = GL_UNSIGNED_BYTE_3_3_2; - break; - case SDL_PIXELFORMAT_RGB444: - *internalFormat = GL_RGB4; - *format = GL_RGB; - *type = GL_UNSIGNED_SHORT_4_4_4_4; - break; - case SDL_PIXELFORMAT_RGB555: - *internalFormat = GL_RGB5; - *format = GL_RGB; - *type = GL_UNSIGNED_SHORT_5_5_5_1; - break; - case SDL_PIXELFORMAT_ARGB4444: - *internalFormat = GL_RGBA4; - *format = GL_BGRA; - *type = GL_UNSIGNED_SHORT_4_4_4_4_REV; - break; - case SDL_PIXELFORMAT_ARGB1555: - *internalFormat = GL_RGB5_A1; - *format = GL_BGRA; - *type = GL_UNSIGNED_SHORT_1_5_5_5_REV; - break; - case SDL_PIXELFORMAT_RGB565: - *internalFormat = GL_RGB8; - *format = GL_RGB; - *type = GL_UNSIGNED_SHORT_5_6_5; - break; - case SDL_PIXELFORMAT_RGB24: - *internalFormat = GL_RGB8; - *format = GL_RGB; - *type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_RGB888: - *internalFormat = GL_RGB8; - *format = GL_BGRA; - *type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_BGR24: - *internalFormat = GL_RGB8; - *format = GL_BGR; - *type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_BGR888: - *internalFormat = GL_RGB8; - *format = GL_RGBA; - *type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_ARGB8888: -#ifdef __MACOSX__ - *internalFormat = GL_RGBA; - *format = GL_BGRA; - *type = GL_UNSIGNED_INT_8_8_8_8_REV; -#else - *internalFormat = GL_RGBA8; - *format = GL_BGRA; - *type = GL_UNSIGNED_BYTE; -#endif - break; - case SDL_PIXELFORMAT_ABGR8888: - *internalFormat = GL_RGBA8; - *format = GL_RGBA; - *type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_ARGB2101010: - *internalFormat = GL_RGB10_A2; - *format = GL_BGRA; - *type = GL_UNSIGNED_INT_2_10_10_10_REV; - break; - case SDL_PIXELFORMAT_UYVY: - if (renderdata->GL_APPLE_ycbcr_422_supported) { - *internalFormat = GL_RGB; - *format = GL_YCBCR_422_APPLE; -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - *type = GL_UNSIGNED_SHORT_8_8_APPLE; -#else - *type = GL_UNSIGNED_SHORT_8_8_REV_APPLE; -#endif - } else if (renderdata->GL_MESA_ycbcr_texture_supported) { - *internalFormat = GL_YCBCR_MESA; - *format = GL_YCBCR_MESA; -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - *type = GL_UNSIGNED_SHORT_8_8_MESA; -#else - *type = GL_UNSIGNED_SHORT_8_8_REV_MESA; -#endif - } else if (renderdata->GL_ARB_fragment_program_supported) { - *internalFormat = GL_RGBA; - *format = GL_RGBA; - *type = GL_UNSIGNED_BYTE; - } else { - return SDL_FALSE; - } - break; - case SDL_PIXELFORMAT_YUY2: - if (renderdata->GL_APPLE_ycbcr_422_supported) { - *internalFormat = GL_RGB; - *format = GL_YCBCR_422_APPLE; -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - *type = GL_UNSIGNED_SHORT_8_8_REV_APPLE; -#else - *type = GL_UNSIGNED_SHORT_8_8_APPLE; -#endif - } else if (renderdata->GL_MESA_ycbcr_texture_supported) { - *internalFormat = GL_YCBCR_MESA; - *format = GL_YCBCR_MESA; -#if SDL_BYTEORDER == SDL_LIL_ENDIAN - *type = GL_UNSIGNED_SHORT_8_8_REV_MESA; -#else - *type = GL_UNSIGNED_SHORT_8_8_MESA; -#endif - } else { - return SDL_FALSE; - } - break; - default: - return SDL_FALSE; - } - return SDL_TRUE; -} - -static int -GL_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; - GL_TextureData *data; - GLint internalFormat; - GLenum format, type; - int texture_w, texture_h; - GLuint shader = 0; - GLenum result; - - if (!convert_format(renderdata, texture->format, &internalFormat, - &format, &type)) { - SDL_SetError("Texture format %s not supported by OpenGL", - SDL_GetPixelFormatName(texture->format)); - return -1; - } - if (texture->format == SDL_PIXELFORMAT_UYVY && - !renderdata->GL_APPLE_ycbcr_422_supported && - !renderdata->GL_MESA_ycbcr_texture_supported && - renderdata->GL_ARB_fragment_program_supported) { - if (renderdata->fragment_program_UYVY == 0) { - renderdata->fragment_program_UYVY = - compile_shader(renderdata, GL_FRAGMENT_PROGRAM_ARB, - fragment_program_UYVY_source_code); - if (renderdata->fragment_program_UYVY == 0) { - set_shader_error(renderdata, "UYVY"); - return -1; - } - } - shader = renderdata->fragment_program_UYVY; - } - - data = (GL_TextureData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - SDL_OutOfMemory(); - return -1; - } - - data->shader = shader; - - if (texture->format == SDL_PIXELFORMAT_INDEX8) { - data->palette = (Uint8 *) SDL_malloc(3 * 256 * sizeof(Uint8)); - if (!data->palette) { - SDL_OutOfMemory(); - SDL_free(data); - return -1; - } - SDL_memset(data->palette, 0xFF, 3 * 256 * sizeof(Uint8)); - } - - if (texture->access == SDL_TEXTUREACCESS_STREAMING) { - data->pitch = texture->w * bytes_per_pixel(texture->format); - data->pixels = SDL_malloc(texture->h * data->pitch); - if (!data->pixels) { - SDL_OutOfMemory(); - SDL_free(data); - return -1; - } - } - - texture->driverdata = data; - - renderdata->glGetError(); - renderdata->glGenTextures(1, &data->texture); - if (renderdata->GL_ARB_texture_rectangle_supported) { - data->type = GL_TEXTURE_RECTANGLE_ARB; - texture_w = texture->w; - texture_h = texture->h; - data->texw = (GLfloat) texture_w; - data->texh = (GLfloat) texture_h; - } else { - data->type = GL_TEXTURE_2D; - texture_w = power_of_2(texture->w); - texture_h = power_of_2(texture->h); - data->texw = (GLfloat) (texture->w) / texture_w; - data->texh = (GLfloat) texture->h / texture_h; - } - - /* YUV formats use RGBA but are really two bytes per pixel */ - if (internalFormat == GL_RGBA && bytes_per_pixel(texture->format) < 4) { - texture_w /= 2; - if (data->type == GL_TEXTURE_2D) { - data->texw *= 2.0f; - } - data->HACK_RYAN_FIXME = 2; - } else { - data->HACK_RYAN_FIXME = 1; - } - - data->format = format; - data->formattype = type; - renderdata->glEnable(data->type); - renderdata->glBindTexture(data->type, data->texture); - renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, - GL_NEAREST); - renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, - GL_NEAREST); - renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, - GL_CLAMP_TO_EDGE); - renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, - GL_CLAMP_TO_EDGE); -#ifdef __MACOSX__ -#ifndef GL_TEXTURE_STORAGE_HINT_APPLE -#define GL_TEXTURE_STORAGE_HINT_APPLE 0x85BC -#endif -#ifndef STORAGE_CACHED_APPLE -#define STORAGE_CACHED_APPLE 0x85BE -#endif -#ifndef STORAGE_SHARED_APPLE -#define STORAGE_SHARED_APPLE 0x85BF -#endif - if (texture->access == SDL_TEXTUREACCESS_STREAMING) { - renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE, - GL_STORAGE_SHARED_APPLE); - } else { - renderdata->glTexParameteri(data->type, GL_TEXTURE_STORAGE_HINT_APPLE, - GL_STORAGE_CACHED_APPLE); - } -/* This causes a crash in testoverlay for some reason. Apple bug? */ -#if 0 - if (texture->access == SDL_TEXTUREACCESS_STREAMING - && texture->format == SDL_PIXELFORMAT_ARGB8888) { - /* - if (renderdata->glTextureRangeAPPLE) { - renderdata->glTextureRangeAPPLE(data->type, - texture->h * data->pitch, - data->pixels); - } - */ - renderdata->glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); - renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, - texture_h, 0, format, type, data->pixels); - } else -#endif -#endif - { - renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, - texture_h, 0, format, type, NULL); - } - renderdata->glDisable(data->type); - result = renderdata->glGetError(); - if (result != GL_NO_ERROR) { - GL_SetError("glTexImage2D()", result); - return -1; - } - return 0; -} - -static int -GL_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - GL_TextureData *data = (GL_TextureData *) texture->driverdata; - - *pixels = data->pixels; - *pitch = data->pitch; - return 0; -} - -static int -GL_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, int ncolors) -{ - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; - GL_TextureData *data = (GL_TextureData *) texture->driverdata; - Uint8 *palette; - - if (!data->palette) { - SDL_SetError("Texture doesn't have a palette"); - return -1; - } - palette = data->palette + firstcolor * 3; - while (ncolors--) { - *palette++ = colors->r; - *palette++ = colors->g; - *palette++ = colors->b; - ++colors; - } - renderdata->glEnable(data->type); - renderdata->glBindTexture(data->type, data->texture); - renderdata->glColorTableEXT(data->type, GL_RGB8, 256, GL_RGB, - GL_UNSIGNED_BYTE, data->palette); - return 0; -} - -static int -GL_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, int ncolors) -{ - GL_TextureData *data = (GL_TextureData *) texture->driverdata; - Uint8 *palette; - - if (!data->palette) { - SDL_SetError("Texture doesn't have a palette"); - return -1; - } - palette = data->palette + firstcolor * 3; - while (ncolors--) { - colors->r = *palette++; - colors->g = *palette++; - colors->b = *palette++; - colors->unused = SDL_ALPHA_OPAQUE; - ++colors; - } - return 0; -} - -static void -SetupTextureUpdate(GL_RenderData * renderdata, SDL_Texture * texture, - int pitch) -{ - if (texture->format == SDL_PIXELFORMAT_INDEX1LSB) { - renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 1); - } else if (texture->format == SDL_PIXELFORMAT_INDEX1MSB) { - renderdata->glPixelStorei(GL_UNPACK_LSB_FIRST, 0); - } - renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - renderdata->glPixelStorei(GL_UNPACK_ROW_LENGTH, - (pitch / bytes_per_pixel(texture->format)) / - ((GL_TextureData *) texture->driverdata)-> - HACK_RYAN_FIXME); -} - -static int -GL_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -GL_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -GL_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->blendMode) { - case SDL_BLENDMODE_NONE: - case SDL_BLENDMODE_MASK: - case SDL_BLENDMODE_BLEND: - case SDL_BLENDMODE_ADD: - case SDL_BLENDMODE_MOD: - return 0; - default: - SDL_Unsupported(); - texture->blendMode = SDL_BLENDMODE_NONE; - return -1; - } -} - -static int -GL_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: - case SDL_SCALEMODE_FAST: - case SDL_SCALEMODE_SLOW: - return 0; - case SDL_SCALEMODE_BEST: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_SLOW; - return -1; - default: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_NONE; - return -1; - } -} - -static int -GL_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; - GL_TextureData *data = (GL_TextureData *) texture->driverdata; - GLenum result; - - renderdata->glGetError(); - SetupTextureUpdate(renderdata, texture, pitch); - renderdata->glEnable(data->type); - renderdata->glBindTexture(data->type, data->texture); - renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, - rect->h, data->format, data->formattype, - pixels); - renderdata->glDisable(data->type); - result = renderdata->glGetError(); - if (result != GL_NO_ERROR) { - GL_SetError("glTexSubImage2D()", result); - return -1; - } - return 0; -} - -static int -GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - GL_TextureData *data = (GL_TextureData *) texture->driverdata; - - if (markDirty) { - SDL_AddDirtyRect(&data->dirty, rect); - } - - *pixels = - (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * bytes_per_pixel(texture->format)); - *pitch = data->pitch; - return 0; -} - -static void -GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ -} - -static void -GL_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, - const SDL_Rect * rects) -{ - GL_TextureData *data = (GL_TextureData *) texture->driverdata; - int i; - - for (i = 0; i < numrects; ++i) { - SDL_AddDirtyRect(&data->dirty, &rects[i]); - } -} - -static void -GL_SetBlendMode(GL_RenderData * data, int blendMode, int isprimitive) -{ - if (blendMode != data->blendMode) { - switch (blendMode) { - case SDL_BLENDMODE_NONE: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - data->glDisable(GL_BLEND); - break; - case SDL_BLENDMODE_MASK: - if (isprimitive) { - /* The same as SDL_BLENDMODE_NONE */ - blendMode = SDL_BLENDMODE_NONE; - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - data->glDisable(GL_BLEND); - } else { - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - } - break; - case SDL_BLENDMODE_BLEND: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - break; - case SDL_BLENDMODE_ADD: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); - break; - case SDL_BLENDMODE_MOD: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); - break; - } - data->blendMode = blendMode; - } -} - -static int -GL_RenderClear(SDL_Renderer * renderer) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - - data->glClearColor((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - data->glClear(GL_COLOR_BUFFER_BIT); - - return 0; -} - -static int -GL_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - int i; - - GL_SetBlendMode(data, renderer->blendMode, 1); - - data->glColor4f((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - data->glBegin(GL_POINTS); - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); - - return 0; -} - -static int -GL_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - int i; - - GL_SetBlendMode(data, renderer->blendMode, 1); - - data->glColor4f((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - if (count > 2 && - points[0].x == points[count-1].x && points[0].y == points[count-1].y) { - data->glBegin(GL_LINE_LOOP); - /* GL_LINE_LOOP takes care of the final segment */ - --count; - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); - } else { -#if defined(__APPLE__) || defined(__WIN32__) -#else - int x1, y1, x2, y2; -#endif - - data->glBegin(GL_LINE_STRIP); - for (i = 0; i < count; ++i) { - data->glVertex2f(0.5f + points[i].x, 0.5f + points[i].y); - } - data->glEnd(); - - /* The line is half open, so we need one more point to complete it. - * http://www.opengl.org/documentation/specs/version1.1/glspec1.1/node47.html - * If we have to, we can use vertical line and horizontal line textures - * for vertical and horizontal lines, and then create custom textures - * for diagonal lines and software render those. It's terrible, but at - * least it would be pixel perfect. - */ - data->glBegin(GL_POINTS); -#if defined(__APPLE__) || defined(__WIN32__) - /* Mac OS X and Windows seem to always leave the second point open */ - data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y); -#else - /* Linux seems to leave the right-most or bottom-most point open */ - x1 = points[0].x; - y1 = points[0].y; - x2 = points[count-1].x; - y2 = points[count-1].y; - - if (x1 > x2) { - data->glVertex2f(0.5f + x1, 0.5f + y1); - } else if (x2 > x1) { - data->glVertex2f(0.5f + x2, 0.5f + y2); - } else if (y1 > y2) { - data->glVertex2f(0.5f + x1, 0.5f + y1); - } else if (y2 > y1) { - data->glVertex2f(0.5f + x2, 0.5f + y2); - } -#endif - data->glEnd(); - } - - return 0; -} - -static int -GL_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - int i, x, y; - - GL_SetBlendMode(data, renderer->blendMode, 1); - - data->glColor4f((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - data->glBegin(GL_LINE_LOOP); - for (i = 0; i < count; ++i) { - const SDL_Rect *rect = rects[i]; - - x = rect->x; - y = rect->y; - data->glVertex2f(0.5f + x, 0.5f + y); - - x = rect->x+rect->w-1; - y = rect->y; - data->glVertex2f(0.5f + x, 0.5f + y); - - x = rect->x+rect->w-1; - y = rect->y+rect->h-1; - data->glVertex2f(0.5f + x, 0.5f + y); - - x = rect->x; - y = rect->y+rect->h-1; - data->glVertex2f(0.5f + x, 0.5f + y); - } - data->glEnd(); - - return 0; -} - -static int -GL_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - int i; - - GL_SetBlendMode(data, renderer->blendMode, 1); - - data->glColor4f((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - for (i = 0; i < count; ++i) { - const SDL_Rect *rect = rects[i]; - - data->glRecti(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h); - } - - return 0; -} - -static int -GL_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - GL_TextureData *texturedata = (GL_TextureData *) texture->driverdata; - GLuint shader = 0; - int minx, miny, maxx, maxy; - GLfloat minu, maxu, minv, maxv; - - if (texturedata->dirty.list) { - SDL_DirtyRect *dirty; - void *pixels; - int bpp = bytes_per_pixel(texture->format); - int pitch = texturedata->pitch; - - SetupTextureUpdate(data, texture, pitch); - data->glEnable(texturedata->type); - data->glBindTexture(texturedata->type, texturedata->texture); - for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) { - SDL_Rect *rect = &dirty->rect; - pixels = - (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch + - rect->x * bpp); - data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, - rect->w / texturedata->HACK_RYAN_FIXME, - rect->h, texturedata->format, - texturedata->formattype, pixels); - } - SDL_ClearDirtyRects(&texturedata->dirty); - } - - minx = dstrect->x; - miny = dstrect->y; - maxx = dstrect->x + dstrect->w; - maxy = dstrect->y + dstrect->h; - - minu = (GLfloat) srcrect->x / texture->w; - minu *= texturedata->texw; - maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; - maxu *= texturedata->texw; - minv = (GLfloat) srcrect->y / texture->h; - minv *= texturedata->texh; - maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; - maxv *= texturedata->texh; - - data->glEnable(texturedata->type); - data->glBindTexture(texturedata->type, texturedata->texture); - - if (texture->modMode) { - data->glColor4f((GLfloat) texture->r * inv255f, - (GLfloat) texture->g * inv255f, - (GLfloat) texture->b * inv255f, - (GLfloat) texture->a * inv255f); - } else { - data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - } - - GL_SetBlendMode(data, texture->blendMode, 0); - - /* Set up the shader for the copy, we have a special one for MASK */ - shader = texturedata->shader; - if (texture->blendMode == SDL_BLENDMODE_MASK && !shader) { - if (data->fragment_program_mask == 0) { - data->fragment_program_mask = - compile_shader(data, GL_FRAGMENT_PROGRAM_ARB, - fragment_program_mask_source_code); - if (data->fragment_program_mask == 0) { - /* That's okay, we'll just miss some of the blend semantics */ - data->fragment_program_mask = ~0; - } - } - if (data->fragment_program_mask != ~0) { - shader = data->fragment_program_mask; - } - } - - if (texture->scaleMode != data->scaleMode) { - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: - case SDL_SCALEMODE_FAST: - data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, - GL_NEAREST); - data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, - GL_NEAREST); - break; - case SDL_SCALEMODE_SLOW: - case SDL_SCALEMODE_BEST: - data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, - GL_LINEAR); - break; - } - data->scaleMode = texture->scaleMode; - } - - if (shader) { - data->glEnable(GL_FRAGMENT_PROGRAM_ARB); - data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, shader); - } - - data->glBegin(GL_TRIANGLE_STRIP); - data->glTexCoord2f(minu, minv); - data->glVertex2f((GLfloat) minx, (GLfloat) miny); - data->glTexCoord2f(maxu, minv); - data->glVertex2f((GLfloat) maxx, (GLfloat) miny); - data->glTexCoord2f(minu, maxv); - data->glVertex2f((GLfloat) minx, (GLfloat) maxy); - data->glTexCoord2f(maxu, maxv); - data->glVertex2f((GLfloat) maxx, (GLfloat) maxy); - data->glEnd(); - - if (shader) { - data->glDisable(GL_FRAGMENT_PROGRAM_ARB); - } - - data->glDisable(texturedata->type); - - return 0; -} - -static int -GL_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, void * pixels, int pitch) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - GLint internalFormat; - GLenum format, type; - Uint8 *src, *dst, *tmp; - int length, rows; - - if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) { - /* FIXME: Do a temp copy to a format that is supported */ - SDL_SetError("Unsupported pixel format"); - return -1; - } - - if (pixel_format == SDL_PIXELFORMAT_INDEX1LSB) { - data->glPixelStorei(GL_PACK_LSB_FIRST, 1); - } else if (pixel_format == SDL_PIXELFORMAT_INDEX1MSB) { - data->glPixelStorei(GL_PACK_LSB_FIRST, 0); - } - data->glPixelStorei(GL_PACK_ALIGNMENT, 1); - data->glPixelStorei(GL_PACK_ROW_LENGTH, - (pitch / bytes_per_pixel(pixel_format))); - - data->glReadPixels(rect->x, (window->h-rect->y)-rect->h, rect->w, rect->h, - format, type, pixels); - - /* Flip the rows to be top-down */ - length = rect->w * bytes_per_pixel(pixel_format); - src = (Uint8*)pixels + (rect->h-1)*pitch; - dst = (Uint8*)pixels; - tmp = SDL_stack_alloc(Uint8, length); - rows = rect->h / 2; - while (rows--) { - SDL_memcpy(tmp, dst, length); - SDL_memcpy(dst, src, length); - SDL_memcpy(src, tmp, length); - dst += pitch; - src -= pitch; - } - SDL_stack_free(tmp); - - return 0; -} - -static int -GL_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 pixel_format, const void * pixels, int pitch) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - GLint internalFormat; - GLenum format, type; - Uint8 *src, *dst, *tmp; - int length, rows; - - if (!convert_format(data, pixel_format, &internalFormat, &format, &type)) { - /* FIXME: Do a temp copy to a format that is supported */ - SDL_SetError("Unsupported pixel format"); - return -1; - } - - if (pixel_format == SDL_PIXELFORMAT_INDEX1LSB) { - data->glPixelStorei(GL_UNPACK_LSB_FIRST, 1); - } else if (pixel_format == SDL_PIXELFORMAT_INDEX1MSB) { - data->glPixelStorei(GL_UNPACK_LSB_FIRST, 0); - } - data->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - data->glPixelStorei(GL_UNPACK_ROW_LENGTH, - (pitch / bytes_per_pixel(pixel_format))); - - /* Flip the rows to be bottom-up */ - length = rect->h * rect->w * pitch; - tmp = SDL_stack_alloc(Uint8, length); - src = (Uint8*)pixels + (rect->h-1)*pitch; - dst = (Uint8*)tmp; - rows = rect->h; - while (rows--) { - SDL_memcpy(dst, src, pitch); - dst += pitch; - src -= pitch; - } - - data->glRasterPos2i(rect->x, (window->h-rect->y)); - data->glDrawPixels(rect->w, rect->h, format, type, tmp); - SDL_stack_free(tmp); - - return 0; -} - -static void -GL_RenderPresent(SDL_Renderer * renderer) -{ - SDL_GL_SwapWindow(renderer->window); -} - -static void -GL_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - GL_RenderData *renderdata = (GL_RenderData *) renderer->driverdata; - GL_TextureData *data = (GL_TextureData *) texture->driverdata; - - if (!data) { - return; - } - if (data->texture) { - renderdata->glDeleteTextures(1, &data->texture); - } - if (data->palette) { - SDL_free(data->palette); - } - if (data->pixels) { - SDL_free(data->pixels); - } - SDL_FreeDirtyRects(&data->dirty); - SDL_free(data); - texture->driverdata = NULL; -} - -static void -GL_DestroyRenderer(SDL_Renderer * renderer) -{ - GL_RenderData *data = (GL_RenderData *) renderer->driverdata; - - if (data) { - if (data->context) { - if (data->GL_ARB_fragment_program_supported) { - data->glDisable(GL_FRAGMENT_PROGRAM_ARB); - data->glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, 0); - if (data->fragment_program_mask && - data->fragment_program_mask != ~0) { - data->glDeleteProgramsARB(1, - &data->fragment_program_mask); - } - if (data->fragment_program_UYVY && - data->fragment_program_UYVY != ~0) { - data->glDeleteProgramsARB(1, - &data->fragment_program_UYVY); - } - } - - /* SDL_GL_MakeCurrent(0, NULL); *//* doesn't do anything */ - SDL_GL_DeleteContext(data->context); - } - SDL_free(data); - } - SDL_free(renderer); -} - -#endif /* SDL_VIDEO_RENDER_OGL */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_renderer_gl.h b/project/jni/sdl-1.3/src/video/SDL_renderer_gl.h deleted file mode 100644 index 6dd0a2362..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_renderer_gl.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* OpenGL renderer implementation */ - -extern SDL_RenderDriver GL_RenderDriver; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_renderer_gles.c b/project/jni/sdl-1.3/src/video/SDL_renderer_gles.c deleted file mode 100644 index 62d88ecf9..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_renderer_gles.c +++ /dev/null @@ -1,1056 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" -#include "SDL_version.h" - -#if SDL_VIDEO_RENDER_OGL_ES - -#if SDL_VERSION_ATLEAST(1,3,0) -#include "SDL_video.h" -#include "SDL_opengles.h" -#include "SDL_sysvideo.h" -#else -#include "SDL_video-1.3.h" -#include "SDL_sysvideo-1.3.h" -#endif -#include "SDL_opengles.h" -#include "SDL_pixels_c.h" -#include "SDL_rect_c.h" -#if SDL_VERSION_ATLEAST(1,3,0) -#include "SDL_yuv_sw_c.h" -#endif -#ifdef ANDROID -#include -#else -#define __android_log_print(...) -#endif - -#if defined(__QNXNTO__) -/* Include QNX system header to check QNX version later */ -#include -#endif /* __QNXNTO__ */ - -#if defined(SDL_VIDEO_DRIVER_QNXGF) || \ - defined(SDL_VIDEO_DRIVER_PHOTON) || \ - defined(SDL_VIDEO_DRIVER_PANDORA) - -/* Empty function stub to get OpenGL ES 1.x support without */ -/* OpenGL ES extension GL_OES_draw_texture supported */ -GL_API void GL_APIENTRY -glDrawTexiOES(GLint x, GLint y, GLint z, GLint width, GLint height) -{ - return; -} - -#endif /* QNXGF || PHOTON || PANDORA */ - -/* OpenGL ES 1.1 renderer implementation, based on the OpenGL renderer */ - -static const float inv255f = 1.0f / 255.0f; - -static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags); -static int GLES_ActivateRenderer(SDL_Renderer * renderer); -static int GLES_DisplayModeChanged(SDL_Renderer * renderer); -static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int GLES_QueryTexturePixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int GLES_SetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); -static int GLES_GetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors); -static int GLES_SetTextureColorMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GLES_SetTextureAlphaMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GLES_SetTextureBlendMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GLES_SetTextureScaleMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); -static int GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch); -static void GLES_UnlockTexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects); -static int GLES_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int GLES_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int GLES_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int GLES_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_Rect * dstrect); -static void GLES_RenderPresent(SDL_Renderer * renderer); -static void GLES_DestroyTexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void GLES_DestroyRenderer(SDL_Renderer * renderer); - - -SDL_RenderDriver GL_ES_RenderDriver = { - GLES_CreateRenderer, - { - "opengl_es", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD | - SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | - SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | - SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), - (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW), 5, - { - /* OpenGL ES 1.x supported formats list */ - SDL_PIXELFORMAT_RGBA4444, - SDL_PIXELFORMAT_RGBA5551, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB24, - SDL_PIXELFORMAT_RGBA8888}, - 0, - 0} -}; - -typedef struct -{ - SDL_GLContext context; - SDL_bool updateSize; - int blendMode; - -#ifndef APIENTRY -#define APIENTRY -#endif - - SDL_bool useDrawTexture; - SDL_bool GL_OES_draw_texture_supported; - - /* OpenGL ES functions */ -#define SDL_PROC(ret,func,params) ret (APIENTRY *func) params; -#include "SDL_glesfuncs.h" -#undef SDL_PROC - -} GLES_RenderData; - -typedef struct -{ - GLuint texture; - GLenum type; - GLfloat texw; - GLfloat texh; - GLenum format; - GLenum formattype; - void *pixels; - int pitch; - SDL_DirtyRectList dirty; -} GLES_TextureData; - -static void -GLES_SetError(const char *prefix, GLenum result) -{ - const char *error; - - switch (result) { - case GL_NO_ERROR: - error = "GL_NO_ERROR"; - break; - case GL_INVALID_ENUM: - error = "GL_INVALID_ENUM"; - break; - case GL_INVALID_VALUE: - error = "GL_INVALID_VALUE"; - break; - case GL_INVALID_OPERATION: - error = "GL_INVALID_OPERATION"; - break; - case GL_STACK_OVERFLOW: - error = "GL_STACK_OVERFLOW"; - break; - case GL_STACK_UNDERFLOW: - error = "GL_STACK_UNDERFLOW"; - break; - case GL_OUT_OF_MEMORY: - error = "GL_OUT_OF_MEMORY"; - break; - default: - error = "UNKNOWN"; - break; - } - SDL_SetError("%s: %s", prefix, error); -} - -static int -GLES_LoadFunctions(GLES_RenderData * data) -{ - -#define SDL_PROC(ret,func,params) \ - data->func = func; -#include "SDL_glesfuncs.h" -#undef SDL_PROC - - return 0; -} - -SDL_Renderer * -GLES_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - - SDL_Renderer *renderer; - GLES_RenderData *data; - GLint value; - int doublebuffer; - -#if SDL_VERSION_ATLEAST(1,3,0) - if (!(window->flags & SDL_WINDOW_OPENGL)) { - if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) { - return NULL; - } - } -#endif - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (GLES_RenderData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - GLES_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - - renderer->ActivateRenderer = GLES_ActivateRenderer; - renderer->DisplayModeChanged = GLES_DisplayModeChanged; - renderer->CreateTexture = GLES_CreateTexture; - renderer->QueryTexturePixels = GLES_QueryTexturePixels; - renderer->SetTexturePalette = GLES_SetTexturePalette; - renderer->GetTexturePalette = GLES_GetTexturePalette; - renderer->SetTextureColorMod = GLES_SetTextureColorMod; - renderer->SetTextureAlphaMod = GLES_SetTextureAlphaMod; - renderer->SetTextureBlendMode = GLES_SetTextureBlendMode; - renderer->SetTextureScaleMode = GLES_SetTextureScaleMode; - renderer->UpdateTexture = GLES_UpdateTexture; - renderer->LockTexture = GLES_LockTexture; - renderer->UnlockTexture = GLES_UnlockTexture; - renderer->DirtyTexture = GLES_DirtyTexture; - renderer->RenderDrawPoints = GLES_RenderDrawPoints; - renderer->RenderDrawLines = GLES_RenderDrawLines; - renderer->RenderDrawRects = GLES_RenderDrawRects; - renderer->RenderFillRects = GLES_RenderFillRects; - renderer->RenderCopy = GLES_RenderCopy; - renderer->RenderPresent = GLES_RenderPresent; - renderer->DestroyTexture = GLES_DestroyTexture; - renderer->DestroyRenderer = GLES_DestroyRenderer; - renderer->info = GL_ES_RenderDriver.info; - renderer->window = window; - renderer->driverdata = data; - - renderer->info.flags = - (SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED); - -#if defined(__QNXNTO__) -#if _NTO_VERSION<=641 - /* QNX's OpenGL ES implementation is broken regarding */ - /* packed textures support, affected versions 6.3.2, 6.4.0, 6.4.1 */ - renderer->info.num_texture_formats = 2; - renderer->info.texture_formats[0] = SDL_PIXELFORMAT_ABGR8888; - renderer->info.texture_formats[1] = SDL_PIXELFORMAT_BGR24; -#endif /* _NTO_VERSION */ -#endif /* __QNXNTO__ */ - - if (GLES_LoadFunctions(data) < 0) { - GLES_DestroyRenderer(renderer); - return NULL; - } - - data->context = SDL_GL_CreateContext(window); - if (!data->context) { - GLES_DestroyRenderer(renderer); - return NULL; - } - if (SDL_GL_MakeCurrent(window, data->context) < 0) { - GLES_DestroyRenderer(renderer); - return NULL; - } - - if (flags & SDL_RENDERER_PRESENTVSYNC) { - SDL_GL_SetSwapInterval(1); - } else { - SDL_GL_SetSwapInterval(0); - } - if (SDL_GL_GetSwapInterval() > 0) { - renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; - } - -#if SDL_VERSION_ATLEAST(1,3,0) - // Always double-buffered -#else - if (SDL_GL_GetAttribute(SDL_GL_DOUBLEBUFFER, &doublebuffer) == 0) { - if (!doublebuffer) { - renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER; - } - } -#endif -#if SDL_VIDEO_DRIVER_PANDORA - data->GL_OES_draw_texture_supported = SDL_FALSE; - data->useDrawTexture = SDL_FALSE; -#else - if (SDL_GL_ExtensionSupported("GL_OES_draw_texture")) { - data->GL_OES_draw_texture_supported = SDL_TRUE; - data->useDrawTexture = SDL_TRUE; - } else { - data->GL_OES_draw_texture_supported = SDL_FALSE; - data->useDrawTexture = SDL_FALSE; - } -#ifdef ANDROID - data->GL_OES_draw_texture_supported = SDL_TRUE; - data->useDrawTexture = SDL_TRUE; -#endif -#endif - - data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); - renderer->info.max_texture_width = value; - data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); - renderer->info.max_texture_height = value; - - /* Set up parameters for rendering */ - data->blendMode = -1; - data->glDisable(GL_DEPTH_TEST); - data->glDisable(GL_CULL_FACE); - data->updateSize = SDL_TRUE; - - return renderer; -} - -static int -GLES_ActivateRenderer(SDL_Renderer * renderer) -{ - - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - - if (SDL_GL_MakeCurrent(window, data->context) < 0) { - return -1; - } - - /* Set up parameters for rendering */ - data->blendMode = -1; - data->glDisable(GL_DEPTH_TEST); - data->glDisable(GL_CULL_FACE); - data->updateSize = SDL_TRUE; - - if (data->updateSize) { - data->glMatrixMode(GL_PROJECTION); - data->glLoadIdentity(); - data->glMatrixMode(GL_MODELVIEW); - data->glLoadIdentity(); -#if SDL_VIDEO_RENDER_RESIZE - data->glViewport(0, 0, window->display->desktop_mode.w, window->display->desktop_mode.h); - data->glOrthof(0.0, (GLfloat) window->display->desktop_mode.w, (GLfloat) window->display->desktop_mode.h, - 0.0, 0.0, 1.0); -#else - data->glViewport(0, 0, window->w, window->h); - data->glOrthof(0.0, (GLfloat) window->w, (GLfloat) window->h, - 0.0, 0.0, 1.0); -#endif - data->updateSize = SDL_FALSE; - } - return 0; -} - -static int -GLES_DisplayModeChanged(SDL_Renderer * renderer) -{ - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - - data->updateSize = SDL_TRUE; - return 0; -} - -static __inline__ int -power_of_2(int input) -{ - int value = 1; - - while (value < input) { - value <<= 1; - } - return value; -} - -static int -GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; - GLES_TextureData *data; - GLint internalFormat; - GLenum format, type; - int texture_w, texture_h; - GLenum result; - - switch (texture->format) { - case SDL_PIXELFORMAT_RGB24: - internalFormat = GL_RGB; - format = GL_RGB; - type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_BGR888: - case SDL_PIXELFORMAT_ABGR8888: - case SDL_PIXELFORMAT_RGBA8888: - internalFormat = GL_RGBA; - format = GL_RGBA; - type = GL_UNSIGNED_BYTE; - break; - case SDL_PIXELFORMAT_RGB565: - internalFormat = GL_RGB; - format = GL_RGB; - type = GL_UNSIGNED_SHORT_5_6_5; - break; - case SDL_PIXELFORMAT_RGBA5551: - internalFormat = GL_RGBA; - format = GL_RGBA; - type = GL_UNSIGNED_SHORT_5_5_5_1; - break; - case SDL_PIXELFORMAT_RGBA4444: - internalFormat = GL_RGBA; - format = GL_RGBA; - type = GL_UNSIGNED_SHORT_4_4_4_4; - break; - default: - SDL_SetError("Texture format %s not supported by OpenGL ES", - SDL_GetPixelFormatName(texture->format)); - return -1; - } - - data = (GLES_TextureData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - SDL_OutOfMemory(); - return -1; - } - - if (texture->access == SDL_TEXTUREACCESS_STREAMING) - { - data->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); - data->pixels = SDL_malloc(texture->h * data->pitch); - if (!data->pixels) { - SDL_OutOfMemory(); - SDL_free(data); - return -1; - } - } - - texture->driverdata = data; - - renderdata->glGetError(); - renderdata->glEnable(GL_TEXTURE_2D); - renderdata->glGenTextures(1, &data->texture); - - data->type = GL_TEXTURE_2D; - /* no NPOV textures allowed in OpenGL ES (yet) */ - texture_w = power_of_2(texture->w); - texture_h = power_of_2(texture->h); - data->texw = (GLfloat) texture->w / texture_w; - data->texh = (GLfloat) texture->h / texture_h; - if( renderer->info.max_texture_width < texture_w || renderer->info.max_texture_height < texture_h ) - __android_log_print(ANDROID_LOG_WARN, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than largest possible device texture %dx%d", - texture_w, texture_h, renderer->info.max_texture_width, renderer->info.max_texture_height ); - else if( texture_w > 1024 || texture_h > 1024 ) - __android_log_print(ANDROID_LOG_WARN, "libSDL", "GLES: Allocated texture of size %dx%d which is bigger than 1024x1024 - this code will not work on HTC G1", texture_w, texture_h ); - - data->format = format; - data->formattype = type; - renderdata->glBindTexture(data->type, data->texture); - renderdata->glTexParameteri(data->type, GL_TEXTURE_MIN_FILTER, - GL_NEAREST); - renderdata->glTexParameteri(data->type, GL_TEXTURE_MAG_FILTER, - GL_NEAREST); - renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_S, - GL_CLAMP_TO_EDGE); - renderdata->glTexParameteri(data->type, GL_TEXTURE_WRAP_T, - GL_CLAMP_TO_EDGE); - - renderdata->glTexImage2D(data->type, 0, internalFormat, texture_w, - texture_h, 0, format, type, NULL); - renderdata->glDisable(GL_TEXTURE_2D); - - result = renderdata->glGetError(); - if (result != GL_NO_ERROR) { - GLES_SetError("glTexImage2D()", result); - return -1; - } - return 0; -} - -static int -GLES_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; - - *pixels = data->pixels; - *pitch = data->pitch; - return 0; -} - -static int -GLES_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, int ncolors) -{ - SDL_SetError("OpenGL ES does not support paletted textures"); - return -1; -} - -static int -GLES_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, int ncolors) -{ - SDL_SetError("OpenGL ES does not support paletted textures"); - return -1; -} - -static void -SetupTextureUpdate(GLES_RenderData * renderdata, SDL_Texture * texture, - int pitch) -{ - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; - renderdata->glBindTexture(data->type, data->texture); - renderdata->glPixelStorei(GL_UNPACK_ALIGNMENT, 1); -} - -static int -GLES_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -GLES_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -GLES_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->blendMode) { - case SDL_BLENDMODE_NONE: - case SDL_BLENDMODE_MASK: - case SDL_BLENDMODE_BLEND: - case SDL_BLENDMODE_ADD: - case SDL_BLENDMODE_MOD: - return 0; - default: - SDL_Unsupported(); - texture->blendMode = SDL_BLENDMODE_NONE; - return -1; - } -} - -static int -GLES_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: - case SDL_SCALEMODE_FAST: - case SDL_SCALEMODE_SLOW: - return 0; - case SDL_SCALEMODE_BEST: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_SLOW; - return -1; - default: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_NONE; - return -1; - } -} - -static int -GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - GLES_RenderData *renderdata = (GLES_RenderData *) renderer->driverdata; - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; - GLenum result; - int bpp = SDL_BYTESPERPIXEL(texture->format); - void * temp_buffer; - void * temp_ptr; - int i; - - renderdata->glGetError(); - renderdata->glEnable(data->type); - SetupTextureUpdate(renderdata, texture, pitch); - - if( rect->w * bpp == pitch ) { - temp_buffer = (void *)pixels; /* No need to reformat */ - } else { - /* Reformatting of mem area required */ - temp_buffer = SDL_malloc(rect->w * rect->h * bpp); - temp_ptr = temp_buffer; - for (i = 0; i < rect->h; i++) { - SDL_memcpy(temp_ptr, pixels, rect->w * bpp); - temp_ptr += rect->w * bpp; - pixels += pitch; - } - } - - renderdata->glTexSubImage2D(data->type, 0, rect->x, rect->y, rect->w, - rect->h, data->format, data->formattype, - temp_buffer); - - if( temp_buffer != pixels ) { - SDL_free(temp_buffer); - } - - renderdata->glDisable(data->type); - result = renderdata->glGetError(); - if (result != GL_NO_ERROR) { - GLES_SetError("glTexSubImage2D()", result); - return -1; - } - return 0; -} - -static int -GLES_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; - - if (markDirty) { - SDL_AddDirtyRect(&data->dirty, rect); - } - - *pixels = - (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch = data->pitch; - return 0; -} - -static void -GLES_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ -} - -static void -GLES_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects) -{ - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; - int i; - - for (i = 0; i < numrects; ++i) { - SDL_AddDirtyRect(&data->dirty, &rects[i]); - } -} - -static void -GLES_SetBlendMode(GLES_RenderData * data, int blendMode, int isprimitive) -{ - if (blendMode != data->blendMode) { - switch (blendMode) { - case SDL_BLENDMODE_NONE: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - data->glDisable(GL_BLEND); - break; - case SDL_BLENDMODE_MASK: - if (isprimitive) { - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); - data->glDisable(GL_BLEND); - /* The same as SDL_BLENDMODE_NONE */ - blendMode = SDL_BLENDMODE_NONE; - break; - } - /* fall through */ - case SDL_BLENDMODE_BLEND: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - break; - case SDL_BLENDMODE_ADD: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_SRC_ALPHA, GL_ONE); - break; - case SDL_BLENDMODE_MOD: - data->glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); - data->glEnable(GL_BLEND); - data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); - break; - } - data->blendMode = blendMode; - } -} - -static int -GLES_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - int i; - GLshort *vertices; - - GLES_SetBlendMode(data, renderer->blendMode, 1); - - data->glColor4f((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - vertices = SDL_stack_alloc(GLshort, count*2); - for (i = 0; i < count; ++i) { - vertices[2*i+0] = (GLshort)points[i].x; - vertices[2*i+1] = (GLshort)points[i].y; - } - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glEnableClientState(GL_VERTEX_ARRAY); - data->glDrawArrays(GL_POINTS, 0, count); - data->glDisableClientState(GL_VERTEX_ARRAY); - SDL_stack_free(vertices); - - return 0; -} - -static int -GLES_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - int i; - GLshort *vertices; - - GLES_SetBlendMode(data, renderer->blendMode, 1); - - data->glColor4f((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - vertices = SDL_stack_alloc(GLshort, count*2); - for (i = 0; i < count; ++i) { - vertices[2*i+0] = (GLshort)points[i].x; - vertices[2*i+1] = (GLshort)points[i].y; - } - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glEnableClientState(GL_VERTEX_ARRAY); - if (count > 2 && - points[0].x == points[count-1].x && points[0].y == points[count-1].y) { - /* GL_LINE_LOOP takes care of the final segment */ - --count; - data->glDrawArrays(GL_LINE_LOOP, 0, count); - } else { - data->glDrawArrays(GL_LINE_STRIP, 0, count); - } - data->glDisableClientState(GL_VERTEX_ARRAY); - SDL_stack_free(vertices); - - return 0; -} - -static int -GLES_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - int i; - - GLES_SetBlendMode(data, renderer->blendMode, 1); - - data->glColor4f((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - data->glEnableClientState(GL_VERTEX_ARRAY); - for (i = 0; i < count; ++i) { - const SDL_Rect *rect = rects[i]; - GLshort minx = rect->x; - GLshort maxx = rect->x + rect->w; - GLshort miny = rect->y; - GLshort maxy = rect->y + rect->h; - GLshort vertices[8]; - vertices[0] = minx; - vertices[1] = miny; - vertices[2] = maxx; - vertices[3] = miny; - vertices[4] = minx; - vertices[5] = maxy; - vertices[6] = maxx; - vertices[7] = maxy; - - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glDrawArrays(GL_LINE_LOOP, 0, 4); - } - data->glDisableClientState(GL_VERTEX_ARRAY); - - return 0; -} - -static int -GLES_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - int i; - - GLES_SetBlendMode(data, renderer->blendMode, 1); - - data->glColor4f((GLfloat) renderer->r * inv255f, - (GLfloat) renderer->g * inv255f, - (GLfloat) renderer->b * inv255f, - (GLfloat) renderer->a * inv255f); - - data->glEnableClientState(GL_VERTEX_ARRAY); - for (i = 0; i < count; ++i) { - const SDL_Rect *rect = rects[i]; - GLshort minx = rect->x; - GLshort maxx = rect->x + rect->w; - GLshort miny = rect->y; - GLshort maxy = rect->y + rect->h; - GLshort vertices[8]; - vertices[0] = minx; - vertices[1] = miny; - vertices[2] = maxx; - vertices[3] = miny; - vertices[4] = minx; - vertices[5] = maxy; - vertices[6] = maxx; - vertices[7] = maxy; - - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - } - data->glDisableClientState(GL_VERTEX_ARRAY); - - return 0; -} - -static int -GLES_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - GLES_TextureData *texturedata = (GLES_TextureData *) texture->driverdata; - int minx, miny, maxx, maxy; - GLfloat minu, maxu, minv, maxv; - int i; - void *temp_buffer; /* used for reformatting dirty rect pixels */ - void *temp_ptr; - - data->glEnable(GL_TEXTURE_2D); - - if (texturedata->dirty.list) { - SDL_DirtyRect *dirty; - void *pixels; - int bpp = SDL_BYTESPERPIXEL(texture->format); - int pitch = texturedata->pitch; - - SetupTextureUpdate(data, texture, pitch); - - data->glBindTexture(texturedata->type, texturedata->texture); - for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) { - SDL_Rect *rect = &dirty->rect; - pixels = - (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch + - rect->x * bpp); - /* There is no GL_UNPACK_ROW_LENGTH in OpenGLES - we must do this reformatting ourselves(!) - - maybe it'd be a good idea to keep a temp buffer around - for this purpose rather than allocating it each time - */ - if( rect->x == 0 && rect->w * bpp == pitch ) { - temp_buffer = pixels; /* Updating whole texture, no need to reformat */ - } else { - temp_buffer = SDL_malloc(rect->w * rect->h * bpp); - temp_ptr = temp_buffer; - for (i = 0; i < rect->h; i++) { - SDL_memcpy(temp_ptr, pixels, rect->w * bpp); - temp_ptr += rect->w * bpp; - pixels += pitch; - } - } - - data->glTexSubImage2D(texturedata->type, 0, rect->x, rect->y, - rect->w, rect->h, texturedata->format, - texturedata->formattype, temp_buffer); - - if( temp_buffer != pixels ) { - SDL_free(temp_buffer); - } - } - SDL_ClearDirtyRects(&texturedata->dirty); - } - - data->glBindTexture(texturedata->type, texturedata->texture); - - if (texture->modMode) { - data->glColor4f((GLfloat) texture->r * inv255f, - (GLfloat) texture->g * inv255f, - (GLfloat) texture->b * inv255f, - (GLfloat) texture->a * inv255f); - } else { - data->glColor4f(1.0f, 1.0f, 1.0f, 1.0f); - } - - GLES_SetBlendMode(data, texture->blendMode, 0); - - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: - case SDL_SCALEMODE_FAST: - data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, - GL_NEAREST); - data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, - GL_NEAREST); - break; - case SDL_SCALEMODE_SLOW: - case SDL_SCALEMODE_BEST: - data->glTexParameteri(texturedata->type, GL_TEXTURE_MIN_FILTER, - GL_LINEAR); - data->glTexParameteri(texturedata->type, GL_TEXTURE_MAG_FILTER, - GL_LINEAR); - break; - } - - if (data->GL_OES_draw_texture_supported && data->useDrawTexture) { - /* this code is a little funny because the viewport is upside down vs SDL's coordinate system */ - SDL_Window *window = renderer->window; - GLint cropRect[4]; - cropRect[0] = srcrect->x; - cropRect[1] = srcrect->y + srcrect->h; - cropRect[2] = srcrect->w; - cropRect[3] = -srcrect->h; - data->glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, - cropRect); - //__android_log_print(ANDROID_LOG_INFO, "libSDL", "GLES_RenderCopy glDrawTexiOES(%d, %d, %d, %d) cropRect %d:%d:%d:%d", dstrect->x, window->display->desktop_mode.h - dstrect->y - dstrect->h, dstrect->w, dstrect->h, cropRect[0], cropRect[1], cropRect[2], cropRect[3]); - data->glDrawTexiOES(dstrect->x, -#if SDL_VIDEO_RENDER_RESIZE - window->display->desktop_mode.h - dstrect->y - dstrect->h, -#else - window->h - dstrect->y - dstrect->h, -#endif - 0, dstrect->w, dstrect->h); - } else { - - minx = dstrect->x; - miny = dstrect->y; - maxx = dstrect->x + dstrect->w; - maxy = dstrect->y + dstrect->h; - - minu = (GLfloat) srcrect->x / texture->w; - minu *= texturedata->texw; - maxu = (GLfloat) (srcrect->x + srcrect->w) / texture->w; - maxu *= texturedata->texw; - minv = (GLfloat) srcrect->y / texture->h; - minv *= texturedata->texh; - maxv = (GLfloat) (srcrect->y + srcrect->h) / texture->h; - maxv *= texturedata->texh; - - GLshort vertices[8]; - GLfloat texCoords[8]; - - vertices[0] = minx; - vertices[1] = miny; - vertices[2] = maxx; - vertices[3] = miny; - vertices[4] = minx; - vertices[5] = maxy; - vertices[6] = maxx; - vertices[7] = maxy; - - texCoords[0] = minu; - texCoords[1] = minv; - texCoords[2] = maxu; - texCoords[3] = minv; - texCoords[4] = minu; - texCoords[5] = maxv; - texCoords[6] = maxu; - texCoords[7] = maxv; - - data->glVertexPointer(2, GL_SHORT, 0, vertices); - data->glEnableClientState(GL_VERTEX_ARRAY); - data->glTexCoordPointer(2, GL_FLOAT, 0, texCoords); - data->glEnableClientState(GL_TEXTURE_COORD_ARRAY); - data->glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); - data->glDisableClientState(GL_TEXTURE_COORD_ARRAY); - data->glDisableClientState(GL_VERTEX_ARRAY); - } - - data->glDisable(GL_TEXTURE_2D); - - return 0; -} - -static void -GLES_RenderPresent(SDL_Renderer * renderer) -{ - SDL_GL_SwapWindow(renderer->window); -} - -static void -GLES_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - GLES_TextureData *data = (GLES_TextureData *) texture->driverdata; - - if (!data) { - return; - } - if (data->texture) { - glDeleteTextures(1, &data->texture); - } - if (data->pixels) { - SDL_free(data->pixels); - } - SDL_FreeDirtyRects(&data->dirty); - SDL_free(data); - texture->driverdata = NULL; -} - -static void -GLES_DestroyRenderer(SDL_Renderer * renderer) -{ - GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata; - - if (data) { - if (data->context) { - SDL_GL_DeleteContext(data->context); - } - SDL_free(data); - } - SDL_free(renderer); -} - -#endif /* SDL_VIDEO_RENDER_OGL_ES */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_renderer_gles.h b/project/jni/sdl-1.3/src/video/SDL_renderer_gles.h deleted file mode 100644 index f86328d4e..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_renderer_gles.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* OpenGL renderer implementation */ - -extern SDL_RenderDriver GL_ES_RenderDriver; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_renderer_sw.c b/project/jni/sdl-1.3/src/video/SDL_renderer_sw.c deleted file mode 100644 index 604584f20..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_renderer_sw.c +++ /dev/null @@ -1,958 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" -#include "SDL_sysvideo.h" -#include "SDL_pixels_c.h" -#include "SDL_rect_c.h" -#include "SDL_yuv_sw_c.h" -#include "SDL_renderer_sw.h" - - -/* SDL surface based renderer implementation */ - -static SDL_Renderer *SW_CreateRenderer(SDL_Window * window, Uint32 flags); -static int SW_ActivateRenderer(SDL_Renderer * renderer); -static int SW_DisplayModeChanged(SDL_Renderer * renderer); -static int SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int SW_QueryTexturePixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int SW_SetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); -static int SW_GetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors); -static int SW_SetTextureColorMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int SW_SetTextureAlphaMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int SW_SetTextureBlendMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int SW_SetTextureScaleMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); -static int SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch); -static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int SW_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int SW_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int SW_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int SW_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect); -static int SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch); -static int SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch); -static void SW_RenderPresent(SDL_Renderer * renderer); -static void SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static void SW_DestroyRenderer(SDL_Renderer * renderer); - - -SDL_RenderDriver SW_RenderDriver = { - SW_CreateRenderer, - { - "software", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | - SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | - SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), - (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST), - 14, - { - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_BGR888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGBA8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_YUY2, - SDL_PIXELFORMAT_UYVY, - SDL_PIXELFORMAT_YVYU}, - 0, - 0} -}; - -typedef struct -{ - Uint32 format; - SDL_bool updateSize; - int current_texture; - SDL_Texture *texture[3]; - SDL_Surface surface; - SDL_Renderer *renderer; - SDL_DirtyRectList dirty; -} SW_RenderData; - -static SDL_Texture * -CreateTexture(SDL_Renderer * renderer, Uint32 format, int w, int h) -{ - SDL_Texture *texture; - - texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); - if (!texture) { - SDL_OutOfMemory(); - return NULL; - } - - texture->format = format; - texture->access = SDL_TEXTUREACCESS_STREAMING; - texture->w = w; - texture->h = h; - texture->renderer = renderer; - - if (renderer->CreateTexture(renderer, texture) < 0) { - SDL_free(texture); - return NULL; - } - return texture; -} - -static void -DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - renderer->DestroyTexture(renderer, texture); - SDL_free(texture); -} - -static int -DisplayPaletteChanged(void *userdata, SDL_Palette * palette) -{ - SW_RenderData *data = (SW_RenderData *) userdata; - int i; - - for (i = 0; i < SDL_arraysize(data->texture); ++i) { - if (data->texture[i] && data->renderer->SetTexturePalette) { - data->renderer->SetTexturePalette(data->renderer, - data->texture[i], - palette->colors, 0, - palette->ncolors); - } - } - return 0; -} - -void -Setup_SoftwareRenderer(SDL_Renderer * renderer) -{ - renderer->CreateTexture = SW_CreateTexture; - renderer->QueryTexturePixels = SW_QueryTexturePixels; - renderer->SetTexturePalette = SW_SetTexturePalette; - renderer->GetTexturePalette = SW_GetTexturePalette; - renderer->SetTextureColorMod = SW_SetTextureColorMod; - renderer->SetTextureAlphaMod = SW_SetTextureAlphaMod; - renderer->SetTextureBlendMode = SW_SetTextureBlendMode; - renderer->SetTextureScaleMode = SW_SetTextureScaleMode; - renderer->UpdateTexture = SW_UpdateTexture; - renderer->LockTexture = SW_LockTexture; - renderer->UnlockTexture = SW_UnlockTexture; - renderer->DestroyTexture = SW_DestroyTexture; - - renderer->info.mod_modes = SW_RenderDriver.info.mod_modes; - renderer->info.blend_modes = SW_RenderDriver.info.blend_modes; - renderer->info.scale_modes = SW_RenderDriver.info.scale_modes; - renderer->info.num_texture_formats = - SW_RenderDriver.info.num_texture_formats; - SDL_memcpy(renderer->info.texture_formats, - SW_RenderDriver.info.texture_formats, - sizeof(renderer->info.texture_formats));; - renderer->info.max_texture_width = SW_RenderDriver.info.max_texture_width; - renderer->info.max_texture_height = - SW_RenderDriver.info.max_texture_height; -} - -SDL_Renderer * -SW_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - SDL_VideoDisplay *display = window->display; - SDL_DisplayMode *displayMode = &display->current_mode; - SDL_Renderer *renderer; - SW_RenderData *data; - int i, n; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - Uint32 renderer_flags; - const char *desired_driver; - - if (!SDL_PixelFormatEnumToMasks - (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown display format"); - return NULL; - } - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (SW_RenderData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - SW_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - renderer->ActivateRenderer = SW_ActivateRenderer; - renderer->DisplayModeChanged = SW_DisplayModeChanged; - - renderer->RenderDrawPoints = SW_RenderDrawPoints; - renderer->RenderDrawLines = SW_RenderDrawLines; - renderer->RenderDrawRects = SW_RenderDrawRects; - renderer->RenderFillRects = SW_RenderFillRects; - renderer->RenderCopy = SW_RenderCopy; - renderer->RenderReadPixels = SW_RenderReadPixels; - renderer->RenderWritePixels = SW_RenderWritePixels; - renderer->RenderPresent = SW_RenderPresent; - renderer->DestroyRenderer = SW_DestroyRenderer; - renderer->info.name = SW_RenderDriver.info.name; - renderer->info.flags = 0; - renderer->window = window; - renderer->driverdata = data; - Setup_SoftwareRenderer(renderer); - - if (flags & SDL_RENDERER_PRESENTFLIP2) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; - n = 2; - } else if (flags & SDL_RENDERER_PRESENTFLIP3) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; - n = 3; - } else { - renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; - n = 1; - } - data->format = displayMode->format; - - /* Find a render driver that we can use to display data */ - renderer_flags = (SDL_RENDERER_SINGLEBUFFER | - SDL_RENDERER_PRESENTDISCARD); - if (flags & SDL_RENDERER_PRESENTVSYNC) { - renderer_flags |= SDL_RENDERER_PRESENTVSYNC; - } - desired_driver = SDL_getenv("SDL_VIDEO_RENDERER_SWDRIVER"); - for (i = 0; i < display->num_render_drivers; ++i) { - SDL_RenderDriver *driver = &display->render_drivers[i]; - if (driver->info.name == SW_RenderDriver.info.name) { - continue; - } - if (desired_driver - && SDL_strcasecmp(desired_driver, driver->info.name) != 0) { - continue; - } - data->renderer = driver->CreateRenderer(window, renderer_flags); - if (data->renderer) { - break; - } - } - if (i == display->num_render_drivers) { - SW_DestroyRenderer(renderer); - SDL_SetError("Couldn't find display render driver"); - return NULL; - } - if (data->renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { - renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; - } - - /* Create the textures we'll use for display */ - for (i = 0; i < n; ++i) { - data->texture[i] = - CreateTexture(data->renderer, data->format, window->w, window->h); - if (!data->texture[i]) { - SW_DestroyRenderer(renderer); - return NULL; - } - } - data->current_texture = 0; - - /* Create a surface we'll use for rendering */ - data->surface.flags = SDL_PREALLOC; - data->surface.format = SDL_AllocFormat(bpp, Rmask, Gmask, Bmask, Amask); - if (!data->surface.format) { - SW_DestroyRenderer(renderer); - return NULL; - } - SDL_SetSurfacePalette(&data->surface, display->palette); - - /* Set up a palette watch on the display palette */ - if (display->palette) { - SDL_AddPaletteWatch(display->palette, DisplayPaletteChanged, data); - } - - return renderer; -} - -static int -SW_ActivateRenderer(SDL_Renderer * renderer) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - int i, n; - - if (data->renderer && data->renderer->ActivateRenderer) { - if (data->renderer->ActivateRenderer(data->renderer) < 0) { - return -1; - } - } - if (data->updateSize) { - /* Recreate the textures for the new window size */ - if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { - n = 2; - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { - n = 3; - } else { - n = 1; - } - for (i = 0; i < n; ++i) { - if (data->texture[i]) { - DestroyTexture(data->renderer, data->texture[i]); - data->texture[i] = 0; - } - } - for (i = 0; i < n; ++i) { - data->texture[i] = - CreateTexture(data->renderer, data->format, window->w, - window->h); - if (!data->texture[i]) { - return -1; - } - } - data->updateSize = SDL_FALSE; - } - return 0; -} - -static int -SW_DisplayModeChanged(SDL_Renderer * renderer) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - - if (data->renderer && data->renderer->DisplayModeChanged) { - if (data->renderer->DisplayModeChanged(data->renderer) < 0) { - return -1; - } - } - /* Rebind the context to the window area */ - data->updateSize = SDL_TRUE; - return SW_ActivateRenderer(renderer); -} - -static int -SW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - texture->driverdata = - SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); - } else { - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (!SDL_PixelFormatEnumToMasks - (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown texture format"); - return -1; - } - - texture->driverdata = - SDL_CreateRGBSurface(0, texture->w, texture->h, bpp, Rmask, Gmask, - Bmask, Amask); - SDL_SetSurfaceColorMod(texture->driverdata, texture->r, texture->g, - texture->b); - SDL_SetSurfaceAlphaMod(texture->driverdata, texture->a); - SDL_SetSurfaceBlendMode(texture->driverdata, texture->blendMode); - SDL_SetSurfaceScaleMode(texture->driverdata, texture->scaleMode); - - if (texture->access == SDL_TEXTUREACCESS_STATIC) { - SDL_SetSurfaceRLE(texture->driverdata, 1); - } - } - - if (!texture->driverdata) { - return -1; - } - return 0; -} - -static int -SW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - return SDL_SW_QueryYUVTexturePixels((SDL_SW_YUVTexture *) - texture->driverdata, pixels, - pitch); - } else { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - - *pixels = surface->pixels; - *pitch = surface->pitch; - return 0; - } -} - -static int -SW_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, int ncolors) -{ - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - SDL_SetError("YUV textures don't have a palette"); - return -1; - } else { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - - return SDL_SetPaletteColors(surface->format->palette, colors, - firstcolor, ncolors); - } -} - -static int -SW_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, int ncolors) -{ - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - SDL_SetError("YUV textures don't have a palette"); - return -1; - } else { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - - SDL_memcpy(colors, &surface->format->palette->colors[firstcolor], - ncolors * sizeof(*colors)); - return 0; - } -} - -static int -SW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - return SDL_SetSurfaceColorMod(surface, texture->r, texture->g, - texture->b); -} - -static int -SW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - return SDL_SetSurfaceAlphaMod(surface, texture->a); -} - -static int -SW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - return SDL_SetSurfaceBlendMode(surface, texture->blendMode); -} - -static int -SW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - return SDL_SetSurfaceScaleMode(surface, texture->scaleMode); -} - -static int -SW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - return SDL_SW_UpdateYUVTexture((SDL_SW_YUVTexture *) - texture->driverdata, rect, pixels, - pitch); - } else { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - Uint8 *src, *dst; - int row; - size_t length; - - src = (Uint8 *) pixels; - dst = - (Uint8 *) surface->pixels + rect->y * surface->pitch + - rect->x * surface->format->BytesPerPixel; - length = rect->w * surface->format->BytesPerPixel; - for (row = 0; row < rect->h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += surface->pitch; - } - return 0; - } -} - -static int -SW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - return SDL_SW_LockYUVTexture((SDL_SW_YUVTexture *) - texture->driverdata, rect, markDirty, - pixels, pitch); - } else { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - - *pixels = - (void *) ((Uint8 *) surface->pixels + rect->y * surface->pitch + - rect->x * surface->format->BytesPerPixel); - *pitch = surface->pitch; - return 0; - } -} - -static void -SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - SDL_SW_UnlockYUVTexture((SDL_SW_YUVTexture *) texture->driverdata); - } -} - -static int -SW_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Texture *texture = data->texture[data->current_texture]; - SDL_Rect rect; - int i; - int x, y; - int status = 0; - - /* Get the smallest rectangle that contains everything */ - rect.x = 0; - rect.y = 0; - rect.w = texture->w; - rect.h = texture->h; - if (!SDL_EnclosePoints(points, count, &rect, &rect)) { - /* Nothing to draw */ - return 0; - } - - if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { - SDL_AddDirtyRect(&data->dirty, &rect); - } - - if (data->renderer->LockTexture(data->renderer, texture, &rect, 1, - &data->surface.pixels, - &data->surface.pitch) < 0) { - return -1; - } - - data->surface.clip_rect.w = data->surface.w = rect.w; - data->surface.clip_rect.h = data->surface.h = rect.h; - - /* Draw the points! */ - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - Uint32 color = SDL_MapRGBA(data->surface.format, - renderer->r, renderer->g, renderer->b, - renderer->a); - - for (i = 0; i < count; ++i) { - x = points[i].x - rect.x; - y = points[i].y - rect.y; - - status = SDL_DrawPoint(&data->surface, x, y, color); - } - } else { - for (i = 0; i < count; ++i) { - x = points[i].x - rect.x; - y = points[i].y - rect.y; - - status = SDL_BlendPoint(&data->surface, x, y, - renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } - } - - data->renderer->UnlockTexture(data->renderer, texture); - - return status; -} - -static int -SW_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Texture *texture = data->texture[data->current_texture]; - SDL_Rect clip, rect; - int i; - int x1, y1, x2, y2; - int status = 0; - - /* Get the smallest rectangle that contains everything */ - clip.x = 0; - clip.y = 0; - clip.w = texture->w; - clip.h = texture->h; - SDL_EnclosePoints(points, count, NULL, &rect); - if (!SDL_IntersectRect(&rect, &clip, &rect)) { - /* Nothing to draw */ - return 0; - } - - if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { - SDL_AddDirtyRect(&data->dirty, &rect); - } - - if (data->renderer->LockTexture(data->renderer, texture, &rect, 1, - &data->surface.pixels, - &data->surface.pitch) < 0) { - return -1; - } - - data->surface.clip_rect.w = data->surface.w = rect.w; - data->surface.clip_rect.h = data->surface.h = rect.h; - - /* Draw the points! */ - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - Uint32 color = SDL_MapRGBA(data->surface.format, - renderer->r, renderer->g, renderer->b, - renderer->a); - - for (i = 1; i < count; ++i) { - x1 = points[i-1].x - rect.x; - y1 = points[i-1].y - rect.y; - x2 = points[i].x - rect.x; - y2 = points[i].y - rect.y; - - status = SDL_DrawLine(&data->surface, x1, y1, x2, y2, color); - } - } else { - for (i = 1; i < count; ++i) { - x1 = points[i-1].x - rect.x; - y1 = points[i-1].y - rect.y; - x2 = points[i].x - rect.x; - y2 = points[i].y - rect.y; - - status = SDL_BlendLine(&data->surface, x1, y1, x2, y2, - renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } - } - - data->renderer->UnlockTexture(data->renderer, texture); - - return status; -} - -static int -SW_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Texture *texture = data->texture[data->current_texture]; - SDL_Rect clip, rect; - Uint32 color = 0; - int i; - int status = 0; - - clip.x = 0; - clip.y = 0; - clip.w = texture->w; - clip.h = texture->h; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - color = SDL_MapRGBA(data->surface.format, - renderer->r, renderer->g, renderer->b, - renderer->a); - } - - for (i = 0; i < count; ++i) { - /* FIXME: We don't want to draw clipped edges */ - if (!SDL_IntersectRect(rects[i], &clip, &rect)) { - /* Nothing to draw */ - continue; - } - - if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { - SDL_AddDirtyRect(&data->dirty, &rect); - } - - if (data->renderer->LockTexture(data->renderer, texture, &rect, 1, - &data->surface.pixels, - &data->surface.pitch) < 0) { - return -1; - } - - data->surface.clip_rect.w = data->surface.w = rect.w; - data->surface.clip_rect.h = data->surface.h = rect.h; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - status = SDL_DrawRect(&data->surface, NULL, color); - } else { - status = SDL_BlendRect(&data->surface, NULL, - renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } - - data->renderer->UnlockTexture(data->renderer, texture); - } - return status; -} - -static int -SW_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Texture *texture = data->texture[data->current_texture]; - SDL_Rect clip, rect; - Uint32 color = 0; - int i; - int status = 0; - - clip.x = 0; - clip.y = 0; - clip.w = texture->w; - clip.h = texture->h; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - color = SDL_MapRGBA(data->surface.format, - renderer->r, renderer->g, renderer->b, - renderer->a); - } - - for (i = 0; i < count; ++i) { - if (!SDL_IntersectRect(rects[i], &clip, &rect)) { - /* Nothing to draw */ - continue; - } - - if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { - SDL_AddDirtyRect(&data->dirty, &rect); - } - - if (data->renderer->LockTexture(data->renderer, texture, &rect, 1, - &data->surface.pixels, - &data->surface.pitch) < 0) { - return -1; - } - - data->surface.clip_rect.w = data->surface.w = rect.w; - data->surface.clip_rect.h = data->surface.h = rect.h; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - status = SDL_FillRect(&data->surface, NULL, color); - } else { - status = SDL_BlendFillRect(&data->surface, NULL, - renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } - - data->renderer->UnlockTexture(data->renderer, texture); - } - return status; -} - -static int -SW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - int status; - - if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { - SDL_AddDirtyRect(&data->dirty, dstrect); - } - - if (data->renderer->LockTexture(data->renderer, - data->texture[data->current_texture], - dstrect, 1, &data->surface.pixels, - &data->surface.pitch) < 0) { - return -1; - } - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - status = - SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata, - srcrect, data->format, dstrect->w, dstrect->h, - data->surface.pixels, data->surface.pitch); - } else { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - SDL_Rect real_srcrect = *srcrect; - SDL_Rect real_dstrect; - - data->surface.w = dstrect->w; - data->surface.h = dstrect->h; - data->surface.clip_rect.w = dstrect->w; - data->surface.clip_rect.h = dstrect->h; - real_dstrect = data->surface.clip_rect; - - status = - SDL_LowerBlit(surface, &real_srcrect, &data->surface, - &real_dstrect); - } - data->renderer->UnlockTexture(data->renderer, - data->texture[data->current_texture]); - return status; -} - -static int -SW_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - - if (data->renderer->LockTexture(data->renderer, - data->texture[data->current_texture], - rect, 0, &data->surface.pixels, - &data->surface.pitch) < 0) { - return -1; - } - - SDL_ConvertPixels(rect->w, rect->h, - data->format, data->surface.pixels, data->surface.pitch, - format, pixels, pitch); - - data->renderer->UnlockTexture(data->renderer, - data->texture[data->current_texture]); - return 0; -} - -static int -SW_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - - if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { - SDL_AddDirtyRect(&data->dirty, rect); - } - - if (data->renderer->LockTexture(data->renderer, - data->texture[data->current_texture], - rect, 1, &data->surface.pixels, - &data->surface.pitch) < 0) { - return -1; - } - - SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch, - data->format, data->surface.pixels, data->surface.pitch); - - data->renderer->UnlockTexture(data->renderer, - data->texture[data->current_texture]); - return 0; -} - -static void -SW_RenderPresent(SDL_Renderer * renderer) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Texture *texture = data->texture[data->current_texture]; - - /* Send the data to the display */ - if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) { - SDL_DirtyRect *dirty; - for (dirty = data->dirty.list; dirty; dirty = dirty->next) { - data->renderer->RenderCopy(data->renderer, texture, &dirty->rect, - &dirty->rect); - } - SDL_ClearDirtyRects(&data->dirty); - } else { - SDL_Rect rect; - rect.x = 0; - rect.y = 0; - rect.w = texture->w; - rect.h = texture->h; - data->renderer->RenderCopy(data->renderer, texture, &rect, &rect); - } - data->renderer->RenderPresent(data->renderer); - - /* Update the flipping chain, if any */ - if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { - data->current_texture = (data->current_texture + 1) % 2; - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { - data->current_texture = (data->current_texture + 1) % 3; - } -} - -static void -SW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - SDL_SW_DestroyYUVTexture((SDL_SW_YUVTexture *) texture->driverdata); - } else { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - - SDL_FreeSurface(surface); - } -} - -static void -SW_DestroyRenderer(SDL_Renderer * renderer) -{ - SW_RenderData *data = (SW_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - int i; - - if (data) { - for (i = 0; i < SDL_arraysize(data->texture); ++i) { - if (data->texture[i]) { - DestroyTexture(data->renderer, data->texture[i]); - } - } - if (data->surface.format) { - SDL_SetSurfacePalette(&data->surface, NULL); - SDL_FreeFormat(data->surface.format); - } - if (display->palette) { - SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged, - data); - } - if (data->renderer) { - data->renderer->DestroyRenderer(data->renderer); - } - SDL_FreeDirtyRects(&data->dirty); - SDL_free(data); - } - SDL_free(renderer); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_renderer_sw.h b/project/jni/sdl-1.3/src/video/SDL_renderer_sw.h deleted file mode 100644 index 6a6daa8c3..000000000 --- a/project/jni/sdl-1.3/src/video/SDL_renderer_sw.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* SDL surface based renderer implementation */ - -extern SDL_RenderDriver SW_RenderDriver; - -/* Set up SDL_Surface texture functions for a renderer */ -void Setup_SoftwareRenderer(SDL_Renderer * renderer); - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_shape.c b/project/jni/sdl-1.3/src/video/SDL_shape.c index fe5f7fffa..3e0c030f8 100644 --- a/project/jni/sdl-1.3/src/video/SDL_shape.c +++ b/project/jni/sdl-1.3/src/video/SDL_shape.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -35,7 +34,7 @@ SDL_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned SDL_Window *result = NULL; result = SDL_CreateWindow(title,-1000,-1000,w,h,(flags | SDL_WINDOW_BORDERLESS) & (~SDL_WINDOW_FULLSCREEN) & (~SDL_WINDOW_RESIZABLE) /*& (~SDL_WINDOW_SHOWN)*/); if(result != NULL) { - result->shaper = result->display->device->shape_driver.CreateShaper(result); + result->shaper = SDL_GetVideoDevice()->shape_driver.CreateShaper(result); if(result->shaper != NULL) { result->shaper->userx = x; result->shaper->usery = y; @@ -116,7 +115,7 @@ SDL_CalculateShapeBitmap(SDL_WindowShapeMode mode,SDL_Surface *shape,Uint8* bitm SDL_UnlockSurface(shape); } -SDL_ShapeTree* +static SDL_ShapeTree* RecursivelyCalculateShapeTree(SDL_WindowShapeMode mode,SDL_Surface* mask,SDL_Rect dimensions) { int x = 0,y = 0; Uint8* pixel = NULL; @@ -240,7 +239,7 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh if(shape_mode != NULL) window->shaper->mode = *shape_mode; - result = window->display->device->shape_driver.SetWindowShape(window->shaper,shape,shape_mode); + result = SDL_GetVideoDevice()->shape_driver.SetWindowShape(window->shaper,shape,shape_mode); window->shaper->hasshape = SDL_TRUE; if(window->shaper->userx != 0 && window->shaper->usery != 0) { SDL_SetWindowPosition(window,window->shaper->userx,window->shaper->usery); @@ -250,7 +249,7 @@ SDL_SetWindowShape(SDL_Window *window,SDL_Surface *shape,SDL_WindowShapeMode *sh return result; } -SDL_bool +static SDL_bool SDL_WindowHasAShape(SDL_Window *window) { if (window == NULL || !SDL_IsShapedWindow(window)) return SDL_FALSE; diff --git a/project/jni/sdl-1.3/src/video/SDL_shape_internals.h b/project/jni/sdl-1.3/src/video/SDL_shape_internals.h index b831455e3..9d0dc8732 100644 --- a/project/jni/sdl-1.3/src/video/SDL_shape_internals.h +++ b/project/jni/sdl-1.3/src/video/SDL_shape_internals.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/SDL_stretch.c b/project/jni/sdl-1.3/src/video/SDL_stretch.c index 09a9a24df..92a37c923 100644 --- a/project/jni/sdl-1.3/src/video/SDL_stretch.c +++ b/project/jni/sdl-1.3/src/video/SDL_stretch.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/SDL_surface.c b/project/jni/sdl-1.3/src/video/SDL_surface.c index 2e2f583b7..62c5f5f3d 100644 --- a/project/jni/sdl-1.3/src/video/SDL_surface.c +++ b/project/jni/sdl-1.3/src/video/SDL_surface.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -27,7 +26,6 @@ #include "SDL_blit.h" #include "SDL_RLEaccel_c.h" #include "SDL_pixels_c.h" -#include "SDL_leaks.h" /* Public routines */ @@ -40,10 +38,18 @@ SDL_CreateRGBSurface(Uint32 flags, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { SDL_Surface *surface; + Uint32 format; /* The flags are no longer used, make the compiler happy */ (void)flags; + /* Get the pixel format */ + format = SDL_MasksToPixelFormatEnum(depth, Rmask, Gmask, Bmask, Amask); + if (format == SDL_PIXELFORMAT_UNKNOWN) { + SDL_SetError("Unknown pixel format"); + return NULL; + } + /* Allocate the surface */ surface = (SDL_Surface *) SDL_calloc(1, sizeof(*surface)); if (surface == NULL) { @@ -51,7 +57,7 @@ SDL_CreateRGBSurface(Uint32 flags, return NULL; } - surface->format = SDL_AllocFormat(depth, Rmask, Gmask, Bmask, Amask); + surface->format = SDL_AllocFormat(format); if (!surface->format) { SDL_FreeSurface(surface); return NULL; @@ -61,51 +67,14 @@ SDL_CreateRGBSurface(Uint32 flags, surface->pitch = SDL_CalculatePitch(surface); SDL_SetClipRect(surface, NULL); - if (surface->format->BitsPerPixel <= 8) { + if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) { SDL_Palette *palette = SDL_AllocPalette((1 << surface->format->BitsPerPixel)); if (!palette) { SDL_FreeSurface(surface); return NULL; } - if (Rmask || Bmask || Gmask) { - const SDL_PixelFormat *format = surface->format; - - /* create palette according to masks */ - int i; - int Rm = 0, Gm = 0, Bm = 0; - int Rw = 0, Gw = 0, Bw = 0; - - if (Rmask) { - Rw = 8 - format->Rloss; - for (i = format->Rloss; i > 0; i -= Rw) - Rm |= 1 << i; - } - if (Gmask) { - Gw = 8 - format->Gloss; - for (i = format->Gloss; i > 0; i -= Gw) - Gm |= 1 << i; - } - if (Bmask) { - Bw = 8 - format->Bloss; - for (i = format->Bloss; i > 0; i -= Bw) - Bm |= 1 << i; - } - for (i = 0; i < palette->ncolors; ++i) { - int r, g, b; - r = (i & Rmask) >> format->Rshift; - r = (r << format->Rloss) | ((r * Rm) >> Rw); - palette->colors[i].r = r; - - g = (i & Gmask) >> format->Gshift; - g = (g << format->Gloss) | ((g * Gm) >> Gw); - palette->colors[i].g = g; - - b = (i & Bmask) >> format->Bshift; - b = (b << format->Bloss) | ((b * Bm) >> Bw); - palette->colors[i].b = b; - } - } else if (palette->ncolors == 2) { + if (palette->ncolors == 2) { /* Create a black and white bitmap palette */ palette->colors[0].r = 0xFF; palette->colors[0].g = 0xFF; @@ -136,7 +105,6 @@ SDL_CreateRGBSurface(Uint32 flags, SDL_FreeSurface(surface); return NULL; } - SDL_FormatChanged(surface); /* By default surface with an alpha mask are set up for blending */ if (Amask) { @@ -145,9 +113,6 @@ SDL_CreateRGBSurface(Uint32 flags, /* The surface is ready to go */ surface->refcount = 1; -#ifdef CHECK_LEAKS - ++surfaces_allocated; -#endif return surface; } @@ -175,46 +140,14 @@ SDL_CreateRGBSurfaceFrom(void *pixels, return surface; } -static int -SDL_SurfacePaletteChanged(void *userdata, SDL_Palette * palette) -{ - SDL_Surface *surface = (SDL_Surface *) userdata; - - SDL_FormatChanged(surface); - - return 0; -} - int SDL_SetSurfacePalette(SDL_Surface * surface, SDL_Palette * palette) { - if (!surface || !surface->format) { + if (!surface) { SDL_SetError("SDL_SetSurfacePalette() passed a NULL surface"); return -1; } - - if (palette && palette->ncolors != (1 << surface->format->BitsPerPixel)) { - SDL_SetError - ("SDL_SetSurfacePalette() passed a palette that doesn't match the surface format"); - return -1; - } - - if (surface->format->palette == palette) { - return 0; - } - - if (surface->format->palette) { - SDL_DelPaletteWatch(surface->format->palette, - SDL_SurfacePaletteChanged, surface); - } - - surface->format->palette = palette; - - if (surface->format->palette) { - SDL_AddPaletteWatch(surface->format->palette, - SDL_SurfacePaletteChanged, surface); - } - return 0; + return SDL_SetPixelFormatPalette(surface->format, palette); } int @@ -449,13 +382,10 @@ SDL_SetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode blendMode) status = 0; flags = surface->map->info.flags; surface->map->info.flags &= - ~(SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD); + ~(SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD); switch (blendMode) { case SDL_BLENDMODE_NONE: break; - case SDL_BLENDMODE_MASK: - surface->map->info.flags |= SDL_COPY_MASK; - break; case SDL_BLENDMODE_BLEND: surface->map->info.flags |= SDL_COPY_BLEND; break; @@ -497,11 +427,7 @@ SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode) } switch (surface->map-> - info.flags & (SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | - SDL_COPY_MOD)) { - case SDL_COPY_MASK: - *blendMode = SDL_BLENDMODE_MASK; - break; + info.flags & (SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD)) { case SDL_COPY_BLEND: *blendMode = SDL_BLENDMODE_BLEND; break; @@ -518,64 +444,6 @@ SDL_GetSurfaceBlendMode(SDL_Surface * surface, SDL_BlendMode *blendMode) return 0; } -int -SDL_SetSurfaceScaleMode(SDL_Surface * surface, SDL_ScaleMode scaleMode) -{ - int flags, status; - - if (!surface) { - return -1; - } - - status = 0; - flags = surface->map->info.flags; - surface->map->info.flags &= ~(SDL_COPY_NEAREST); - switch (scaleMode) { - case SDL_SCALEMODE_NONE: - break; - case SDL_SCALEMODE_FAST: - surface->map->info.flags |= SDL_COPY_NEAREST; - break; - case SDL_SCALEMODE_SLOW: - case SDL_SCALEMODE_BEST: - SDL_Unsupported(); - surface->map->info.flags |= SDL_COPY_NEAREST; - status = -1; - break; - default: - SDL_Unsupported(); - status = -1; - break; - } - - if (surface->map->info.flags != flags) { - SDL_InvalidateMap(surface->map); - } - return status; -} - -int -SDL_GetSurfaceScaleMode(SDL_Surface * surface, SDL_ScaleMode *scaleMode) -{ - if (!surface) { - return -1; - } - - if (!scaleMode) { - return 0; - } - - switch (surface->map->info.flags & SDL_COPY_NEAREST) { - case SDL_COPY_NEAREST: - *scaleMode = SDL_SCALEMODE_FAST; - break; - default: - *scaleMode = SDL_SCALEMODE_NONE; - break; - } - return 0; -} - SDL_bool SDL_SetClipRect(SDL_Surface * surface, const SDL_Rect * rect) { @@ -625,7 +493,8 @@ SDL_LowerBlit(SDL_Surface * src, SDL_Rect * srcrect, { /* Check to make sure the blit mapping is valid */ if ((src->map->dst != dst) || - (src->map->dst->format_version != src->map->format_version)) { + (dst->format->palette && + src->map->palette_version != dst->format->palette->version)) { if (SDL_MapSurface(src, dst) < 0) { return (-1); } @@ -732,6 +601,135 @@ SDL_UpperBlit(SDL_Surface * src, const SDL_Rect * srcrect, return 0; } +int +SDL_UpperBlitScaled(SDL_Surface * src, const SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) +{ + SDL_Rect final_src, final_dst, fulldst; + + /* Make sure the surfaces aren't locked */ + if (!src || !dst) { + SDL_SetError("SDL_UpperBlitScaled: passed a NULL surface"); + return (-1); + } + if (src->locked || dst->locked) { + SDL_SetError("Surfaces must not be locked during blit"); + return (-1); + } + + /* If the destination rectangle is NULL, use the entire dest surface */ + if (dstrect == NULL) { + fulldst.x = fulldst.y = 0; + dstrect = &fulldst; + } + + /* clip the source rectangle to the source surface */ + if (srcrect) { + int maxw, maxh; + + final_src.x = srcrect->x; + final_src.w = srcrect->w; + if (final_src.x < 0) { + final_src.w += final_src.x; + final_src.x = 0; + } + maxw = src->w - final_src.x; + if (maxw < final_src.w) + final_src.w = maxw; + + final_src.y = srcrect->y; + final_src.h = srcrect->h; + if (final_src.y < 0) { + final_src.h += final_src.y; + final_src.y = 0; + } + maxh = src->h - final_src.y; + if (maxh < final_src.h) + final_src.h = maxh; + + } else { + final_src.x = final_src.y = 0; + final_src.w = src->w; + final_src.h = src->h; + } + + /* clip the destination rectangle against the clip rectangle */ + if (dstrect) { + int maxw, maxh; + + final_dst.x = dstrect->x; + final_dst.w = dstrect->w; + if (final_dst.x < 0) { + final_dst.w += final_dst.x; + final_dst.x = 0; + } + maxw = dst->w - final_dst.x; + if (maxw < final_dst.w) + final_dst.w = maxw; + + final_dst.y = dstrect->y; + final_dst.h = dstrect->h; + if (final_dst.y < 0) { + final_dst.h += final_dst.y; + final_dst.y = 0; + } + maxh = dst->h - final_dst.y; + if (maxh < final_dst.h) + final_dst.h = maxh; + } else { + final_dst.x = final_dst.y = 0; + final_dst.w = dst->w; + final_dst.h = dst->h; + } + + if (final_dst.w > 0 && final_dst.h > 0) { + return SDL_LowerBlitScaled(src, &final_src, dst, &final_dst); + } + + return 0; +} + +/** + * This is a semi-private blit function and it performs low-level surface + * scaled blitting only. + */ +int +SDL_LowerBlitScaled(SDL_Surface * src, SDL_Rect * srcrect, + SDL_Surface * dst, SDL_Rect * dstrect) +{ + /* Save off the original dst width, height */ + int dstW = dstrect->w; + int dstH = dstrect->h; + SDL_Rect final_dst = *dstrect; + SDL_Rect final_src = *srcrect; + + /* Clip the dst surface to the dstrect */ + SDL_SetClipRect( dst, &final_dst ); + + /* Did the dst width change? */ + if ( dstW != dst->clip_rect.w ) { + /* scale the src width appropriately */ + final_src.w = final_src.w * dst->clip_rect.w / dstW; + } + + /* Did the dst height change? */ + if ( dstH != dst->clip_rect.h ) { + /* scale the src width appropriately */ + final_src.h = final_src.h * dst->clip_rect.h / dstH; + } + + /* Clip the src surface to the srcrect */ + SDL_SetClipRect( src, &final_src ); + + src->map->info.flags |= SDL_COPY_NEAREST; + + if ( src->format->format == dst->format->format && !SDL_ISPIXELFORMAT_INDEXED(src->format->format) ) { + return SDL_SoftStretch( src, &final_src, dst, &final_dst ); + } else { + return SDL_LowerBlit( src, &final_src, dst, &final_dst ); + } +} + /* * Lock a surface to directly access the pixels */ @@ -862,6 +860,21 @@ SDL_ConvertSurface(SDL_Surface * surface, SDL_PixelFormat * format, return (convert); } +SDL_Surface * +SDL_ConvertSurfaceFormat(SDL_Surface * surface, Uint32 pixel_format, + Uint32 flags) +{ + SDL_PixelFormat *fmt; + SDL_Surface *convert = NULL; + + fmt = SDL_AllocFormat(pixel_format); + if (fmt) { + convert = SDL_ConvertSurface(surface, fmt, flags); + SDL_FreeFormat(fmt); + } + return convert; +} + /* * Create a surface on the stack for quick blit operations */ @@ -870,21 +883,17 @@ SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, void * pixels, int pitch, SDL_Surface * surface, SDL_PixelFormat * format, SDL_BlitMap * blitmap) { - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (!SDL_PixelFormatEnumToMasks(pixel_format, - &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { + if (SDL_ISPIXELFORMAT_INDEXED(pixel_format)) { + SDL_SetError("Indexed pixel formats not supported"); return SDL_FALSE; } - if (bpp <= 8) { - SDL_SetError("Indexed pixel formats not supported"); + if (SDL_InitFormat(format, pixel_format) < 0) { return SDL_FALSE; } SDL_zerop(surface); surface->flags = SDL_PREALLOC; - surface->format = SDL_InitFormat(format, bpp, Rmask, Gmask, Bmask, Amask); + surface->format = format; surface->pixels = pixels; surface->w = width; surface->h = height; @@ -899,7 +908,6 @@ SDL_CreateSurfaceOnStack(int width, int height, Uint32 pixel_format, blitmap->info.b = 0xFF; blitmap->info.a = 0xFF; surface->map = blitmap; - SDL_FormatChanged(surface); /* The surface is ready to go */ surface->refcount = 1; @@ -944,7 +952,7 @@ int SDL_ConvertPixels(int width, int height, src = (Uint8*)src + src_pitch; dst = (Uint8*)dst + dst_pitch; } - return SDL_TRUE; + return 0; } if (!SDL_CreateSurfaceOnStack(width, height, src_format, (void*)src, @@ -974,6 +982,9 @@ SDL_FreeSurface(SDL_Surface * surface) if (surface == NULL) { return; } + if (surface->flags & SDL_DONTFREE) { + return; + } if (--surface->refcount > 0) { return; } @@ -996,9 +1007,6 @@ SDL_FreeSurface(SDL_Surface * surface) SDL_free(surface->pixels); } SDL_free(surface); -#ifdef CHECK_LEAKS - --surfaces_allocated; -#endif } /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/SDL_sysvideo.h b/project/jni/sdl-1.3/src/video/SDL_sysvideo.h index f8af44377..416bfb6d2 100644 --- a/project/jni/sdl-1.3/src/video/SDL_sysvideo.h +++ b/project/jni/sdl-1.3/src/video/SDL_sysvideo.h @@ -1,142 +1,37 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef _SDL_sysvideo_h #define _SDL_sysvideo_h -#include "SDL_mouse.h" -#include "SDL_keysym.h" #include "SDL_shape.h" /* The SDL video driver */ -typedef struct SDL_Renderer SDL_Renderer; -typedef struct SDL_RenderDriver SDL_RenderDriver; typedef struct SDL_WindowShaper SDL_WindowShaper; typedef struct SDL_ShapeDriver SDL_ShapeDriver; typedef struct SDL_VideoDisplay SDL_VideoDisplay; typedef struct SDL_VideoDevice SDL_VideoDevice; -/* Define the SDL texture structure */ -struct SDL_Texture -{ - const void *magic; - Uint32 format; /**< The pixel format of the texture */ - int access; /**< SDL_TextureAccess */ - int w; /**< The width of the texture */ - int h; /**< The height of the texture */ - int modMode; /**< The texture modulation mode */ - SDL_BlendMode blendMode; /**< The texture blend mode */ - SDL_ScaleMode scaleMode; /**< The texture scale mode */ - Uint8 r, g, b, a; /**< Texture modulation values */ - - SDL_Renderer *renderer; - - void *driverdata; /**< Driver specific texture representation */ - - SDL_Texture *prev; - SDL_Texture *next; -}; - -/* Define the SDL renderer structure */ -struct SDL_Renderer -{ - int (*ActivateRenderer) (SDL_Renderer * renderer); - int (*DisplayModeChanged) (SDL_Renderer * renderer); - int (*CreateTexture) (SDL_Renderer * renderer, SDL_Texture * texture); - int (*QueryTexturePixels) (SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch); - int (*SetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); - int (*GetTexturePalette) (SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, - int ncolors); - int (*SetTextureColorMod) (SDL_Renderer * renderer, - SDL_Texture * texture); - int (*SetTextureAlphaMod) (SDL_Renderer * renderer, - SDL_Texture * texture); - int (*SetTextureBlendMode) (SDL_Renderer * renderer, - SDL_Texture * texture); - int (*SetTextureScaleMode) (SDL_Renderer * renderer, - SDL_Texture * texture); - int (*UpdateTexture) (SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); - int (*LockTexture) (SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch); - void (*UnlockTexture) (SDL_Renderer * renderer, SDL_Texture * texture); - void (*DirtyTexture) (SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects); - int (*SetDrawColor) (SDL_Renderer * renderer); - int (*SetDrawBlendMode) (SDL_Renderer * renderer); - int (*RenderClear) (SDL_Renderer * renderer); - int (*RenderDrawPoints) (SDL_Renderer * renderer, const SDL_Point * points, - int count); - int (*RenderDrawLines) (SDL_Renderer * renderer, const SDL_Point * points, - int count); - int (*RenderDrawRects) (SDL_Renderer * renderer, const SDL_Rect ** rects, - int count); - int (*RenderFillRects) (SDL_Renderer * renderer, const SDL_Rect ** rects, - int count); - int (*RenderCopy) (SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect); - int (*RenderReadPixels) (SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch); - int (*RenderWritePixels) (SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch); - void (*RenderPresent) (SDL_Renderer * renderer); - void (*DestroyTexture) (SDL_Renderer * renderer, SDL_Texture * texture); - - void (*DestroyRenderer) (SDL_Renderer * renderer); - - /* The current renderer info */ - SDL_RendererInfo info; - - /* The window associated with the renderer */ - SDL_Window *window; - - /* The list of textures */ - SDL_Texture *textures; - - Uint8 r, g, b, a; /**< Color for drawing operations values */ - SDL_BlendMode blendMode; /**< The drawing blend mode */ - - void *driverdata; -}; - -/* Define the SDL render driver structure */ -struct SDL_RenderDriver -{ - SDL_Renderer *(*CreateRenderer) (SDL_Window * window, Uint32 flags); - - /* Info about the renderer capabilities */ - SDL_RendererInfo info; - /* Used for resizing renderer */ - size_t infoSize; -}; - /* Define the SDL window-shaper structure */ struct SDL_WindowShaper { @@ -163,6 +58,13 @@ struct SDL_ShapeDriver int (*ResizeWindowShape)(SDL_Window *window); }; +typedef struct SDL_WindowUserData +{ + char *name; + void *data; + struct SDL_WindowUserData *next; +} SDL_WindowUserData; + /* Define the SDL window structure, corresponding to toplevel windows */ struct SDL_Window { @@ -173,14 +75,22 @@ struct SDL_Window int w, h; Uint32 flags; - SDL_VideoDisplay *display; - SDL_Renderer *renderer; + /* Stored position and size for windowed mode */ + SDL_Rect windowed; SDL_DisplayMode fullscreen_mode; + float brightness; + Uint16 *gamma; + Uint16 *saved_gamma; /* (just offset into gamma) */ + + SDL_Surface *surface; + SDL_bool surface_valid; + SDL_WindowShaper *shaper; - void *userdata; + SDL_WindowUserData *data; + void *driverdata; SDL_Window *prev; @@ -202,25 +112,17 @@ struct SDL_VideoDisplay SDL_DisplayMode *display_modes; SDL_DisplayMode desktop_mode; SDL_DisplayMode current_mode; - SDL_bool updating_fullscreen; - SDL_Palette *palette; - Uint16 *gamma; - Uint16 *saved_gamma; /* (just offset into gamma) */ - - int num_render_drivers; - SDL_RenderDriver *render_drivers; - - SDL_Window *windows; SDL_Window *fullscreen_window; - SDL_Renderer *current_renderer; - SDL_VideoDevice *device; void *driverdata; }; +/* Forward declaration */ +struct SDL_SysWMinfo; + /* Define the SDL video driver structure */ #define _THIS SDL_VideoDevice *_this @@ -256,8 +158,7 @@ struct SDL_VideoDevice int (*GetDisplayBounds) (_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); /* - * Get a list of the available display modes. e.g. - * SDL_AddDisplayMode(_this->current_display, mode) + * Get a list of the available display modes for a display. */ void (*GetDisplayModes) (_THIS, SDL_VideoDisplay * display); @@ -269,18 +170,6 @@ struct SDL_VideoDevice */ int (*SetDisplayMode) (_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); - /* Set the color entries of the display palette */ - int (*SetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette); - - /* Get the color entries of the display palette */ - int (*GetDisplayPalette) (_THIS, SDL_VideoDisplay * display, SDL_Palette * palette); - - /* Set the gamma ramp */ - int (*SetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp); - - /* Get the gamma ramp */ - int (*GetDisplayGammaRamp) (_THIS, SDL_VideoDisplay * display, Uint16 * ramp); - /* * * */ /* * Window functions @@ -297,9 +186,15 @@ struct SDL_VideoDevice void (*MaximizeWindow) (_THIS, SDL_Window * window); void (*MinimizeWindow) (_THIS, SDL_Window * window); void (*RestoreWindow) (_THIS, SDL_Window * window); + void (*SetWindowFullscreen) (_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); + int (*SetWindowGammaRamp) (_THIS, SDL_Window * window, const Uint16 * ramp); + int (*GetWindowGammaRamp) (_THIS, SDL_Window * window, Uint16 * ramp); void (*SetWindowGrab) (_THIS, SDL_Window * window); void (*DestroyWindow) (_THIS, SDL_Window * window); - + int (*CreateWindowFramebuffer) (_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); + int (*UpdateWindowFramebuffer) (_THIS, SDL_Window * window, SDL_Rect * rects, int numrects); + void (*DestroyWindowFramebuffer) (_THIS, SDL_Window * window); + /* * * */ /* * Shaped-window functions @@ -348,9 +243,8 @@ struct SDL_VideoDevice SDL_bool suspend_screensaver; int num_displays; SDL_VideoDisplay *displays; - int current_display; + SDL_Window *windows; Uint8 window_magic; - Uint8 texture_magic; Uint32 next_object_id; char * clipboard_text; @@ -382,6 +276,11 @@ struct SDL_VideoDevice void *dll_handle; } gl_config; + /* * * */ + /* Cache current GL context; don't call the OS when it hasn't changed. */ + SDL_Window *current_glwin; + SDL_GLContext current_glctx; + /* * * */ /* Data private to this driver */ void *driverdata; @@ -410,70 +309,36 @@ extern VideoBootStrap COCOA_bootstrap; #if SDL_VIDEO_DRIVER_X11 extern VideoBootStrap X11_bootstrap; #endif -#if SDL_VIDEO_DRIVER_FBCON -extern VideoBootStrap FBCON_bootstrap; -#endif #if SDL_VIDEO_DRIVER_DIRECTFB extern VideoBootStrap DirectFB_bootstrap; #endif -#if SDL_VIDEO_DRIVER_PS3 -extern VideoBootStrap PS3_bootstrap; -#endif -#if SDL_VIDEO_DRIVER_SVGALIB -extern VideoBootStrap SVGALIB_bootstrap; -#endif -#if SDL_VIDEO_DRIVER_WIN32 -extern VideoBootStrap WIN32_bootstrap; +#if SDL_VIDEO_DRIVER_WINDOWS +extern VideoBootStrap WINDOWS_bootstrap; #endif #if SDL_VIDEO_DRIVER_BWINDOW extern VideoBootStrap BWINDOW_bootstrap; #endif -#if SDL_VIDEO_DRIVER_PHOTON -extern VideoBootStrap photon_bootstrap; +#if SDL_VIDEO_DRIVER_PANDORA +extern VideoBootStrap PND_bootstrap; #endif -#if SDL_VIDEO_DRIVER_QNXGF -extern VideoBootStrap qnxgf_bootstrap; -#endif -#if SDL_VIDEO_DRIVER_EPOC -extern VideoBootStrap EPOC_bootstrap; -#endif -#if SDL_VIDEO_DRIVER_RISCOS -extern VideoBootStrap RISCOS_bootstrap; +#if SDL_VIDEO_DRIVER_NDS +extern VideoBootStrap NDS_bootstrap; #endif #if SDL_VIDEO_DRIVER_UIKIT extern VideoBootStrap UIKIT_bootstrap; #endif #if SDL_VIDEO_DRIVER_ANDROID -extern VideoBootStrap ANDROID_bootstrap; +extern VideoBootStrap Android_bootstrap; #endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif -#if SDL_VIDEO_DRIVER_NDS -extern VideoBootStrap NDS_bootstrap; -#endif -#if SDL_VIDEO_DRIVER_PANDORA -extern VideoBootStrap PND_bootstrap; -#endif - -#define SDL_CurrentDisplay (&_this->displays[_this->current_display]) -#define SDL_CurrentRenderer (SDL_CurrentDisplay->current_renderer) extern SDL_VideoDevice *SDL_GetVideoDevice(void); extern int SDL_AddBasicVideoDisplay(const SDL_DisplayMode * desktop_mode); extern int SDL_AddVideoDisplay(const SDL_VideoDisplay * display); extern SDL_bool SDL_AddDisplayMode(SDL_VideoDisplay *display, const SDL_DisplayMode * mode); -extern int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display); -extern int SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode); -extern int SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode); -extern int SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode); -extern SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest); -extern int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode); -extern int SDL_SetPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors); -extern int SDL_GetPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors); -extern int SDL_SetGammaRampForDisplay(SDL_VideoDisplay * display, const Uint16 * red, const Uint16 * green, const Uint16 * blue); -extern int SDL_GetGammaRampForDisplay(SDL_VideoDisplay * display, Uint16 * red, Uint16 * green, Uint16 * blue); -extern void SDL_AddRenderDriver(SDL_VideoDisplay *display, const SDL_RenderDriver * driver); +extern SDL_VideoDisplay *SDL_GetDisplayForWindow(SDL_Window *window); extern int SDL_RecreateWindow(SDL_Window * window, Uint32 flags); diff --git a/project/jni/sdl-1.3/src/video/SDL_video.c b/project/jni/sdl-1.3/src/video/SDL_video.c index 87bed9154..66966a781 100644 --- a/project/jni/sdl-1.3/src/video/SDL_video.c +++ b/project/jni/sdl-1.3/src/video/SDL_video.c @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -28,27 +27,21 @@ #include "SDL_sysvideo.h" #include "SDL_blit.h" #include "SDL_pixels_c.h" -#include "SDL_renderer_gl.h" -#include "SDL_renderer_gles.h" -#include "SDL_renderer_sw.h" -#include "../events/SDL_sysevents.h" +#include "SDL_rect_c.h" #include "../events/SDL_events_c.h" -#ifdef ANDROID #include -#endif -#if SDL_VIDEO_DRIVER_WIN32 -#include "win32/SDL_win32video.h" -extern void IME_Present(SDL_VideoData *videodata); -#endif +#if SDL_VIDEO_OPENGL +#include "SDL_opengl.h" +#endif /* SDL_VIDEO_OPENGL */ #if SDL_VIDEO_OPENGL_ES #include "SDL_opengles.h" #endif /* SDL_VIDEO_OPENGL_ES */ -#if SDL_VIDEO_OPENGL -#include "SDL_opengl.h" -#endif /* SDL_VIDEO_OPENGL */ +#if SDL_VIDEO_OPENGL_ES2 +#include "SDL_opengles2.h" +#endif /* SDL_VIDEO_OPENGL_ES2 */ #include "SDL_syswm.h" @@ -65,35 +58,17 @@ static VideoBootStrap *bootstrap[] = { #if SDL_VIDEO_DRIVER_X11 &X11_bootstrap, #endif -#if SDL_VIDEO_DRIVER_FBCON - &FBCON_bootstrap, -#endif #if SDL_VIDEO_DRIVER_DIRECTFB &DirectFB_bootstrap, #endif -#if SDL_VIDEO_DRIVER_PS3 - &PS3_bootstrap, -#endif -#if SDL_VIDEO_DRIVER_SVGALIB - &SVGALIB_bootstrap, -#endif -#if SDL_VIDEO_DRIVER_WIN32 - &WIN32_bootstrap, +#if SDL_VIDEO_DRIVER_WINDOWS + &WINDOWS_bootstrap, #endif #if SDL_VIDEO_DRIVER_BWINDOW &BWINDOW_bootstrap, #endif -#if SDL_VIDEO_DRIVER_PHOTON - &photon_bootstrap, -#endif -#if SDL_VIDEO_DRIVER_QNXGF - &qnxgf_bootstrap, -#endif -#if SDL_VIDEO_DRIVER_EPOC - &EPOC_bootstrap, -#endif -#if SDL_VIDEO_DRIVER_RISCOS - &RISCOS_bootstrap, +#if SDL_VIDEO_DRIVER_PANDORA + &PND_bootstrap, #endif #if SDL_VIDEO_DRIVER_NDS &NDS_bootstrap, @@ -102,41 +77,286 @@ static VideoBootStrap *bootstrap[] = { &UIKIT_bootstrap, #endif #if SDL_VIDEO_DRIVER_ANDROID - &ANDROID_bootstrap, + &Android_bootstrap, #endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, -#endif -#if SDL_VIDEO_DRIVER_PANDORA - &PND_bootstrap, #endif NULL }; static SDL_VideoDevice *_this = NULL; -#define CHECK_WINDOW_MAGIC(window, retval) \ +#define CHECK_WINDOW_MAGIC1(window, retval, F, L) \ if (!_this) { \ SDL_UninitializedVideo(); \ return retval; \ } \ if (!window || window->magic != &_this->window_magic) { \ - SDL_SetError("Invalid window"); \ + SDL_SetError("CHECK_WINDOW_MAGIC: Invalid window %p at %s:%d", window, F, L); \ return retval; \ } +#define CHECK_WINDOW_MAGIC(window, retval) CHECK_WINDOW_MAGIC1(window, retval, __FILE__, __LINE__) -#define CHECK_TEXTURE_MAGIC(texture, retval) \ +#define CHECK_DISPLAY_INDEX(displayIndex, retval) \ if (!_this) { \ SDL_UninitializedVideo(); \ return retval; \ } \ - if (!texture || texture->magic != &_this->texture_magic) { \ - SDL_SetError("Invalid texture"); \ + if (displayIndex < 0 || displayIndex >= _this->num_displays) { \ + SDL_SetError("displayIndex must be in the range 0 - %d", \ + _this->num_displays - 1); \ return retval; \ } -/* Various local functions */ -static void SDL_UpdateWindowGrab(SDL_Window * window); +/* Support for framebuffer emulation using an accelerated renderer */ + +#define SDL_WINDOWTEXTUREDATA "_SDL_WindowTextureData" + +typedef struct { + SDL_Renderer *renderer; + SDL_Texture *texture; + void *pixels; + int pitch; + int bytes_per_pixel; +} SDL_WindowTextureData; + +static SDL_bool +ShouldUseTextureFramebuffer() +{ + const char *hint; + + /* If there's no native framebuffer support then there's no option */ + if (!_this->CreateWindowFramebuffer) { + return SDL_TRUE; + } + + /* If the user has specified a software renderer we can't use a + texture framebuffer, or renderer creation will go recursive. + */ + hint = SDL_GetHint(SDL_HINT_RENDER_DRIVER); + if (hint && SDL_strcasecmp(hint, "software") == 0) { + return SDL_FALSE; + } + + /* See if the user or application wants a specific behavior */ + hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); + if (hint) { + if (*hint == '0') { + return SDL_FALSE; + } else { + return SDL_TRUE; + } + } + + /* Each platform has different performance characteristics */ +#if defined(__WIN32__) + /* GDI BitBlt() is way faster than Direct3D dynamic textures right now. + */ + return SDL_FALSE; + +#elif defined(__MACOSX__) + /* Mac OS X uses OpenGL as the native fast path */ + return SDL_TRUE; + +#elif defined(__LINUX__) + /* Properly configured OpenGL drivers are faster than MIT-SHM */ +#if SDL_VIDEO_OPENGL + /* Ugh, find a way to cache this value! */ + { + SDL_Window *window; + SDL_GLContext context; + SDL_bool hasAcceleratedOpenGL = SDL_FALSE; + + window = SDL_CreateWindow("OpenGL test", -32, -32, 32, 32, SDL_WINDOW_OPENGL|SDL_WINDOW_HIDDEN); + if (window) { + context = SDL_GL_CreateContext(window); + if (context) { + const GLubyte *(APIENTRY * glGetStringFunc) (GLenum); + const char *vendor = NULL; + + glGetStringFunc = SDL_GL_GetProcAddress("glGetString"); + if (glGetStringFunc) { + vendor = (const char *) glGetStringFunc(GL_VENDOR); + } + /* Add more vendors here at will... */ + if (vendor && + (SDL_strstr(vendor, "ATI Technologies") || + SDL_strstr(vendor, "NVIDIA"))) { + hasAcceleratedOpenGL = SDL_TRUE; + } + SDL_GL_DeleteContext(context); + } + SDL_DestroyWindow(window); + } + return hasAcceleratedOpenGL; + } +#else + return SDL_FALSE; +#endif + +#else + /* Play it safe, assume that if there is a framebuffer driver that it's + optimized for the current platform. + */ + return SDL_FALSE; +#endif +} + +static int +SDL_CreateWindowTexture(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +{ + SDL_WindowTextureData *data; + SDL_RendererInfo info; + Uint32 i; + + data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); + if (!data) { + SDL_Renderer *renderer = NULL; + SDL_RendererInfo info; + int i; + const char *hint = SDL_GetHint(SDL_HINT_FRAMEBUFFER_ACCELERATION); + + /* Check to see if there's a specific driver requested */ + if (hint && *hint != '0' && *hint != '1' && + SDL_strcasecmp(hint, "software") != 0) { + for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) { + SDL_GetRenderDriverInfo(i, &info); + if (SDL_strcasecmp(info.name, hint) == 0) { + renderer = SDL_CreateRenderer(window, i, 0); + break; + } + } + } + + if (!renderer) { + for (i = 0; i < SDL_GetNumRenderDrivers(); ++i) { + SDL_GetRenderDriverInfo(i, &info); + if (SDL_strcmp(info.name, "software") != 0) { + renderer = SDL_CreateRenderer(window, i, 0); + if (renderer) { + break; + } + } + } + } + if (!renderer) { + return -1; + } + + /* Create the data after we successfully create the renderer (bug #1116) */ + data = (SDL_WindowTextureData *)SDL_calloc(1, sizeof(*data)); + if (!data) { + SDL_DestroyRenderer(renderer); + SDL_OutOfMemory(); + return -1; + } + SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, data); + + data->renderer = renderer; + } + + /* Free any old texture and pixel data */ + if (data->texture) { + SDL_DestroyTexture(data->texture); + data->texture = NULL; + } + if (data->pixels) { + SDL_free(data->pixels); + data->pixels = NULL; + } + + if (SDL_GetRendererInfo(data->renderer, &info) < 0) { + return -1; + } + + /* Find the first format without an alpha channel */ + *format = info.texture_formats[0]; + for (i = 0; i < info.num_texture_formats; ++i) { + if (!SDL_ISPIXELFORMAT_FOURCC(info.texture_formats[i]) && + !SDL_ISPIXELFORMAT_ALPHA(info.texture_formats[i])) { + *format = info.texture_formats[i]; + break; + } + } + + data->texture = SDL_CreateTexture(data->renderer, *format, + SDL_TEXTUREACCESS_STREAMING, + window->w, window->h); + if (!data->texture) { + return -1; + } + + /* Create framebuffer data */ + data->bytes_per_pixel = SDL_BYTESPERPIXEL(*format); + data->pitch = (((window->w * data->bytes_per_pixel) + 3) & ~3); + data->pixels = SDL_malloc(window->h * data->pitch); + if (!data->pixels) { + SDL_OutOfMemory(); + return -1; + } + + *pixels = data->pixels; + *pitch = data->pitch; + + /* Make sure we're not double-scaling the viewport */ + SDL_RenderSetViewport(data->renderer, NULL); + + return 0; +} + +static int +SDL_UpdateWindowTexture(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects) +{ + SDL_WindowTextureData *data; + SDL_Rect rect; + void *src; + + data = SDL_GetWindowData(window, SDL_WINDOWTEXTUREDATA); + if (!data || !data->texture) { + SDL_SetError("No window texture data"); + return -1; + } + + /* Update a single rect that contains subrects for best DMA performance */ + if (SDL_GetSpanEnclosingRect(window->w, window->h, numrects, rects, &rect)) { + src = (void *)((Uint8 *)data->pixels + + rect.y * data->pitch + + rect.x * data->bytes_per_pixel); + if (SDL_UpdateTexture(data->texture, &rect, src, data->pitch) < 0) { + return -1; + } + + if (SDL_RenderCopy(data->renderer, data->texture, NULL, NULL) < 0) { + return -1; + } + + SDL_RenderPresent(data->renderer); + } + return 0; +} + +static void +SDL_DestroyWindowTexture(_THIS, SDL_Window * window) +{ + SDL_WindowTextureData *data; + + data = SDL_SetWindowData(window, SDL_WINDOWTEXTUREDATA, NULL); + if (!data) { + return; + } + if (data->texture) { + SDL_DestroyTexture(data->texture); + } + if (data->renderer) { + SDL_DestroyRenderer(data->renderer); + } + if (data->pixels) { + SDL_free(data->pixels); + } + SDL_free(data); +} + static int cmpmodes(const void *A, const void *B) @@ -187,7 +407,7 @@ SDL_GetVideoDriver(int index) * Initialize the video and event subsystems -- determine native pixel format */ int -SDL_VideoInit(const char *driver_name, Uint32 flags) +SDL_VideoInit(const char *driver_name) { SDL_VideoDevice *video; int index; @@ -198,18 +418,12 @@ SDL_VideoInit(const char *driver_name, Uint32 flags) SDL_VideoQuit(); } - /* Toggle the event thread flags, based on OS requirements */ -#if defined(MUST_THREAD_EVENTS) - flags |= SDL_INIT_EVENTTHREAD; -#elif defined(CANT_THREAD_EVENTS) - if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) { - SDL_SetError("OS doesn't support threaded events"); - return -1; - } -#endif - /* Start the event loop */ - if (SDL_StartEventLoop(flags) < 0) { + if (SDL_StartEventLoop() < 0 || + SDL_KeyboardInit() < 0 || + SDL_MouseInit() < 0 || + SDL_TouchInit() < 0 || + SDL_QuitInit() < 0) { return -1; } @@ -269,34 +483,35 @@ SDL_VideoInit(const char *driver_name, Uint32 flags) _this->gl_config.multisamplesamples = 0; _this->gl_config.retained_backing = 1; _this->gl_config.accelerated = -1; /* accelerated or not, both are fine */ +#if SDL_VIDEO_OPENGL _this->gl_config.major_version = 2; _this->gl_config.minor_version = 1; +#elif SDL_VIDEO_OPENGL_ES + _this->gl_config.major_version = 1; + _this->gl_config.minor_version = 1; +#elif SDL_VIDEO_OPENGL_ES2 + _this->gl_config.major_version = 2; + _this->gl_config.minor_version = 0; +#endif /* Initialize the video subsystem */ if (_this->VideoInit(_this) < 0) { SDL_VideoQuit(); return -1; } + /* Make sure some displays were added */ if (_this->num_displays == 0) { SDL_SetError("The video driver did not add any displays"); SDL_VideoQuit(); return (-1); } - /* The software renderer is always available */ - for (i = 0; i < _this->num_displays; ++i) { - SDL_VideoDisplay *display = &_this->displays[i]; - if (_this->GL_CreateContext) { -#if SDL_VIDEO_RENDER_OGL - SDL_AddRenderDriver(display, &GL_RenderDriver); -#endif -#if SDL_VIDEO_RENDER_OGL_ES - SDL_AddRenderDriver(display, &GL_ES_RenderDriver); -#endif - } - if (display->num_render_drivers > 0) { - SDL_AddRenderDriver(display, &SW_RenderDriver); - } + + /* Add the renderer framebuffer emulation if desired */ + if (ShouldUseTextureFramebuffer()) { + _this->CreateWindowFramebuffer = SDL_CreateWindowTexture; + _this->UpdateWindowFramebuffer = SDL_UpdateWindowTexture; + _this->DestroyWindowFramebuffer = SDL_DestroyWindowTexture; } /* We're ready to go! */ @@ -363,65 +578,47 @@ SDL_GetNumVideoDisplays(void) return _this->num_displays; } -int -SDL_GetDisplayBounds(int index, SDL_Rect * rect) +static int +SDL_GetIndexOfDisplay(SDL_VideoDisplay *display) { - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - if (index < 0 || index >= _this->num_displays) { - SDL_SetError("index must be in the range 0 - %d", - _this->num_displays - 1); - return -1; - } - if (rect) { - SDL_VideoDisplay *display = &_this->displays[index]; + int displayIndex; - if (_this->GetDisplayBounds) { - if (_this->GetDisplayBounds(_this, display, rect) < 0) { - return -1; - } - } else { - /* Assume that the displays are left to right */ - if (index == 0) { - rect->x = 0; - rect->y = 0; - } else { - SDL_GetDisplayBounds(index-1, rect); - rect->x += rect->w; - } - rect->w = display->desktop_mode.w; - rect->h = display->desktop_mode.h; + for (displayIndex = 0; displayIndex < _this->num_displays; ++displayIndex) { + if (display == &_this->displays[displayIndex]) { + return displayIndex; } } + + /* Couldn't find the display, just use index 0 */ return 0; } int -SDL_SelectVideoDisplay(int index) +SDL_GetDisplayBounds(int displayIndex, SDL_Rect * rect) { - if (!_this) { - SDL_UninitializedVideo(); - return (-1); - } - if (index < 0 || index >= _this->num_displays) { - SDL_SetError("index must be in the range 0 - %d", - _this->num_displays - 1); - return -1; - } - _this->current_display = index; - return 0; -} + CHECK_DISPLAY_INDEX(displayIndex, -1); -int -SDL_GetCurrentVideoDisplay(void) -{ - if (!_this) { - SDL_UninitializedVideo(); - return (-1); + if (rect) { + SDL_VideoDisplay *display = &_this->displays[displayIndex]; + + if (_this->GetDisplayBounds) { + if (_this->GetDisplayBounds(_this, display, rect) == 0) { + return 0; + } + } + + /* Assume that the displays are left to right */ + if (displayIndex == 0) { + rect->x = 0; + rect->y = 0; + } else { + SDL_GetDisplayBounds(displayIndex-1, rect); + rect->x += rect->w; + } + rect->w = display->desktop_mode.w; + rect->h = display->desktop_mode.h; } - return _this->current_display; + return 0; } SDL_bool @@ -460,7 +657,7 @@ SDL_AddDisplayMode(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) return SDL_TRUE; } -int +static int SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display) { if (!display->num_display_modes && _this->GetDisplayModes) { @@ -472,17 +669,21 @@ SDL_GetNumDisplayModesForDisplay(SDL_VideoDisplay * display) } int -SDL_GetNumDisplayModes() +SDL_GetNumDisplayModes(int displayIndex) { - if (_this) { - return SDL_GetNumDisplayModesForDisplay(SDL_CurrentDisplay); - } - return 0; + CHECK_DISPLAY_INDEX(displayIndex, -1); + + return SDL_GetNumDisplayModesForDisplay(&_this->displays[displayIndex]); } int -SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayMode * mode) +SDL_GetDisplayMode(int displayIndex, int index, SDL_DisplayMode * mode) { + SDL_VideoDisplay *display; + + CHECK_DISPLAY_INDEX(displayIndex, -1); + + display = &_this->displays[displayIndex]; if (index < 0 || index >= SDL_GetNumDisplayModesForDisplay(display)) { SDL_SetError("index must be in the range of 0 - %d", SDL_GetNumDisplayModesForDisplay(display) - 1); @@ -495,14 +696,13 @@ SDL_GetDisplayModeForDisplay(SDL_VideoDisplay * display, int index, SDL_DisplayM } int -SDL_GetDisplayMode(int index, SDL_DisplayMode * mode) +SDL_GetDesktopDisplayMode(int displayIndex, SDL_DisplayMode * mode) { - return SDL_GetDisplayModeForDisplay(SDL_CurrentDisplay, index, mode); -} + SDL_VideoDisplay *display; -int -SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode) -{ + CHECK_DISPLAY_INDEX(displayIndex, -1); + + display = &_this->displays[displayIndex]; if (mode) { *mode = display->desktop_mode; } @@ -510,35 +710,20 @@ SDL_GetDesktopDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode } int -SDL_GetDesktopDisplayMode(SDL_DisplayMode * mode) +SDL_GetCurrentDisplayMode(int displayIndex, SDL_DisplayMode * mode) { - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - return SDL_GetDesktopDisplayModeForDisplay(SDL_CurrentDisplay, mode); -} + SDL_VideoDisplay *display; -int -SDL_GetCurrentDisplayModeForDisplay(SDL_VideoDisplay * display, SDL_DisplayMode * mode) -{ + CHECK_DISPLAY_INDEX(displayIndex, -1); + + display = &_this->displays[displayIndex]; if (mode) { *mode = display->current_mode; } return 0; } -int -SDL_GetCurrentDisplayMode(SDL_DisplayMode * mode) -{ - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - return SDL_GetCurrentDisplayModeForDisplay(SDL_CurrentDisplay, mode); -} - -SDL_DisplayMode * +static SDL_DisplayMode * SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode, SDL_DisplayMode * closest) @@ -646,22 +831,23 @@ SDL_GetClosestDisplayModeForDisplay(SDL_VideoDisplay * display, } SDL_DisplayMode * -SDL_GetClosestDisplayMode(const SDL_DisplayMode * mode, +SDL_GetClosestDisplayMode(int displayIndex, + const SDL_DisplayMode * mode, SDL_DisplayMode * closest) { - if (!_this) { - SDL_UninitializedVideo(); - return NULL; - } - return SDL_GetClosestDisplayModeForDisplay(SDL_CurrentDisplay, mode, closest); + SDL_VideoDisplay *display; + + CHECK_DISPLAY_INDEX(displayIndex, NULL); + + display = &_this->displays[displayIndex]; + return SDL_GetClosestDisplayModeForDisplay(display, mode, closest); } -int +static int SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * mode) { SDL_DisplayMode display_mode; SDL_DisplayMode current_mode; - int ncolors; if (mode) { display_mode = *mode; @@ -691,7 +877,7 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * } /* See if there's anything left to do */ - SDL_GetCurrentDisplayModeForDisplay(display, ¤t_mode); + current_mode = display->current_mode; if (SDL_memcmp(&display_mode, ¤t_mode, sizeof(display_mode)) == 0) { return 0; } @@ -705,32 +891,75 @@ SDL_SetDisplayModeForDisplay(SDL_VideoDisplay * display, const SDL_DisplayMode * return -1; } display->current_mode = display_mode; - - /* Set up a palette, if necessary */ - if (SDL_ISPIXELFORMAT_INDEXED(display_mode.format)) { - ncolors = (1 << SDL_BITSPERPIXEL(display_mode.format)); - } else { - ncolors = 0; - } - if ((!ncolors && display->palette) || (ncolors && !display->palette) - || (ncolors && ncolors != display->palette->ncolors)) { - if (display->palette) { - SDL_FreePalette(display->palette); - display->palette = NULL; - } - if (ncolors) { - display->palette = SDL_AllocPalette(ncolors); - if (!display->palette) { - return -1; - } - SDL_DitherColors(display->palette->colors, - SDL_BITSPERPIXEL(display_mode.format)); - } - } - return 0; } +int +SDL_GetWindowDisplay(SDL_Window * window) +{ + int displayIndex; + int i, dist; + int closest = -1; + int closest_dist = 0x7FFFFFFF; + SDL_Point center; + SDL_Point delta; + SDL_Rect rect; + + CHECK_WINDOW_MAGIC(window, -1); + + if (SDL_WINDOWPOS_ISUNDEFINED(window->x) || + SDL_WINDOWPOS_ISCENTERED(window->x)) { + displayIndex = (window->x & 0xFFFF); + if (displayIndex >= _this->num_displays) { + displayIndex = 0; + } + return displayIndex; + } + if (SDL_WINDOWPOS_ISUNDEFINED(window->y) || + SDL_WINDOWPOS_ISCENTERED(window->y)) { + displayIndex = (window->y & 0xFFFF); + if (displayIndex >= _this->num_displays) { + displayIndex = 0; + } + return displayIndex; + } + + /* Find the display containing the window */ + center.x = window->x + window->w / 2; + center.y = window->y + window->h / 2; + for (i = 0; i < _this->num_displays; ++i) { + SDL_VideoDisplay *display = &_this->displays[i]; + + SDL_GetDisplayBounds(i, &rect); + if (display->fullscreen_window == window || SDL_EnclosePoints(¢er, 1, &rect, NULL)) { + return i; + } + + delta.x = center.x - (rect.x + rect.w / 2); + delta.y = center.y - (rect.y + rect.h / 2); + dist = (delta.x*delta.x + delta.y*delta.y); + if (dist < closest_dist) { + closest = i; + closest_dist = dist; + } + } + if (closest < 0) { + SDL_SetError("Couldn't find any displays"); + } + return closest; +} + +SDL_VideoDisplay * +SDL_GetDisplayForWindow(SDL_Window *window) +{ + int displayIndex = SDL_GetWindowDisplay(window); + if (displayIndex >= 0) { + return &_this->displays[displayIndex]; + } else { + return NULL; + } +} + int SDL_SetWindowDisplayMode(SDL_Window * window, const SDL_DisplayMode * mode) { @@ -759,7 +988,7 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) fullscreen_mode.h = window->h; } - if (!SDL_GetClosestDisplayModeForDisplay(window->display, + if (!SDL_GetClosestDisplayModeForDisplay(SDL_GetDisplayForWindow(window), &fullscreen_mode, &fullscreen_mode)) { SDL_SetError("Couldn't find display mode match"); @@ -772,53 +1001,83 @@ SDL_GetWindowDisplayMode(SDL_Window * window, SDL_DisplayMode * mode) return 0; } -static void -SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt) +Uint32 +SDL_GetWindowPixelFormat(SDL_Window * window) { - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display; - /* See if we're already processing a window */ - if (display->updating_fullscreen) { + CHECK_WINDOW_MAGIC(window, SDL_PIXELFORMAT_UNKNOWN); + + display = SDL_GetDisplayForWindow(window); + return display->current_mode.format; +} + +static void +SDL_RestoreMousePosition(SDL_Window *window) +{ + int x, y; + + if (window == SDL_GetMouseFocus()) { + SDL_GetMouseState(&x, &y); + SDL_WarpMouseInWindow(window, x, y); + } +} + +static void +SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool fullscreen) +{ + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + SDL_Window *other; + + if (fullscreen) { + /* Hide any other fullscreen windows */ + if (display->fullscreen_window && + display->fullscreen_window != window) { + SDL_MinimizeWindow(display->fullscreen_window); + } + } + + /* See if anything needs to be done now */ + if ((display->fullscreen_window == window) == fullscreen) { return; } - display->updating_fullscreen = SDL_TRUE; - - /* See if we even want to do anything here */ - if ((window->flags & SDL_WINDOW_FULLSCREEN) && - (window->flags & SDL_WINDOW_SHOWN)) { - if (attempt) { - /* We just gained some state, try to gain all states */ - if (window->flags & SDL_WINDOW_MINIMIZED) { - SDL_RestoreWindow(window); - } else { - SDL_RaiseWindow(window); - } - } else { - /* We just lost some state, try to release all states */ - SDL_MinimizeWindow(window); - } - } - - if (FULLSCREEN_VISIBLE(window)) { - /* Hide any other fullscreen windows */ - SDL_Window *other; - for (other = display->windows; other; other = other->next) { - if (other != window && FULLSCREEN_VISIBLE(other)) { - SDL_MinimizeWindow(other); - } - } - } - - display->updating_fullscreen = SDL_FALSE; - /* See if there are any fullscreen windows */ - for (window = display->windows; window; window = window->next) { - if (FULLSCREEN_VISIBLE(window)) { + for (other = _this->windows; other; other = other->next) { + SDL_bool setDisplayMode = SDL_FALSE; + + if (other == window) { + setDisplayMode = fullscreen; + } else if (FULLSCREEN_VISIBLE(other) && + SDL_GetDisplayForWindow(other) == display) { + setDisplayMode = SDL_TRUE; + } + + if (setDisplayMode) { SDL_DisplayMode fullscreen_mode; - if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { + + if (SDL_GetWindowDisplayMode(other, &fullscreen_mode) == 0) { + SDL_bool resized = SDL_TRUE; + + if (other->w == fullscreen_mode.w && other->h == fullscreen_mode.h) { + resized = SDL_FALSE; + } + SDL_SetDisplayModeForDisplay(display, &fullscreen_mode); - display->fullscreen_window = window; + if (_this->SetWindowFullscreen) { + _this->SetWindowFullscreen(_this, other, display, SDL_TRUE); + } + display->fullscreen_window = other; + + /* Generate a mode change event here */ + if (resized) { + SDL_SendWindowEvent(other, SDL_WINDOWEVENT_RESIZED, + fullscreen_mode.w, fullscreen_mode.h); + } else { + SDL_OnWindowResized(other); + } + + SDL_RestoreMousePosition(other); return; } } @@ -826,86 +1085,63 @@ SDL_UpdateFullscreenMode(SDL_Window * window, SDL_bool attempt) /* Nope, restore the desktop mode */ SDL_SetDisplayModeForDisplay(display, NULL); + + if (_this->SetWindowFullscreen) { + _this->SetWindowFullscreen(_this, window, display, SDL_FALSE); + } display->fullscreen_window = NULL; + + /* Generate a mode change event here */ + SDL_OnWindowResized(window); + + /* Restore the cursor position */ + SDL_RestoreMousePosition(window); } -int -SDL_SetPaletteForDisplay(SDL_VideoDisplay * display, const SDL_Color * colors, int firstcolor, int ncolors) +#define CREATE_FLAGS \ + (SDL_WINDOW_OPENGL | SDL_WINDOW_BORDERLESS | SDL_WINDOW_RESIZABLE) + +static void +SDL_FinishWindowCreation(SDL_Window *window, Uint32 flags) { - SDL_Palette *palette; - int status = 0; + window->windowed.x = window->x; + window->windowed.y = window->y; + window->windowed.w = window->w; + window->windowed.h = window->h; - palette = display->palette; - if (!palette) { - SDL_SetError("Display mode does not have a palette"); - return -1; + if (flags & SDL_WINDOW_MAXIMIZED) { + SDL_MaximizeWindow(window); } - status = SDL_SetPaletteColors(palette, colors, firstcolor, ncolors); - - if (_this->SetDisplayPalette) { - if (_this->SetDisplayPalette(_this, display, palette) < 0) { - status = -1; - } + if (flags & SDL_WINDOW_MINIMIZED) { + SDL_MinimizeWindow(window); } - return status; -} - -int -SDL_SetDisplayPalette(const SDL_Color * colors, int firstcolor, int ncolors) -{ - if (!_this) { - SDL_UninitializedVideo(); - return -1; + if (flags & SDL_WINDOW_FULLSCREEN) { + SDL_SetWindowFullscreen(window, SDL_TRUE); } - return SDL_SetPaletteForDisplay(SDL_CurrentDisplay, colors, firstcolor, ncolors); -} - -int -SDL_GetPaletteForDisplay(SDL_VideoDisplay * display, SDL_Color * colors, int firstcolor, int ncolors) -{ - SDL_Palette *palette; - - palette = display->palette; - if (!palette || !palette->ncolors) { - SDL_SetError("Display mode does not have a palette"); - return -1; + if (flags & SDL_WINDOW_INPUT_GRABBED) { + SDL_SetWindowGrab(window, SDL_TRUE); } - if (firstcolor < 0 || (firstcolor + ncolors) > palette->ncolors) { - SDL_SetError("Palette indices are out of range"); - return -1; + if (!(flags & SDL_WINDOW_HIDDEN)) { + SDL_ShowWindow(window); } - SDL_memcpy(colors, &palette->colors[firstcolor], - ncolors * sizeof(*colors)); - return 0; -} - -int -SDL_GetDisplayPalette(SDL_Color * colors, int firstcolor, int ncolors) -{ - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - return SDL_GetPaletteForDisplay(SDL_CurrentDisplay, colors, firstcolor, ncolors); } SDL_Window * SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) { - const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN | - SDL_WINDOW_OPENGL | - SDL_WINDOW_BORDERLESS | - SDL_WINDOW_RESIZABLE | - SDL_WINDOW_INPUT_GRABBED); - SDL_VideoDisplay *display; SDL_Window *window; if (!_this) { /* Initialize the video system if needed */ - if (SDL_VideoInit(NULL, 0) < 0) { + if (SDL_VideoInit(NULL) < 0) { return NULL; } } + + /* Some platforms have OpenGL enabled by default */ +#if (SDL_VIDEO_OPENGL && __MACOSX__) || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 + flags |= SDL_WINDOW_OPENGL; +#endif if (flags & SDL_WINDOW_OPENGL) { if (!_this->GL_CreateContext) { SDL_SetError("No OpenGL support in video driver"); @@ -913,7 +1149,6 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) } SDL_GL_LoadLibrary(NULL); } - display = SDL_CurrentDisplay; window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); window->magic = &_this->window_magic; window->id = _this->next_object_id++; @@ -921,13 +1156,28 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) window->y = y; window->w = w; window->h = h; - window->flags = (flags & allowed_flags); - window->display = display; - window->next = display->windows; - if (display->windows) { - display->windows->prev = window; + if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISUNDEFINED(y) || + SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + int displayIndex; + SDL_Rect bounds; + + displayIndex = SDL_GetIndexOfDisplay(display); + SDL_GetDisplayBounds(displayIndex, &bounds); + if (SDL_WINDOWPOS_ISUNDEFINED(x) || SDL_WINDOWPOS_ISCENTERED(x)) { + window->x = bounds.x + (bounds.w - w) / 2; + } + if (SDL_WINDOWPOS_ISUNDEFINED(y) || SDL_WINDOWPOS_ISCENTERED(y)) { + window->y = bounds.y + (bounds.h - h) / 2; + } } - display->windows = window; + window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN); + window->brightness = 1.0f; + window->next = _this->windows; + if (_this->windows) { + _this->windows->prev = window; + } + _this->windows = window; if (_this->CreateWindow && _this->CreateWindow(_this, window) < 0) { SDL_DestroyWindow(window); @@ -937,16 +1187,10 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) if (title) { SDL_SetWindowTitle(window, title); } - if (flags & SDL_WINDOW_MAXIMIZED) { - SDL_MaximizeWindow(window); - } - if (flags & SDL_WINDOW_MINIMIZED) { - SDL_MinimizeWindow(window); - } - if (flags & SDL_WINDOW_SHOWN) { - SDL_ShowWindow(window); - } - SDL_UpdateWindowGrab(window); + SDL_FinishWindowCreation(window, flags); + + /* If the window was created fullscreen, make sure the mode code matches */ + SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)); return window; } @@ -954,24 +1198,22 @@ SDL_CreateWindow(const char *title, int x, int y, int w, int h, Uint32 flags) SDL_Window * SDL_CreateWindowFrom(const void *data) { - SDL_VideoDisplay *display; SDL_Window *window; if (!_this) { SDL_UninitializedVideo(); return NULL; } - display = SDL_CurrentDisplay; window = (SDL_Window *)SDL_calloc(1, sizeof(*window)); window->magic = &_this->window_magic; window->id = _this->next_object_id++; window->flags = SDL_WINDOW_FOREIGN; - window->display = display; - window->next = display->windows; - if (display->windows) { - display->windows->prev = window; + window->brightness = 1.0f; + window->next = _this->windows; + if (_this->windows) { + _this->windows->prev = window; } - display->windows = window; + _this->windows = window; if (!_this->CreateWindowFrom || _this->CreateWindowFrom(_this, window, data) < 0) { @@ -984,25 +1226,12 @@ SDL_CreateWindowFrom(const void *data) int SDL_RecreateWindow(SDL_Window * window, Uint32 flags) { - const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN | - SDL_WINDOW_OPENGL | - SDL_WINDOW_BORDERLESS | - SDL_WINDOW_RESIZABLE | - SDL_WINDOW_INPUT_GRABBED | - SDL_WINDOW_FOREIGN); char *title = window->title; if ((flags & SDL_WINDOW_OPENGL) && !_this->GL_CreateContext) { SDL_SetError("No OpenGL support in video driver"); return -1; } - if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) { - if (flags & SDL_WINDOW_OPENGL) { - SDL_GL_LoadLibrary(NULL); - } else { - SDL_GL_UnloadLibrary(); - } - } if (window->flags & SDL_WINDOW_FOREIGN) { /* Can't destroy and re-create foreign windows, hrm */ @@ -1011,12 +1240,31 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags) flags &= ~SDL_WINDOW_FOREIGN; } + /* Restore video mode, etc. */ + SDL_HideWindow(window); + + /* Tear down the old native window */ + if (window->surface) { + window->surface->flags &= ~SDL_DONTFREE; + SDL_FreeSurface(window->surface); + } + if (_this->DestroyWindowFramebuffer) { + _this->DestroyWindowFramebuffer(_this, window); + } if (_this->DestroyWindow && !(flags & SDL_WINDOW_FOREIGN)) { _this->DestroyWindow(_this, window); } + if ((window->flags & SDL_WINDOW_OPENGL) != (flags & SDL_WINDOW_OPENGL)) { + if (flags & SDL_WINDOW_OPENGL) { + SDL_GL_LoadLibrary(NULL); + } else { + SDL_GL_UnloadLibrary(); + } + } + window->title = NULL; - window->flags = (flags & allowed_flags); + window->flags = ((flags & CREATE_FLAGS) | SDL_WINDOW_HIDDEN); if (_this->CreateWindow && !(flags & SDL_WINDOW_FOREIGN)) { if (_this->CreateWindow(_this, window) < 0) { @@ -1031,47 +1279,11 @@ SDL_RecreateWindow(SDL_Window * window, Uint32 flags) SDL_SetWindowTitle(window, title); SDL_free(title); } - if (flags & SDL_WINDOW_MAXIMIZED) { - SDL_MaximizeWindow(window); - } - if (flags & SDL_WINDOW_MINIMIZED) { - SDL_MinimizeWindow(window); - } - if (flags & SDL_WINDOW_SHOWN) { - SDL_ShowWindow(window); - } - SDL_UpdateWindowGrab(window); + SDL_FinishWindowCreation(window, flags); return 0; } -static __inline__ SDL_Renderer * -SDL_GetCurrentRenderer(SDL_bool create) -{ - if (!_this) { - SDL_UninitializedVideo(); - return NULL; - } - if (!SDL_CurrentRenderer) { - SDL_Window *window = NULL; - - if (!create) { - SDL_SetError("Use SDL_CreateRenderer() to create a renderer"); - return NULL; - } - - /* Get the first window on the first display */ - if (_this->num_displays > 0) { - window = _this->displays[0].windows; - } - - if (SDL_CreateRenderer(window, -1, 0) < 0) { - return NULL; - } - } - return SDL_CurrentRenderer; -} - Uint32 SDL_GetWindowID(SDL_Window * window) { @@ -1084,18 +1296,13 @@ SDL_Window * SDL_GetWindowFromID(Uint32 id) { SDL_Window *window; - int i; if (!_this) { return NULL; } - /* FIXME: Should we keep a separate hash table for these? */ - for (i = _this->num_displays; i--;) { - SDL_VideoDisplay *display = &_this->displays[i]; - for (window = display->windows; window; window = window->next) { - if (window->id == id) { - return window; - } + for (window = _this->windows; window; window = window->next) { + if (window->id == id) { + return window; } } return NULL; @@ -1144,25 +1351,69 @@ SDL_SetWindowIcon(SDL_Window * window, SDL_Surface * icon) { CHECK_WINDOW_MAGIC(window, ); + if (!icon) { + return; + } + if (_this->SetWindowIcon) { _this->SetWindowIcon(_this, window, icon); } } -void -SDL_SetWindowData(SDL_Window * window, void *userdata) +void* +SDL_SetWindowData(SDL_Window * window, const char *name, void *userdata) { - CHECK_WINDOW_MAGIC(window, ); + SDL_WindowUserData *prev, *data; - window->userdata = userdata; + CHECK_WINDOW_MAGIC(window, NULL); + + /* See if the named data already exists */ + prev = NULL; + for (data = window->data; data; prev = data, data = data->next) { + if (SDL_strcmp(data->name, name) == 0) { + void *last_value = data->data; + + if (userdata) { + /* Set the new value */ + data->data = userdata; + } else { + /* Delete this value */ + if (prev) { + prev->next = data->next; + } else { + window->data = data->next; + } + SDL_free(data->name); + SDL_free(data); + } + return last_value; + } + } + + /* Add new data to the window */ + if (userdata) { + data = (SDL_WindowUserData *)SDL_malloc(sizeof(*data)); + data->name = SDL_strdup(name); + data->data = userdata; + data->next = window->data; + window->data = data; + } + return NULL; } void * -SDL_GetWindowData(SDL_Window * window) +SDL_GetWindowData(SDL_Window * window, const char *name) { + SDL_WindowUserData *data; + CHECK_WINDOW_MAGIC(window, NULL); - return window->userdata; + for (data = window->data; data; data = data->next) { + if (SDL_strcmp(data->name, name) == 0) { + return data->data; + } + } + return NULL; } void @@ -1170,28 +1421,56 @@ SDL_SetWindowPosition(SDL_Window * window, int x, int y) { CHECK_WINDOW_MAGIC(window, ); - if (x != SDL_WINDOWPOS_UNDEFINED) { + if (!SDL_WINDOWPOS_ISUNDEFINED(x)) { window->x = x; } - if (y != SDL_WINDOWPOS_UNDEFINED) { + if (!SDL_WINDOWPOS_ISUNDEFINED(y)) { window->y = y; } - if (_this->SetWindowPosition) { - _this->SetWindowPosition(_this, window); + if (SDL_WINDOWPOS_ISCENTERED(x) || SDL_WINDOWPOS_ISCENTERED(y)) { + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + int displayIndex; + SDL_Rect bounds; + + displayIndex = SDL_GetIndexOfDisplay(display); + SDL_GetDisplayBounds(displayIndex, &bounds); + if (SDL_WINDOWPOS_ISCENTERED(x)) { + window->x = bounds.x + (bounds.w - window->w) / 2; + } + if (SDL_WINDOWPOS_ISCENTERED(y)) { + window->y = bounds.y + (bounds.h - window->h) / 2; + } + } + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + if (_this->SetWindowPosition) { + _this->SetWindowPosition(_this, window); + } + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y); } - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y); } void SDL_GetWindowPosition(SDL_Window * window, int *x, int *y) { - CHECK_WINDOW_MAGIC(window, ); - + /* Clear the values */ if (x) { - *x = window->x; + *x = 0; } if (y) { - *y = window->y; + *y = 0; + } + + CHECK_WINDOW_MAGIC(window, ); + + /* Fullscreen windows are always at their display's origin */ + if (window->flags & SDL_WINDOW_FULLSCREEN) { + } else { + if (x) { + *x = window->x; + } + if (y) { + *y = window->y; + } } } @@ -1200,19 +1479,38 @@ SDL_SetWindowSize(SDL_Window * window, int w, int h) { CHECK_WINDOW_MAGIC(window, ); - window->w = w; - window->h = h; - - if (_this->SetWindowSize) { - _this->SetWindowSize(_this, window); + /* FIXME: Should this change fullscreen modes? */ + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { + window->w = w; + window->h = h; + if (_this->SetWindowSize) { + _this->SetWindowSize(_this, window); + } + if (window->w == w && window->h == h) { + /* We didn't get a SDL_WINDOWEVENT_RESIZED event (by design) */ + SDL_OnWindowResized(window); + } } - SDL_OnWindowResized(window); } void SDL_GetWindowSize(SDL_Window * window, int *w, int *h) { - if (window) { + int dummy; + + if (!w) { + w = &dummy; + } + if (!h) { + h = &dummy; + } + + *w = 0; + *h = 0; + + CHECK_WINDOW_MAGIC(window, ); + + if (_this && window && window->magic == &_this->window_magic) { if (w) { *w = window->w; } @@ -1253,6 +1551,8 @@ SDL_HideWindow(SDL_Window * window) return; } + SDL_UpdateFullscreenMode(window, SDL_FALSE); + if (_this->HideWindow) { _this->HideWindow(_this, window); } @@ -1269,9 +1569,6 @@ SDL_RaiseWindow(SDL_Window * window) } if (_this->RaiseWindow) { _this->RaiseWindow(_this, window); - } else { - /* FIXME: What we really want is a way to request focus */ - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); } } @@ -1287,7 +1584,6 @@ SDL_MaximizeWindow(SDL_Window * window) if (_this->MaximizeWindow) { _this->MaximizeWindow(_this, window); } - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MAXIMIZED, 0, 0); } void @@ -1299,10 +1595,11 @@ SDL_MinimizeWindow(SDL_Window * window) return; } + SDL_UpdateFullscreenMode(window, SDL_FALSE); + if (_this->MinimizeWindow) { _this->MinimizeWindow(_this, window); } - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } void @@ -1317,46 +1614,206 @@ SDL_RestoreWindow(SDL_Window * window) if (_this->RestoreWindow) { _this->RestoreWindow(_this, window); } - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); } int -SDL_SetWindowFullscreen(SDL_Window * window, int fullscreen) +SDL_SetWindowFullscreen(SDL_Window * window, SDL_bool fullscreen) { CHECK_WINDOW_MAGIC(window, -1); - if (fullscreen) { - fullscreen = SDL_WINDOW_FULLSCREEN; - } - if ((window->flags & SDL_WINDOW_FULLSCREEN) == fullscreen) { + if (!!fullscreen == !!(window->flags & SDL_WINDOW_FULLSCREEN)) { return 0; } if (fullscreen) { window->flags |= SDL_WINDOW_FULLSCREEN; - - SDL_UpdateFullscreenMode(window, SDL_TRUE); } else { window->flags &= ~SDL_WINDOW_FULLSCREEN; - - SDL_UpdateFullscreenMode(window, SDL_FALSE); } + SDL_UpdateFullscreenMode(window, FULLSCREEN_VISIBLE(window)); + return 0; } -void -SDL_SetWindowGrab(SDL_Window * window, int mode) +static SDL_Surface * +SDL_CreateWindowFramebuffer(SDL_Window * window) { - CHECK_WINDOW_MAGIC(window, ); + Uint32 format; + void *pixels; + int pitch; + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; - if ((!!mode == !!(window->flags & SDL_WINDOW_INPUT_GRABBED))) { - return; + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_CreateWindowFramebuffer(): _this->CreateWindowFramebuffer %p _this->UpdateWindowFramebuffer %p", + _this->CreateWindowFramebuffer, _this->UpdateWindowFramebuffer); + if (!_this->CreateWindowFramebuffer || !_this->UpdateWindowFramebuffer) { + return NULL; } - if (mode) { - window->flags |= SDL_WINDOW_INPUT_GRABBED; + + if (_this->CreateWindowFramebuffer(_this, window, &format, &pixels, &pitch) < 0) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_CreateWindowFramebuffer(): _this->CreateWindowFramebuffer() failed"); + return NULL; + } + + if (!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_CreateWindowFramebuffer(): SDL_PixelFormatEnumToMasks() failed"); + return NULL; + } + + return SDL_CreateRGBSurfaceFrom(pixels, window->w, window->h, bpp, pitch, Rmask, Gmask, Bmask, Amask); +} + +SDL_Surface * +SDL_GetWindowSurface(SDL_Window * window) +{ + CHECK_WINDOW_MAGIC(window, NULL); + + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_GetWindowSurface(): window->surface_valid %d", window->surface_valid); + if (!window->surface_valid) { + if (window->surface) { + window->surface->flags &= ~SDL_DONTFREE; + SDL_FreeSurface(window->surface); + } + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_GetWindowSurface(): SDL_CreateWindowFramebuffer()"); + window->surface = SDL_CreateWindowFramebuffer(window); + if (window->surface) { + window->surface_valid = SDL_TRUE; + window->surface->flags |= SDL_DONTFREE; + } + } + __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_GetWindowSurface(): window->surface %p", window->surface); + return window->surface; +} + +int +SDL_UpdateWindowSurface(SDL_Window * window) +{ + SDL_Rect full_rect; + + CHECK_WINDOW_MAGIC(window, -1); + + full_rect.x = 0; + full_rect.y = 0; + full_rect.w = window->w; + full_rect.h = window->h; + return SDL_UpdateWindowSurfaceRects(window, &full_rect, 1); +} + +int +SDL_UpdateWindowSurfaceRects(SDL_Window * window, SDL_Rect * rects, + int numrects) +{ + CHECK_WINDOW_MAGIC(window, -1); + + if (!window->surface_valid) { + SDL_SetError("Window surface is invalid, please call SDL_GetWindowSurface() to get a new surface"); + return -1; + } + + return _this->UpdateWindowFramebuffer(_this, window, rects, numrects); +} + +int +SDL_SetWindowBrightness(SDL_Window * window, float brightness) +{ + Uint16 ramp[256]; + int status; + + CHECK_WINDOW_MAGIC(window, -1); + + SDL_CalculateGammaRamp(brightness, ramp); + status = SDL_SetWindowGammaRamp(window, ramp, ramp, ramp); + if (status == 0) { + window->brightness = brightness; + } + return status; +} + +float +SDL_GetWindowBrightness(SDL_Window * window) +{ + CHECK_WINDOW_MAGIC(window, 1.0f); + + return window->brightness; +} + +int +SDL_SetWindowGammaRamp(SDL_Window * window, const Uint16 * red, + const Uint16 * green, + const Uint16 * blue) +{ + CHECK_WINDOW_MAGIC(window, -1); + + if (!_this->SetWindowGammaRamp) { + SDL_Unsupported(); + return -1; + } + + if (!window->gamma) { + if (SDL_GetWindowGammaRamp(window, NULL, NULL, NULL) < 0) { + return -1; + } + } + + if (red) { + SDL_memcpy(&window->gamma[0*256], red, 256*sizeof(Uint16)); + } + if (green) { + SDL_memcpy(&window->gamma[1*256], green, 256*sizeof(Uint16)); + } + if (blue) { + SDL_memcpy(&window->gamma[2*256], blue, 256*sizeof(Uint16)); + } + if (window->flags & SDL_WINDOW_INPUT_FOCUS) { + return _this->SetWindowGammaRamp(_this, window, window->gamma); } else { - window->flags &= ~SDL_WINDOW_INPUT_GRABBED; + return 0; } - SDL_UpdateWindowGrab(window); +} + +int +SDL_GetWindowGammaRamp(SDL_Window * window, Uint16 * red, + Uint16 * green, + Uint16 * blue) +{ + CHECK_WINDOW_MAGIC(window, -1); + + if (!window->gamma) { + int i; + + window->gamma = (Uint16 *)SDL_malloc(256*6*sizeof(Uint16)); + if (!window->gamma) { + SDL_OutOfMemory(); + return -1; + } + window->saved_gamma = window->gamma + 3*256; + + if (_this->GetWindowGammaRamp) { + if (_this->GetWindowGammaRamp(_this, window, window->gamma) < 0) { + return -1; + } + } else { + /* Create an identity gamma ramp */ + for (i = 0; i < 256; ++i) { + Uint16 value = (Uint16)((i << 8) | i); + + window->gamma[0*256+i] = value; + window->gamma[1*256+i] = value; + window->gamma[2*256+i] = value; + } + } + SDL_memcpy(window->saved_gamma, window->gamma, 3*256*sizeof(Uint16)); + } + + if (red) { + SDL_memcpy(red, &window->gamma[0*256], 256*sizeof(Uint16)); + } + if (green) { + SDL_memcpy(green, &window->gamma[1*256], 256*sizeof(Uint16)); + } + if (blue) { + SDL_memcpy(blue, &window->gamma[2*256], 256*sizeof(Uint16)); + } + return 0; } static void @@ -1367,10 +1824,26 @@ SDL_UpdateWindowGrab(SDL_Window * window) } } -int +void +SDL_SetWindowGrab(SDL_Window * window, SDL_bool grabbed) +{ + CHECK_WINDOW_MAGIC(window, ); + + if (!!grabbed == !!(window->flags & SDL_WINDOW_INPUT_GRABBED)) { + return; + } + if (grabbed) { + window->flags |= SDL_WINDOW_INPUT_GRABBED; + } else { + window->flags &= ~SDL_WINDOW_INPUT_GRABBED; + } + SDL_UpdateWindowGrab(window); +} + +SDL_bool SDL_GetWindowGrab(SDL_Window * window) { - CHECK_WINDOW_MAGIC(window, 0); + CHECK_WINDOW_MAGIC(window, SDL_FALSE); return ((window->flags & SDL_WINDOW_INPUT_GRABBED) != 0); } @@ -1378,8 +1851,7 @@ SDL_GetWindowGrab(SDL_Window * window) void SDL_OnWindowShown(SDL_Window * window) { - SDL_RaiseWindow(window); - SDL_UpdateFullscreenMode(window, SDL_TRUE); + SDL_OnWindowRestored(window); } void @@ -1391,11 +1863,8 @@ SDL_OnWindowHidden(SDL_Window * window) void SDL_OnWindowResized(SDL_Window * window) { - SDL_Renderer *renderer = window->renderer; - - if (renderer && renderer->DisplayModeChanged) { - renderer->DisplayModeChanged(renderer); - } + window->surface_valid = SDL_FALSE; + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_SIZE_CHANGED, window->w, window->h); } void @@ -1408,19 +1877,21 @@ void SDL_OnWindowRestored(SDL_Window * window) { SDL_RaiseWindow(window); - SDL_UpdateFullscreenMode(window, SDL_TRUE); + + if (FULLSCREEN_VISIBLE(window)) { + SDL_UpdateFullscreenMode(window, SDL_TRUE); + } } void SDL_OnWindowFocusGained(SDL_Window * window) { - SDL_VideoDisplay *display = window->display; - - if (display->gamma && _this->SetDisplayGammaRamp) { - _this->SetDisplayGammaRamp(_this, display, display->gamma); + if (window->gamma && _this->SetWindowGammaRamp) { + _this->SetWindowGammaRamp(_this, window, window->gamma); } - if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) - && _this->SetWindowGrab) { + + if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) && + _this->SetWindowGrab) { _this->SetWindowGrab(_this, window); } } @@ -1428,34 +1899,30 @@ SDL_OnWindowFocusGained(SDL_Window * window) void SDL_OnWindowFocusLost(SDL_Window * window) { - SDL_VideoDisplay *display = window->display; + if (window->gamma && _this->SetWindowGammaRamp) { + _this->SetWindowGammaRamp(_this, window, window->saved_gamma); + } + + if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) && + _this->SetWindowGrab) { + _this->SetWindowGrab(_this, window); + } /* If we're fullscreen on a single-head system and lose focus, minimize */ - if ((window->flags & SDL_WINDOW_FULLSCREEN) && - _this->num_displays == 1) { + if ((window->flags & SDL_WINDOW_FULLSCREEN) && _this->num_displays == 1) { SDL_MinimizeWindow(window); } - - if (display->gamma && _this->SetDisplayGammaRamp) { - _this->SetDisplayGammaRamp(_this, display, display->saved_gamma); - } - if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) - && _this->SetWindowGrab) { - _this->SetWindowGrab(_this, window); - } } SDL_Window * SDL_GetFocusWindow(void) { - SDL_VideoDisplay *display; SDL_Window *window; if (!_this) { return NULL; } - display = SDL_CurrentDisplay; - for (window = display->windows; window; window = window->next) { + for (window = _this->windows; window; window = window->next) { if (window->flags & SDL_WINDOW_INPUT_FOCUS) { return window; } @@ -1470,16 +1937,23 @@ SDL_DestroyWindow(SDL_Window * window) CHECK_WINDOW_MAGIC(window, ); - if (window->title) { - SDL_free(window->title); - } - if (window->renderer) { - SDL_DestroyRenderer(window); + /* make no context current if this is the current context window. */ + if (window->flags & SDL_WINDOW_OPENGL) { + if (_this->current_glwin == window) { + SDL_GL_MakeCurrent(NULL, NULL); + } } /* Restore video mode, etc. */ - SDL_UpdateFullscreenMode(window, SDL_FALSE); + SDL_HideWindow(window); + if (window->surface) { + window->surface->flags &= ~SDL_DONTFREE; + SDL_FreeSurface(window->surface); + } + if (_this->DestroyWindowFramebuffer) { + _this->DestroyWindowFramebuffer(_this, window); + } if (_this->DestroyWindow) { _this->DestroyWindow(_this, window); } @@ -1487,1464 +1961,42 @@ SDL_DestroyWindow(SDL_Window * window) SDL_GL_UnloadLibrary(); } + display = SDL_GetDisplayForWindow(window); + if (display->fullscreen_window == window) { + display->fullscreen_window = NULL; + } + /* Now invalidate magic */ window->magic = NULL; + /* Free memory associated with the window */ + if (window->title) { + SDL_free(window->title); + } + if (window->gamma) { + SDL_free(window->gamma); + } + while (window->data) { + SDL_WindowUserData *data = window->data; + + window->data = data->next; + SDL_free(data->name); + SDL_free(data); + } + /* Unlink the window from the list */ - display = window->display; if (window->next) { window->next->prev = window->prev; } if (window->prev) { window->prev->next = window->next; } else { - display->windows = window->next; + _this->windows = window->next; } SDL_free(window); } -void -SDL_AddRenderDriver(SDL_VideoDisplay * display, const SDL_RenderDriver * driver) -{ - SDL_RenderDriver *render_drivers; - - render_drivers = - SDL_realloc(display->render_drivers, - (display->num_render_drivers + - 1) * sizeof(*render_drivers)); - if (render_drivers) { - render_drivers[display->num_render_drivers] = *driver; - display->render_drivers = render_drivers; - display->num_render_drivers++; - } -} - -int -SDL_GetNumRenderDrivers(void) -{ - if (_this) { - return SDL_CurrentDisplay->num_render_drivers; - } - return 0; -} - -int -SDL_GetRenderDriverInfo(int index, SDL_RendererInfo * info) -{ - if (!_this) { - SDL_UninitializedVideo(); - return -1; - } - if (index < 0 || index >= SDL_GetNumRenderDrivers()) { - SDL_SetError("index must be in the range of 0 - %d", - SDL_GetNumRenderDrivers() - 1); - return -1; - } - *info = SDL_CurrentDisplay->render_drivers[index].info; - return 0; -} - -int -SDL_CreateRenderer(SDL_Window * window, int index, Uint32 flags) -{ - CHECK_WINDOW_MAGIC(window, -1); - - /* Free any existing renderer */ - SDL_DestroyRenderer(window); - - if (index < 0) { - char *override = SDL_getenv("SDL_VIDEO_RENDERER"); - int n = SDL_GetNumRenderDrivers(); - -#if SDL_VIDEO_RENDER_OGL - if (!override && (window->flags & SDL_WINDOW_OPENGL)) { - override = "opengl"; - } -#endif /* SDL_VIDEO_RENDER_OGL */ -#if SDL_VIDEO_RENDER_OGL_ES - if (!override && (window->flags & SDL_WINDOW_OPENGL)) { - override = "opengl_es"; - } -#endif /* SDL_VIDEO_RENDER_OGL_ES */ - if (override) { - for (index = 0; index < n; ++index) { - SDL_RenderDriver *driver = - &SDL_CurrentDisplay->render_drivers[index]; - - if (SDL_strcasecmp(override, driver->info.name) == 0) { - /* Create a new renderer instance */ - window->renderer = driver->CreateRenderer(window, flags); - break; - } - } - } else { - for (index = 0; index < n; ++index) { - SDL_RenderDriver *driver = - &SDL_CurrentDisplay->render_drivers[index]; - - if ((driver->info.flags & flags) == flags) { - /* Create a new renderer instance */ - window->renderer = driver->CreateRenderer(window, flags); - if (window->renderer) { - /* Yay, we got one! */ - break; - } - } - } - } - if (index == n) { - SDL_SetError("Couldn't find matching render driver"); - return -1; - } - } else { - if (index >= SDL_GetNumRenderDrivers()) { - SDL_SetError("index must be -1 or in the range of 0 - %d", - SDL_GetNumRenderDrivers() - 1); - return -1; - } - /* Create a new renderer instance */ - window->renderer = SDL_CurrentDisplay->render_drivers[index].CreateRenderer(window, flags); - } - - if (window->renderer == NULL) { - /* Assuming renderer set its error */ - return -1; - } - - SDL_SelectRenderer(window); - - return 0; -} - -int -SDL_SelectRenderer(SDL_Window * window) -{ - SDL_Renderer *renderer; - - CHECK_WINDOW_MAGIC(window, -1); - - renderer = window->renderer; - if (!renderer) { - SDL_SetError("Use SDL_CreateRenderer() to create a renderer"); - return -1; - } - if (renderer->ActivateRenderer) { - if (renderer->ActivateRenderer(renderer) < 0) { - return -1; - } - } - SDL_CurrentDisplay->current_renderer = renderer; - return 0; -} - -int -SDL_GetRendererInfo(SDL_RendererInfo * info) -{ - SDL_Renderer *renderer = SDL_GetCurrentRenderer(SDL_FALSE); - if (!renderer) { - return -1; - } - *info = renderer->info; - return 0; -} - -SDL_Texture * -SDL_CreateTexture(Uint32 format, int access, int w, int h) -{ - SDL_Renderer *renderer; - SDL_Texture *texture; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return 0; - } - if (!renderer->CreateTexture) { - SDL_Unsupported(); - return 0; - } - if (w <= 0 || h <= 0) { - SDL_SetError("Texture dimensions can't be 0"); - return 0; - } - texture = (SDL_Texture *) SDL_calloc(1, sizeof(*texture)); - if (!texture) { - SDL_OutOfMemory(); - return 0; - } - texture->magic = &_this->texture_magic; - texture->format = format; - texture->access = access; - texture->w = w; - texture->h = h; - texture->r = 255; - texture->g = 255; - texture->b = 255; - texture->a = 255; - texture->renderer = renderer; - texture->next = renderer->textures; - if (renderer->textures) { - renderer->textures->prev = texture; - } - renderer->textures = texture; - - if (renderer->CreateTexture(renderer, texture) < 0) { - SDL_DestroyTexture(texture); - return 0; - } - return texture; -} - -SDL_Texture * -SDL_CreateTextureFromSurface(Uint32 format, SDL_Surface * surface) -{ - SDL_Texture *texture; - Uint32 requested_format = format; - SDL_PixelFormat *fmt; - SDL_Renderer *renderer; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (!surface) { - SDL_SetError("SDL_CreateTextureFromSurface() passed NULL surface"); - return 0; - } - fmt = surface->format; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return 0; - } - - if (format) { - if (!SDL_PixelFormatEnumToMasks - (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown pixel format"); - return 0; - } - } else { - if (surface->format->Amask - || !(surface->map->info.flags & - (SDL_COPY_COLORKEY | SDL_COPY_MASK | SDL_COPY_BLEND))) { - Uint32 it; - int pfmt; - - /* Pixel formats, sorted by best first */ - static const Uint32 sdl_pformats[] = { - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGBA8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_BGR888, - SDL_PIXELFORMAT_RGB24, - SDL_PIXELFORMAT_BGR24, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_BGR565, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGBA5551, - SDL_PIXELFORMAT_ABGR1555, - SDL_PIXELFORMAT_BGRA5551, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_BGR555, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_RGBA4444, - SDL_PIXELFORMAT_ABGR4444, - SDL_PIXELFORMAT_BGRA4444, - SDL_PIXELFORMAT_RGB444, - SDL_PIXELFORMAT_ARGB2101010, - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_INDEX4LSB, - SDL_PIXELFORMAT_INDEX4MSB, - SDL_PIXELFORMAT_RGB332, - SDL_PIXELFORMAT_INDEX1LSB, - SDL_PIXELFORMAT_INDEX1MSB, - SDL_PIXELFORMAT_UNKNOWN - }; - - bpp = fmt->BitsPerPixel; - Rmask = fmt->Rmask; - Gmask = fmt->Gmask; - Bmask = fmt->Bmask; - Amask = fmt->Amask; - - format = - SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); - if (!format) { - SDL_SetError("Unknown pixel format"); - return 0; - } - - /* Search requested format in the supported texture */ - /* formats by current renderer */ - for (it = 0; it < renderer->info.num_texture_formats; it++) { - if (renderer->info.texture_formats[it] == format) { - break; - } - } - - /* If requested format can't be found, search any best */ - /* format which renderer provides */ - if (it == renderer->info.num_texture_formats) { - pfmt = 0; - for (;;) { - if (sdl_pformats[pfmt] == SDL_PIXELFORMAT_UNKNOWN) { - break; - } - - for (it = 0; it < renderer->info.num_texture_formats; - it++) { - if (renderer->info.texture_formats[it] == - sdl_pformats[pfmt]) { - break; - } - } - - if (it != renderer->info.num_texture_formats) { - /* The best format has been found */ - break; - } - pfmt++; - } - - /* If any format can't be found, then return an error */ - if (it == renderer->info.num_texture_formats) { - SDL_SetError - ("Any of the supported pixel formats can't be found"); - return 0; - } - - /* Convert found pixel format back to color masks */ - if (SDL_PixelFormatEnumToMasks - (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask, - &Bmask, &Amask) != SDL_TRUE) { - SDL_SetError("Unknown pixel format"); - return 0; - } - } - } else { - /* Need a format with alpha */ - Uint32 it; - int apfmt; - - /* Pixel formats with alpha, sorted by best first */ - static const Uint32 sdl_alpha_pformats[] = { - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGBA8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGBA5551, - SDL_PIXELFORMAT_ABGR1555, - SDL_PIXELFORMAT_BGRA5551, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_RGBA4444, - SDL_PIXELFORMAT_ABGR4444, - SDL_PIXELFORMAT_BGRA4444, - SDL_PIXELFORMAT_ARGB2101010, - SDL_PIXELFORMAT_UNKNOWN - }; - - if (surface->format->Amask) { - /* If surface already has alpha, then try an original */ - /* surface format first */ - bpp = fmt->BitsPerPixel; - Rmask = fmt->Rmask; - Gmask = fmt->Gmask; - Bmask = fmt->Bmask; - Amask = fmt->Amask; - } else { - bpp = 32; - Rmask = 0x00FF0000; - Gmask = 0x0000FF00; - Bmask = 0x000000FF; - Amask = 0xFF000000; - } - - format = - SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); - if (!format) { - SDL_SetError("Unknown pixel format"); - return 0; - } - - /* Search this format in the supported texture formats */ - /* by current renderer */ - for (it = 0; it < renderer->info.num_texture_formats; it++) { - if (renderer->info.texture_formats[it] == format) { - break; - } - } - - /* If this format can't be found, search any best */ - /* compatible format with alpha which renderer provides */ - if (it == renderer->info.num_texture_formats) { - apfmt = 0; - for (;;) { - if (sdl_alpha_pformats[apfmt] == SDL_PIXELFORMAT_UNKNOWN) { - break; - } - - for (it = 0; it < renderer->info.num_texture_formats; - it++) { - if (renderer->info.texture_formats[it] == - sdl_alpha_pformats[apfmt]) { - break; - } - } - - if (it != renderer->info.num_texture_formats) { - /* Compatible format has been found */ - break; - } - apfmt++; - } - - /* If compatible format can't be found, then return an error */ - if (it == renderer->info.num_texture_formats) { - SDL_SetError("Compatible pixel format can't be found"); - return 0; - } - - /* Convert found pixel format back to color masks */ - if (SDL_PixelFormatEnumToMasks - (renderer->info.texture_formats[it], &bpp, &Rmask, &Gmask, - &Bmask, &Amask) != SDL_TRUE) { - SDL_SetError("Unknown pixel format"); - return 0; - } - } - } - - format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); - if (!format) { - SDL_SetError("Unknown pixel format"); - return 0; - } - } - - texture = - SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w, - surface->h); - if (!texture && !requested_format) { - SDL_DisplayMode desktop_mode; - SDL_GetDesktopDisplayMode(&desktop_mode); - format = desktop_mode.format; - texture = - SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, surface->w, - surface->h); - } - if (!texture) { - return 0; - } - if (bpp == fmt->BitsPerPixel && Rmask == fmt->Rmask && Gmask == fmt->Gmask - && Bmask == fmt->Bmask && Amask == fmt->Amask) { - if (SDL_MUSTLOCK(surface)) { - SDL_LockSurface(surface); - SDL_UpdateTexture(texture, NULL, surface->pixels, - surface->pitch); - SDL_UnlockSurface(surface); - } else { - SDL_UpdateTexture(texture, NULL, surface->pixels, - surface->pitch); - } - } else { - SDL_PixelFormat dst_fmt; - SDL_Surface *dst = NULL; - - /* Set up a destination surface for the texture update */ - SDL_InitFormat(&dst_fmt, bpp, Rmask, Gmask, Bmask, Amask); - if (SDL_ISPIXELFORMAT_INDEXED(format)) { - dst_fmt.palette = - SDL_AllocPalette((1 << SDL_BITSPERPIXEL(format))); - if (dst_fmt.palette) { - /* - * FIXME: Should we try to copy - * fmt->palette? - */ - SDL_DitherColors(dst_fmt.palette->colors, - SDL_BITSPERPIXEL(format)); - } - } - dst = SDL_ConvertSurface(surface, &dst_fmt, 0); - if (dst) { - SDL_UpdateTexture(texture, NULL, dst->pixels, dst->pitch); - SDL_FreeSurface(dst); - } - if (dst_fmt.palette) { - SDL_FreePalette(dst_fmt.palette); - } - if (!dst) { - SDL_DestroyTexture(texture); - return 0; - } - } - - { - Uint8 r, g, b, a; - SDL_BlendMode blendMode; - SDL_ScaleMode scaleMode; - - SDL_GetSurfaceColorMod(surface, &r, &g, &b); - SDL_SetTextureColorMod(texture, r, g, b); - - SDL_GetSurfaceAlphaMod(surface, &a); - SDL_SetTextureAlphaMod(texture, a); - - if (surface->map->info.flags & SDL_COPY_COLORKEY) { - /* We converted to a texture with alpha format */ - SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND); - } else { - SDL_GetSurfaceBlendMode(surface, &blendMode); - SDL_SetTextureBlendMode(texture, blendMode); - } - - SDL_GetSurfaceScaleMode(surface, &scaleMode); - SDL_SetTextureScaleMode(texture, scaleMode); - } - - if (SDL_ISPIXELFORMAT_INDEXED(format) && fmt->palette) { - SDL_SetTexturePalette(texture, fmt->palette->colors, 0, - fmt->palette->ncolors); - } - return texture; -} - -int -SDL_QueryTexture(SDL_Texture * texture, Uint32 * format, int *access, - int *w, int *h) -{ - CHECK_TEXTURE_MAGIC(texture, -1); - - if (format) { - *format = texture->format; - } - if (access) { - *access = texture->access; - } - if (w) { - *w = texture->w; - } - if (h) { - *h = texture->h; - } - return 0; -} - -int -SDL_QueryTexturePixels(SDL_Texture * texture, void **pixels, int *pitch) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (!renderer->QueryTexturePixels) { - SDL_Unsupported(); - return -1; - } - return renderer->QueryTexturePixels(renderer, texture, pixels, pitch); -} - -int -SDL_SetTexturePalette(SDL_Texture * texture, const SDL_Color * colors, - int firstcolor, int ncolors) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (!renderer->SetTexturePalette) { - SDL_Unsupported(); - return -1; - } - return renderer->SetTexturePalette(renderer, texture, colors, firstcolor, - ncolors); -} - -int -SDL_GetTexturePalette(SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (!renderer->GetTexturePalette) { - SDL_Unsupported(); - return -1; - } - return renderer->GetTexturePalette(renderer, texture, colors, firstcolor, - ncolors); -} - -int -SDL_SetTextureColorMod(SDL_Texture * texture, Uint8 r, Uint8 g, Uint8 b) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (!renderer->SetTextureColorMod) { - SDL_Unsupported(); - return -1; - } - if (r < 255 || g < 255 || b < 255) { - texture->modMode |= SDL_TEXTUREMODULATE_COLOR; - } else { - texture->modMode &= ~SDL_TEXTUREMODULATE_COLOR; - } - texture->r = r; - texture->g = g; - texture->b = b; - return renderer->SetTextureColorMod(renderer, texture); -} - -int -SDL_GetTextureColorMod(SDL_Texture * texture, Uint8 * r, Uint8 * g, - Uint8 * b) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (r) { - *r = texture->r; - } - if (g) { - *g = texture->g; - } - if (b) { - *b = texture->b; - } - return 0; -} - -int -SDL_SetTextureAlphaMod(SDL_Texture * texture, Uint8 alpha) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (!renderer->SetTextureAlphaMod) { - SDL_Unsupported(); - return -1; - } - if (alpha < 255) { - texture->modMode |= SDL_TEXTUREMODULATE_ALPHA; - } else { - texture->modMode &= ~SDL_TEXTUREMODULATE_ALPHA; - } - texture->a = alpha; - return renderer->SetTextureAlphaMod(renderer, texture); -} - -int -SDL_GetTextureAlphaMod(SDL_Texture * texture, Uint8 * alpha) -{ - CHECK_TEXTURE_MAGIC(texture, -1); - - if (alpha) { - *alpha = texture->a; - } - return 0; -} - -int -SDL_SetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode blendMode) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (!renderer->SetTextureBlendMode) { - SDL_Unsupported(); - return -1; - } - texture->blendMode = blendMode; - return renderer->SetTextureBlendMode(renderer, texture); -} - -int -SDL_GetTextureBlendMode(SDL_Texture * texture, SDL_BlendMode *blendMode) -{ - CHECK_TEXTURE_MAGIC(texture, -1); - - if (blendMode) { - *blendMode = texture->blendMode; - } - return 0; -} - -int -SDL_SetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode scaleMode) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (!renderer->SetTextureScaleMode) { - SDL_Unsupported(); - return -1; - } - texture->scaleMode = scaleMode; - return renderer->SetTextureScaleMode(renderer, texture); -} - -int -SDL_GetTextureScaleMode(SDL_Texture * texture, SDL_ScaleMode *scaleMode) -{ - CHECK_TEXTURE_MAGIC(texture, -1); - - if (scaleMode) { - *scaleMode = texture->scaleMode; - } - return 0; -} - -int -SDL_UpdateTexture(SDL_Texture * texture, const SDL_Rect * rect, - const void *pixels, int pitch) -{ - SDL_Renderer *renderer; - SDL_Rect full_rect; - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = texture->renderer; - if (!renderer->UpdateTexture) { - SDL_Unsupported(); - return -1; - } - if (!rect) { - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = texture->w; - full_rect.h = texture->h; - rect = &full_rect; - } - return renderer->UpdateTexture(renderer, texture, rect, pixels, pitch); -} - -int -SDL_LockTexture(SDL_Texture * texture, const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch) -{ - SDL_Renderer *renderer; - SDL_Rect full_rect; - - CHECK_TEXTURE_MAGIC(texture, -1); - - if (texture->access != SDL_TEXTUREACCESS_STREAMING) { - SDL_SetError("SDL_LockTexture(): texture must be streaming"); - return -1; - } - renderer = texture->renderer; - if (!renderer->LockTexture) { - SDL_Unsupported(); - return -1; - } - if (!rect) { - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = texture->w; - full_rect.h = texture->h; - rect = &full_rect; - } - return renderer->LockTexture(renderer, texture, rect, markDirty, pixels, - pitch); -} - -void -SDL_UnlockTexture(SDL_Texture * texture) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, ); - - if (texture->access != SDL_TEXTUREACCESS_STREAMING) { - return; - } - renderer = texture->renderer; - if (!renderer->UnlockTexture) { - return; - } - renderer->UnlockTexture(renderer, texture); -} - -void -SDL_DirtyTexture(SDL_Texture * texture, int numrects, - const SDL_Rect * rects) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, ); - - if (texture->access != SDL_TEXTUREACCESS_STREAMING) { - return; - } - renderer = texture->renderer; - if (!renderer->DirtyTexture) { - return; - } - renderer->DirtyTexture(renderer, texture, numrects, rects); -} - -int -SDL_SetRenderDrawColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - SDL_Renderer *renderer; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - renderer->r = r; - renderer->g = g; - renderer->b = b; - renderer->a = a; - if (renderer->SetDrawColor) { - return renderer->SetDrawColor(renderer); - } else { - return 0; - } -} - -int -SDL_GetRenderDrawColor(Uint8 * r, Uint8 * g, Uint8 * b, Uint8 * a) -{ - SDL_Renderer *renderer; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (r) { - *r = renderer->r; - } - if (g) { - *g = renderer->g; - } - if (b) { - *b = renderer->b; - } - if (a) { - *a = renderer->a; - } - return 0; -} - -int -SDL_SetRenderDrawBlendMode(SDL_BlendMode blendMode) -{ - SDL_Renderer *renderer; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - renderer->blendMode = blendMode; - if (renderer->SetDrawBlendMode) { - return renderer->SetDrawBlendMode(renderer); - } else { - return 0; - } -} - -int -SDL_GetRenderDrawBlendMode(SDL_BlendMode *blendMode) -{ - SDL_Renderer *renderer; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - *blendMode = renderer->blendMode; - return 0; -} - -int -SDL_RenderClear() -{ - SDL_Renderer *renderer; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (!renderer->RenderClear) { - SDL_BlendMode blendMode = renderer->blendMode; - int status; - - if (blendMode >= SDL_BLENDMODE_BLEND) { - SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE); - } - - status = SDL_RenderFillRect(NULL); - - if (blendMode >= SDL_BLENDMODE_BLEND) { - SDL_SetRenderDrawBlendMode(blendMode); - } - return status; - } - return renderer->RenderClear(renderer); -} - -#if SDL_VIDEO_RENDER_RESIZE - -static inline void -SDL_RESIZE_resizePoints(int realW, int fakeW, int realH, int fakeH, - const SDL_Point * src, SDL_Point * dest, int count ) -{ - int i; - for( i = 0; i < count; i++ ) { - dest[i].x = src[i].x * realW / fakeW; - dest[i].y = src[i].y * realH / fakeH; - } -} - -static inline void -SDL_RESIZE_resizeRects(int realW, int fakeW, int realH, int fakeH, - const SDL_Rect ** src, SDL_Rect * dest, int count ) -{ - int i; - for( i = 0; i < count; i++ ) { - // Calculate bottom-right corner instead of width/height, and substract upper-left corner, - // otherwise we'll have rounding errors and holes between textures - dest[i].x = src[i]->x * realW / fakeW; - dest[i].y = src[i]->y * realH / fakeH; - dest[i].w = (src[i]->w + src[i]->x) * realW / fakeW - dest[i].x; - dest[i].h = (src[i]->h + src[i]->y) * realH / fakeH - dest[i].y; - } -} - -#endif - -int -SDL_RenderDrawPoint(int x, int y) -{ - SDL_Point point; - - point.x = x; - point.y = y; - - return SDL_RenderDrawPoints(&point, 1); -} - -int -SDL_RenderDrawPoints(const SDL_Point * points, int count) -{ - SDL_Renderer *renderer; -#if SDL_VIDEO_RENDER_RESIZE - int realW, realH, fakeW, fakeH, ret; -#endif - - if (!points) { - SDL_SetError("SDL_RenderDrawPoints(): Passed NULL points"); - return -1; - } - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (!renderer->RenderDrawPoints) { - SDL_Unsupported(); - return -1; - } - if (count < 1) { - return 0; - } - -#if SDL_VIDEO_RENDER_RESIZE - realW = renderer->window->display->desktop_mode.w; - realH = renderer->window->display->desktop_mode.h; - fakeW = renderer->window->w; - fakeH = renderer->window->h; - //if( fakeW > realW || fakeH > realH ) - { - SDL_Point * resized = SDL_stack_alloc( SDL_Point, count ); - if( ! resized ) { - SDL_OutOfMemory(); - return -1; - } - SDL_RESIZE_resizePoints( realW, fakeW, realH, fakeH, points, resized, count ); - ret = renderer->RenderDrawPoints(renderer, resized, count); - SDL_stack_free(resized); - return ret; - } -#endif - - return renderer->RenderDrawPoints(renderer, points, count); -} - -int -SDL_RenderDrawLine(int x1, int y1, int x2, int y2) -{ - SDL_Point points[2]; - - points[0].x = x1; - points[0].y = y1; - points[1].x = x2; - points[1].y = y2; - return SDL_RenderDrawLines(points, 2); -} - -int -SDL_RenderDrawLines(const SDL_Point * points, int count) -{ - SDL_Renderer *renderer; -#if SDL_VIDEO_RENDER_RESIZE - int realW, realH, fakeW, fakeH, ret; -#endif - - if (!points) { - SDL_SetError("SDL_RenderDrawLines(): Passed NULL points"); - return -1; - } - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (!renderer->RenderDrawLines) { - SDL_Unsupported(); - return -1; - } - if (count < 2) { - return 0; - } - -#if SDL_VIDEO_RENDER_RESIZE - realW = renderer->window->display->desktop_mode.w; - realH = renderer->window->display->desktop_mode.h; - fakeW = renderer->window->w; - fakeH = renderer->window->h; - //if( fakeW > realW || fakeH > realH ) - { - SDL_Point * resized = SDL_stack_alloc( SDL_Point, count ); - if( ! resized ) { - SDL_OutOfMemory(); - return -1; - } - SDL_RESIZE_resizePoints( realW, fakeW, realH, fakeH, points, resized, count ); - ret = renderer->RenderDrawLines(renderer, resized, count); - SDL_stack_free(resized); - return ret; - } -#endif - - return renderer->RenderDrawLines(renderer, points, count); -} - -int -SDL_RenderDrawRect(const SDL_Rect * rect) -{ - return SDL_RenderDrawRects(&rect, 1); -} - -int -SDL_RenderDrawRects(const SDL_Rect ** rects, int count) -{ - SDL_Renderer *renderer; - int i; -#if SDL_VIDEO_RENDER_RESIZE - int realW, realH, fakeW, fakeH, ret; -#endif - - if (!rects) { - SDL_SetError("SDL_RenderDrawRects(): Passed NULL rects"); - return -1; - } - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (!renderer->RenderDrawRects) { - SDL_Unsupported(); - return -1; - } - if (count < 1) { - return 0; - } - /* Check for NULL rect, which means fill entire window */ - for (i = 0; i < count; ++i) { - if (rects[i] == NULL) { - SDL_Window *window = renderer->window; - SDL_Rect full_rect; - const SDL_Rect *rect; - - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = window->w; - full_rect.h = window->h; - rect = &full_rect; - return renderer->RenderDrawRects(renderer, &rect, 1); - } - } - -#if SDL_VIDEO_RENDER_RESIZE - realW = renderer->window->display->desktop_mode.w; - realH = renderer->window->display->desktop_mode.h; - fakeW = renderer->window->w; - fakeH = renderer->window->h; - //if( fakeW > realW || fakeH > realH ) - { - SDL_Rect * resized = SDL_stack_alloc( SDL_Rect, count ); - if( ! resized ) { - SDL_OutOfMemory(); - return -1; - } - - const SDL_Rect ** resizedPtrs = SDL_stack_alloc( const SDL_Rect *, count ); - if( ! resizedPtrs ) { - SDL_OutOfMemory(); - return -1; - } - - for( i = 0; i < count; i++ ) { - resizedPtrs[i] = &(resized[i]); - } - SDL_RESIZE_resizeRects( realW, fakeW, realH, fakeH, rects, resized, count ); - ret = renderer->RenderDrawRects(renderer, resizedPtrs, count); - SDL_stack_free(resizedPtrs); - SDL_stack_free(resized); - return ret; - } -#endif - - return renderer->RenderDrawRects(renderer, rects, count); -} - -int -SDL_RenderFillRect(const SDL_Rect * rect) -{ - return SDL_RenderFillRects(&rect, 1); -} - -int -SDL_RenderFillRects(const SDL_Rect ** rects, int count) -{ - SDL_Renderer *renderer; - int i; -#if SDL_VIDEO_RENDER_RESIZE - int realW, realH, fakeW, fakeH, ret; -#endif - - if (!rects) { - SDL_SetError("SDL_RenderFillRects(): Passed NULL rects"); - return -1; - } - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (!renderer->RenderFillRects) { - SDL_Unsupported(); - return -1; - } - if (count < 1) { - return 0; - } - /* Check for NULL rect, which means fill entire window */ - for (i = 0; i < count; ++i) { - if (rects[i] == NULL) { - SDL_Window *window = renderer->window; - SDL_Rect full_rect; - const SDL_Rect *rect; - - full_rect.x = 0; - full_rect.y = 0; - full_rect.w = window->w; - full_rect.h = window->h; - rect = &full_rect; - return renderer->RenderFillRects(renderer, &rect, 1); - } - } - -#if SDL_VIDEO_RENDER_RESIZE - realW = renderer->window->display->desktop_mode.w; - realH = renderer->window->display->desktop_mode.h; - fakeW = renderer->window->w; - fakeH = renderer->window->h; - //if( fakeW > realW || fakeH > realH ) - { - SDL_Rect * resized = SDL_stack_alloc( SDL_Rect, count ); - if( ! resized ) { - SDL_OutOfMemory(); - return -1; - } - - const SDL_Rect ** resizedPtrs = SDL_stack_alloc( const SDL_Rect *, count ); - if( ! resizedPtrs ) { - SDL_OutOfMemory(); - return -1; - } - - for( i = 0; i < count; i++ ) { - resizedPtrs[i] = &(resized[i]); - } - SDL_RESIZE_resizeRects( realW, fakeW, realH, fakeH, rects, resized, count ); - ret = renderer->RenderFillRects(renderer, resizedPtrs, count); - SDL_stack_free(resizedPtrs); - SDL_stack_free(resized); - return ret; - } -#endif - - return renderer->RenderFillRects(renderer, rects, count); -} - -int -SDL_RenderCopy(SDL_Texture * texture, const SDL_Rect * srcrect, - const SDL_Rect * dstrect) -{ - SDL_Renderer *renderer; - SDL_Window *window; - SDL_Rect real_srcrect; - SDL_Rect real_dstrect; -#if SDL_VIDEO_RENDER_RESIZE - int realW; - int realH; - int fakeW; - int fakeH; -#endif - - CHECK_TEXTURE_MAGIC(texture, -1); - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (texture->renderer != renderer) { - SDL_SetError("Texture was not created with this renderer"); - return -1; - } - if (!renderer->RenderCopy) { - SDL_Unsupported(); - return -1; - } - window = renderer->window; - - real_srcrect.x = 0; - real_srcrect.y = 0; - real_srcrect.w = texture->w; - real_srcrect.h = texture->h; - if (srcrect) { - if (!SDL_IntersectRect(srcrect, &real_srcrect, &real_srcrect)) { - return 0; - } - } - - real_dstrect.x = 0; - real_dstrect.y = 0; - real_dstrect.w = window->w; - real_dstrect.h = window->h; - if (dstrect) { - if (!SDL_IntersectRect(dstrect, &real_dstrect, &real_dstrect)) { - return 0; - } - /* Clip srcrect by the same amount as dstrect was clipped */ - if (dstrect->w != real_dstrect.w) { - int deltax = (real_dstrect.x - dstrect->x); - int deltaw = (real_dstrect.w - dstrect->w); - real_srcrect.x += (deltax * real_srcrect.w) / dstrect->w; - real_srcrect.w += (deltaw * real_srcrect.w) / dstrect->w; - } - if (dstrect->h != real_dstrect.h) { - int deltay = (real_dstrect.y - dstrect->y); - int deltah = (real_dstrect.h - dstrect->h); - real_srcrect.y += (deltay * real_srcrect.h) / dstrect->h; - real_srcrect.h += (deltah * real_srcrect.h) / dstrect->h; - } - } - -#if SDL_VIDEO_RENDER_RESIZE - realW = window->display->desktop_mode.w; - realH = window->display->desktop_mode.h; - fakeW = window->w; - fakeH = window->h; - //if( fakeW > realW || fakeH > realH ) - { - // Calculate bottom-right corner instead of width/height, and substract upper-left corner, - // otherwise we'll have rounding errors and holes between textures - real_dstrect.w = (real_dstrect.w + real_dstrect.x) * realW / fakeW; - real_dstrect.h = (real_dstrect.h + real_dstrect.y) * realH / fakeH; - real_dstrect.x = real_dstrect.x * realW / fakeW; - real_dstrect.y = real_dstrect.y * realH / fakeH; - real_dstrect.w -= real_dstrect.x; - real_dstrect.h -= real_dstrect.y; - //__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_RenderCopy dest %d:%d+%d+%d desktop_mode %d:%d", (int)real_dstrect.x, (int)real_dstrect.y, (int)real_dstrect.w, (int)real_dstrect.h, (int)realW, (int)realH); - } -#endif - - return renderer->RenderCopy(renderer, texture, &real_srcrect, - &real_dstrect); -} - -int -SDL_RenderReadPixels(const SDL_Rect * rect, Uint32 format, - void * pixels, int pitch) -{ - SDL_Renderer *renderer; - SDL_Window *window; - SDL_Rect real_rect; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (!renderer->RenderReadPixels) { - SDL_Unsupported(); - return -1; - } - window = renderer->window; - - if (!format) { - format = window->display->current_mode.format; - } - - real_rect.x = 0; - real_rect.y = 0; - real_rect.w = window->w; - real_rect.h = window->h; - if (rect) { - if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { - return 0; - } - if (real_rect.y > rect->y) { - pixels = (Uint8 *)pixels + pitch * (real_rect.y - rect->y); - } - if (real_rect.x > rect->x) { - Uint32 format = SDL_CurrentDisplay->current_mode.format; - int bpp = SDL_BYTESPERPIXEL(format); - pixels = (Uint8 *)pixels + bpp * (real_rect.x - rect->x); - } - } - - return renderer->RenderReadPixels(renderer, &real_rect, - format, pixels, pitch); -} - -int -SDL_RenderWritePixels(const SDL_Rect * rect, Uint32 format, - const void * pixels, int pitch) -{ - SDL_Renderer *renderer; - SDL_Window *window; - SDL_Rect real_rect; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer) { - return -1; - } - if (!renderer->RenderWritePixels) { - SDL_Unsupported(); - return -1; - } - window = renderer->window; - - if (!format) { - format = window->display->current_mode.format; - } - - real_rect.x = 0; - real_rect.y = 0; - real_rect.w = window->w; - real_rect.h = window->h; - if (rect) { - if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) { - return 0; - } - if (real_rect.y > rect->y) { - pixels = (const Uint8 *)pixels + pitch * (real_rect.y - rect->y); - } - if (real_rect.x > rect->x) { - Uint32 format = SDL_CurrentDisplay->current_mode.format; - int bpp = SDL_BYTESPERPIXEL(format); - pixels = (const Uint8 *)pixels + bpp * (real_rect.x - rect->x); - } - } - - return renderer->RenderWritePixels(renderer, &real_rect, - format, pixels, pitch); -} - -void -SDL_RenderPresent(void) -{ - SDL_Renderer *renderer; - - renderer = SDL_GetCurrentRenderer(SDL_TRUE); - if (!renderer || !renderer->RenderPresent) { - return; - } -#if SDL_VIDEO_DRIVER_WIN32 - IME_Present((SDL_VideoData *)_this->driverdata); -#endif - renderer->RenderPresent(renderer); -} - -void -SDL_DestroyTexture(SDL_Texture * texture) -{ - SDL_Renderer *renderer; - - CHECK_TEXTURE_MAGIC(texture, ); - texture->magic = NULL; - - renderer = texture->renderer; - if (texture->next) { - texture->next->prev = texture->prev; - } - if (texture->prev) { - texture->prev->next = texture->next; - } else { - renderer->textures = texture->next; - } - - renderer->DestroyTexture(renderer, texture); - SDL_free(texture); -} - -void -SDL_DestroyRenderer(SDL_Window * window) -{ - SDL_Renderer *renderer; - - CHECK_WINDOW_MAGIC(window, ); - - renderer = window->renderer; - if (!renderer) { - return; - } - - /* Free existing textures for this renderer */ - while (renderer->textures) { - SDL_DestroyTexture(renderer->textures); - } - - /* Free the renderer instance */ - renderer->DestroyRenderer(renderer); - - /* Clear references */ - window->renderer = NULL; - if (SDL_CurrentDisplay->current_renderer == renderer) { - SDL_CurrentDisplay->current_renderer = NULL; - } -} - SDL_bool SDL_IsScreenSaverEnabled() { @@ -2992,21 +2044,18 @@ SDL_VideoQuit(void) if (!_this) { return; } + /* Halt event processing before doing anything else */ + SDL_QuitQuit(); + SDL_MouseQuit(); + SDL_KeyboardQuit(); SDL_StopEventLoop(); + SDL_EnableScreenSaver(); /* Clean up the system video */ - for (i = _this->num_displays; i--;) { - SDL_VideoDisplay *display = &_this->displays[i]; - while (display->windows) { - SDL_DestroyWindow(display->windows); - } - if (display->render_drivers) { - SDL_free(display->render_drivers); - display->render_drivers = NULL; - } - display->num_render_drivers = 0; + while (_this->windows) { + SDL_DestroyWindow(_this->windows); } _this->VideoQuit(_this); @@ -3026,14 +2075,6 @@ SDL_VideoQuit(void) SDL_free(display->desktop_mode.driverdata); display->desktop_mode.driverdata = NULL; } - if (display->palette) { - SDL_FreePalette(display->palette); - display->palette = NULL; - } - if (display->gamma) { - SDL_free(display->gamma); - display->gamma = NULL; - } if (display->driverdata) { SDL_free(display->driverdata); display->driverdata = NULL; @@ -3121,7 +2162,7 @@ SDL_GL_UnloadLibrary(void) SDL_bool SDL_GL_ExtensionSupported(const char *extension) { -#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 const GLubyte *(APIENTRY * glGetStringFunc) (GLenum); const char *extensions; const char *start; @@ -3175,7 +2216,7 @@ SDL_GL_ExtensionSupported(const char *extension) int SDL_GL_SetAttribute(SDL_GLattr attr, int value) { -#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 int retval; if (!_this) { @@ -3256,7 +2297,7 @@ SDL_GL_SetAttribute(SDL_GLattr attr, int value) int SDL_GL_GetAttribute(SDL_GLattr attr, int *value) { -#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_OPENGL || SDL_VIDEO_OPENGL_ES || SDL_VIDEO_OPENGL_ES2 void (APIENTRY * glGetIntegervFunc) (GLenum pname, GLint * params); GLenum(APIENTRY * glGetErrorFunc) (void); GLenum attrib = 0; @@ -3276,9 +2317,6 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) *value = 0; switch (attr) { - case SDL_GL_RETAINED_BACKING: - *value = _this->gl_config.retained_backing; - return 0; case SDL_GL_RED_SIZE: attrib = GL_RED_BITS; break; @@ -3292,7 +2330,7 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) attrib = GL_ALPHA_BITS; break; case SDL_GL_DOUBLEBUFFER: -#ifndef SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_OPENGL attrib = GL_DOUBLEBUFFER; break; #else @@ -3308,7 +2346,7 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) case SDL_GL_STENCIL_SIZE: attrib = GL_STENCIL_BITS; break; -#ifndef SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_OPENGL case SDL_GL_ACCUM_RED_SIZE: attrib = GL_ACCUM_RED_BITS; break; @@ -3335,14 +2373,14 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) return 0; #endif case SDL_GL_MULTISAMPLEBUFFERS: -#ifndef SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_OPENGL attrib = GL_SAMPLE_BUFFERS_ARB; #else attrib = GL_SAMPLE_BUFFERS; #endif break; case SDL_GL_MULTISAMPLESAMPLES: -#ifndef SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_OPENGL attrib = GL_SAMPLES_ARB; #else attrib = GL_SAMPLES; @@ -3375,6 +2413,21 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) *value = (_this->gl_config.accelerated != 0); return 0; } + case SDL_GL_RETAINED_BACKING: + { + *value = _this->gl_config.retained_backing; + return 0; + } + case SDL_GL_CONTEXT_MAJOR_VERSION: + { + *value = _this->gl_config.major_version; + return 0; + } + case SDL_GL_CONTEXT_MINOR_VERSION: + { + *value = _this->gl_config.minor_version; + return 0; + } default: SDL_SetError("Unknown OpenGL attribute"); return -1; @@ -3412,28 +2465,49 @@ SDL_GL_GetAttribute(SDL_GLattr attr, int *value) SDL_GLContext SDL_GL_CreateContext(SDL_Window * window) { + SDL_GLContext ctx = NULL; CHECK_WINDOW_MAGIC(window, NULL); if (!(window->flags & SDL_WINDOW_OPENGL)) { SDL_SetError("The specified window isn't an OpenGL window"); return NULL; } - return _this->GL_CreateContext(_this, window); + + ctx = _this->GL_CreateContext(_this, window); + + /* Creating a context is assumed to make it current in the SDL driver. */ + _this->current_glwin = window; + _this->current_glctx = ctx; + + return ctx; } int -SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext context) +SDL_GL_MakeCurrent(SDL_Window * window, SDL_GLContext ctx) { + int retval; + CHECK_WINDOW_MAGIC(window, -1); if (!(window->flags & SDL_WINDOW_OPENGL)) { SDL_SetError("The specified window isn't an OpenGL window"); return -1; } - if (!context) { + if (!ctx) { window = NULL; } - return _this->GL_MakeCurrent(_this, window, context); + + if ((window == _this->current_glwin) && (ctx == _this->current_glctx)) { + retval = 0; /* we're already current. */ + } else { + retval = _this->GL_MakeCurrent(_this, window, ctx); + if (retval == 0) { + _this->current_glwin = window; + _this->current_glctx = ctx; + } + } + + return retval; } int @@ -3442,8 +2516,10 @@ SDL_GL_SetSwapInterval(int interval) if (!_this) { SDL_UninitializedVideo(); return -1; - } - if (_this->GL_SetSwapInterval) { + } else if (_this->current_glctx == NULL) { + SDL_SetError("No OpenGL context has been made current"); + return -1; + } else if (_this->GL_SetSwapInterval) { return _this->GL_SetSwapInterval(_this, interval); } else { SDL_SetError("Setting the swap interval is not supported"); @@ -3457,8 +2533,10 @@ SDL_GL_GetSwapInterval(void) if (!_this) { SDL_UninitializedVideo(); return -1; - } - if (_this->GL_GetSwapInterval) { + } else if (_this->current_glctx == NULL) { + SDL_SetError("No OpenGL context has been made current"); + return -1; + } else if (_this->GL_GetSwapInterval) { return _this->GL_GetSwapInterval(_this); } else { SDL_SetError("Getting the swap interval is not supported"); @@ -3631,41 +2709,4 @@ SDL_SetTextInputRect(SDL_Rect *rect) } } -#ifdef ANDROID -void SDL_ANDROID_VideoContextLost() -{ - SDL_Texture * tex; - if( ! SDL_CurrentDisplay || ! SDL_CurrentRenderer || ! SDL_CurrentRenderer->window || ! SDL_CurrentRenderer->textures || SDL_GetWindowFlags(SDL_CurrentRenderer->window) & SDL_WINDOW_OPENGL ) - return; - - tex = SDL_CurrentRenderer->textures; - while( tex ) - { - SDL_CurrentRenderer->DestroyTexture( SDL_CurrentRenderer, tex ); - tex = tex->next; - } -} - -void SDL_ANDROID_VideoContextRecreated() -{ - int numTextures = 0; - SDL_Texture * tex; - __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_VideoContextRecreated(): SDL_CurrentRenderer %p", SDL_CurrentRenderer); - if( ! SDL_CurrentRenderer ) - return; - - if( SDL_CurrentRenderer->ActivateRenderer ) /* Re-apply glOrtho() and blend modes */ - SDL_CurrentRenderer->ActivateRenderer(SDL_CurrentRenderer); - - tex = SDL_CurrentRenderer->textures; - while( tex ) - { - SDL_CurrentRenderer->CreateTexture( SDL_CurrentRenderer, tex ); - tex = tex->next; - numTextures++; - } - __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_VideoContextRecreated(): re-created %d textures", numTextures); -} -#endif - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/README b/project/jni/sdl-1.3/src/video/Xext/README deleted file mode 100644 index a16ea6844..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/README +++ /dev/null @@ -1,10 +0,0 @@ - -The reason these libraries are built outside of the standard XFree86 -tree is so that they can be linked as shared object code directly into -SDL without causing any symbol collisions with code in the application. - -You can't link static library code into shared libraries on non-x86 -Linux platforms. Since these libraries haven't become standard yet, -we'll just include them directly. - -These sources are synchronized with XFree86 4.2.1 diff --git a/project/jni/sdl-1.3/src/video/Xext/XME/xme.c b/project/jni/sdl-1.3/src/video/Xext/XME/xme.c deleted file mode 100644 index 12a3e1dbe..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XME/xme.c +++ /dev/null @@ -1,426 +0,0 @@ -/* - * Copyright 1993-2001 by Xi Graphics, Inc. - * All Rights Reserved. - * - * Please see the LICENSE file accompanying this distribution for licensing - * information. - * - * Please send any bug fixes and modifications to src@xig.com. - * - * $XiGId: xme.c,v 1.2 2001/11/30 21:56:59 jon Exp $ - * - */ - -#define NEED_EVENTS -#define NEED_REPLIES - -/* Apparently some X11 systems can't include this multiple times... */ -#ifndef SDL_INCLUDED_XLIBINT_H -#define SDL_INCLUDED_XLIBINT_H 1 -#include -#endif - -#include -#include -#include -#include "../extensions/Xext.h" -#include "../extensions/extutil.h" - -/*****************************************************************************/ - - -#define XIGMISC_PROTOCOL_NAME "XiG-SUNDRY-NONSTANDARD" -#define XIGMISC_MAJOR_VERSION 2 -#define XIGMISC_MINOR_VERSION 0 - -#define XiGMiscNumberEvents 0 - -#define X_XiGMiscQueryVersion 0 -#define X_XiGMiscQueryViews 1 -#define X_XiGMiscQueryResolutions 2 -#define X_XiGMiscChangeResolution 3 -#define X_XiGMiscFullScreen 4 - -#define sz_xXiGMiscQueryVersionReq 8 -#define sz_xXiGMiscQueryViewsReq 8 -#define sz_xXiGMiscQueryResolutionsReq 8 -#define sz_xXiGMiscChangeResolutionReq 16 -#define sz_xXiGMiscFullScreenReq 16 - -#define sz_xXiGMiscQueryVersionReply 32 -#define sz_xXiGMiscQueryViewsReply 32 -#define sz_xXiGMiscQueryResolutionsReply 32 -#define sz_xXiGMiscQueryFullScreenReply 32 - -/*******************************************************************/ - -typedef struct -{ - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscQueryVersion */ - CARD16 length; - CARD16 major; - CARD16 minor; -} xXiGMiscQueryVersionReq; - -typedef struct -{ - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscQueryViews */ - CARD16 length; - CARD8 screen; - CARD8 pad0; - CARD16 pad1; -} xXiGMiscQueryViewsReq; - -typedef struct -{ - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscQueryResolutions */ - CARD16 length; - CARD8 screen; - CARD8 view; - CARD16 pad0; -} xXiGMiscQueryResolutionsReq; - -typedef struct -{ - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscChangeResolution */ - CARD16 length; - CARD8 screen; - CARD8 view; - CARD16 pad0; - CARD16 width; - CARD16 height; - INT32 refresh; -} xXiGMiscChangeResolutionReq; - -typedef struct -{ - CARD8 reqType; /* always codes->major_opcode */ - CARD8 xigmiscReqType; /* always X_XiGMiscFullScreen */ - CARD16 length; - CARD8 screen; - CARD8 pad0; - CARD16 pad1; - CARD32 window; - CARD32 cmap; -} xXiGMiscFullScreenReq; - -/*******************************************************************/ - -typedef struct -{ - BYTE type; /* X_Reply */ - CARD8 pad0; - CARD16 sequenceNumber; - CARD32 length; - CARD16 major; - CARD16 minor; - CARD32 pad1; - CARD32 pad2; - CARD32 pad3; - CARD32 pad4; - CARD32 pad5; -} xXiGMiscQueryVersionReply; - -typedef struct -{ - BYTE type; /* X_Reply */ - CARD8 pad0; - CARD16 sequenceNumber; - CARD32 length; - CARD32 nviews; - CARD32 pad1; - CARD32 pad2; - CARD32 pad3; - CARD32 pad4; - CARD32 pad5; -} xXiGMiscQueryViewsReply; - -typedef struct -{ - BYTE type; /* X_Reply */ - CARD8 pad0; - CARD16 sequenceNumber; - CARD32 length; - CARD16 active; - CARD16 nresolutions; - CARD32 pad1; - CARD32 pad2; - CARD32 pad3; - CARD32 pad4; - CARD32 pad5; -} xXiGMiscQueryResolutionsReply; - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL success; - CARD16 sequenceNumber; - CARD32 length; - CARD32 pad1; - CARD32 pad2; - CARD32 pad3; - CARD32 pad4; - CARD32 pad5; - CARD32 pad6; -} xXiGMiscFullScreenReply; - -/*******************************************************************/ - -typedef struct -{ - INT16 x; - INT16 y; - CARD16 w; - CARD16 h; -} XiGMiscViewInfo; - -typedef struct -{ - CARD16 width; - CARD16 height; - INT32 refresh; -} XiGMiscResolutionInfo; - -/*****************************************************************************/ - -static XExtensionInfo *xigmisc_info = NULL; -static char *xigmisc_extension_name = XIGMISC_PROTOCOL_NAME; - -#define XiGMiscCheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, xigmisc_extension_name, val) -#define XiGMiscSimpleCheckExtension(dpy,i) \ - XextSimpleCheckExtension (dpy, i, xigmisc_extension_name) - -#if defined(__STDC__) && !defined(UNIXCPP) -#define XiGMiscGetReq(name,req,info) GetReq (name, req); \ - req->reqType = info->codes->major_opcode; \ - req->xigmiscReqType = X_##name; - -#define XiGMiscGetReqExtra(name,n,req,info) GetReqExtra (name, n, req); \ - req->reqType = info->codes->major_opcode; \ - req->xigmicReqType = X_##name; -#else -#define XiGMiscGetReq(name,req,info) GetReq (name, req); \ - req->reqType = info->codes->major_opcode; \ - req->xigmiscReqType = X_/**/name; -#define XiGMiscGetReqExtra(name,n,req,info) GetReqExtra (name, n, req); \ - req->reqType = info->codes->major_opcode; \ - req->xigmiscReqType = X_/**/name; -#endif - - - -/* - * find_display - locate the display info block - */ -static int XiGMiscCloseDisplay(); - -static XExtensionHooks xigmisc_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - XiGMiscCloseDisplay, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - - -static -XEXT_GENERATE_CLOSE_DISPLAY(XiGMiscCloseDisplay, xigmisc_info) - static XEXT_GENERATE_FIND_DISPLAY(XiGMiscFindDisplay, xigmisc_info, - xigmisc_extension_name, - &xigmisc_extension_hooks, - XiGMiscNumberEvents, NULL) -/*****************************************************************************/ - Bool XiGMiscQueryVersion(Display * dpy, int *major, int *minor) -{ - int opcode, event, error; - xXiGMiscQueryVersionReq *req; - xXiGMiscQueryVersionReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - - if (!XQueryExtension(dpy, XIGMISC_PROTOCOL_NAME, &opcode, &event, &error)) - return xFalse; - - XiGMiscCheckExtension(dpy, info, xFalse); - - LockDisplay(dpy); - XiGMiscGetReq(XiGMiscQueryVersion, req, info); - - req->major = XIGMISC_MAJOR_VERSION; - req->minor = XIGMISC_MINOR_VERSION; - - if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return xFalse; - } - - *major = rep.major; - *minor = rep.minor; - UnlockDisplay(dpy); - SyncHandle(); - - return xTrue; -} - -int -XiGMiscQueryViews(Display * dpy, int screen, XiGMiscViewInfo ** pviews) -{ - int n, size; - XiGMiscViewInfo *views; - xXiGMiscQueryViewsReq *req; - xXiGMiscQueryViewsReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - XiGMiscCheckExtension(dpy, info, 0); - - LockDisplay(dpy); - XiGMiscGetReq(XiGMiscQueryViews, req, info); - req->screen = screen; - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - - n = rep.nviews; - - if (n > 0) { - size = sizeof(XiGMiscViewInfo) * n; - views = (XiGMiscViewInfo *) Xmalloc(size); - if (!views) { - _XEatData(dpy, (unsigned long) size); - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - - _XReadPad(dpy, (void *) views, size); - - *pviews = views; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return n; -} - -int -XiGMiscQueryResolutions(Display * dpy, int screen, int view, int *pactive, - XiGMiscResolutionInfo ** presolutions) -{ - int n, size; - XiGMiscResolutionInfo *resolutions; - xXiGMiscQueryResolutionsReq *req; - xXiGMiscQueryResolutionsReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - XiGMiscCheckExtension(dpy, info, 0); - - LockDisplay(dpy); - XiGMiscGetReq(XiGMiscQueryResolutions, req, info); - req->screen = screen; - req->view = view; - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - - n = rep.nresolutions; - - if (n > 0) { - size = sizeof(XiGMiscResolutionInfo) * n; - resolutions = (XiGMiscResolutionInfo *) Xmalloc(size); - if (!resolutions) { - _XEatData(dpy, (unsigned long) size); - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - - _XReadPad(dpy, (void *) resolutions, size); - - *presolutions = resolutions; - *pactive = rep.active; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return n; -} - -void -XiGMiscChangeResolution(Display * dpy, int screen, int view, int width, - int height, int refresh) -{ - xXiGMiscChangeResolutionReq *req; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - - XiGMiscSimpleCheckExtension(dpy, info); - - LockDisplay(dpy); - XiGMiscGetReq(XiGMiscChangeResolution, req, info); - req->screen = screen; - req->view = view; - req->width = width; - req->height = height; - req->refresh = refresh; - - UnlockDisplay(dpy); - SyncHandle(); -} - - -Bool -XiGMiscFullScreen(Display * dpy, int screen, XID window, XID cmap) -{ - xXiGMiscFullScreenReq *req; - xXiGMiscFullScreenReply rep; - XExtDisplayInfo *info = XiGMiscFindDisplay(dpy); - - XiGMiscCheckExtension(dpy, info, xFalse); - - LockDisplay(dpy); - XiGMiscGetReq(XiGMiscFullScreen, req, info); - req->screen = screen; - req->pad0 = 0; - req->pad1 = 0; - req->window = window; - req->cmap = cmap; - - if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return xFalse; - } - - UnlockDisplay(dpy); - SyncHandle(); - - return (rep.success ? xTrue : xFalse); -} - -/* SDL addition from Ryan: free memory used by xme. */ -void -XiGMiscDestroy(void) -{ - if (xigmisc_info) { - XextDestroyExtension(xigmisc_info); - xigmisc_info = NULL; - } -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/Xinerama/Xinerama.c b/project/jni/sdl-1.3/src/video/Xext/Xinerama/Xinerama.c deleted file mode 100644 index 3d8d66439..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/Xinerama/Xinerama.c +++ /dev/null @@ -1,303 +0,0 @@ -/* $Xorg: XPanoramiX.c,v 1.4 2000/08/17 19:45:51 cpqbld Exp $ */ -/***************************************************************** -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. -******************************************************************/ -/* $XFree86: xc/lib/Xinerama/Xinerama.c,v 1.2 2001/07/23 17:20:28 dawes Exp $ */ - -#define NEED_EVENTS -#define NEED_REPLIES - -/* Apparently some X11 systems can't include this multiple times... */ -#ifndef SDL_INCLUDED_XLIBINT_H -#define SDL_INCLUDED_XLIBINT_H 1 -#include -#endif - -#include -#include "../extensions/Xext.h" -#include "../extensions/extutil.h" /* in ../include */ -#include "../extensions/panoramiXext.h" -#include "../extensions/panoramiXproto.h" /* in ../include */ -#include "../extensions/Xinerama.h" - -static XExtensionInfo _panoramiX_ext_info_data; -static XExtensionInfo *panoramiX_ext_info = &_panoramiX_ext_info_data; -static /* const */ char *panoramiX_extension_name = PANORAMIX_PROTOCOL_NAME; - -#define PanoramiXCheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, panoramiX_extension_name, val) -#define PanoramiXSimpleCheckExtension(dpy,i) \ - XextSimpleCheckExtension (dpy, i, panoramiX_extension_name) - -static int close_display(); -static /* const */ XExtensionHooks panoramiX_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static -XEXT_GENERATE_FIND_DISPLAY(find_display, panoramiX_ext_info, - panoramiX_extension_name, - &panoramiX_extension_hooks, 0, NULL) - static XEXT_GENERATE_CLOSE_DISPLAY(close_display, panoramiX_ext_info) -/**************************************************************************** - * * - * PanoramiX public interfaces * - * * - ****************************************************************************/ - Bool SDL_NAME(XPanoramiXQueryExtension) (Display * dpy, - int *event_basep, - int *error_basep) -{ - XExtDisplayInfo *info = find_display(dpy); - - if (XextHasExtension(info)) { - *event_basep = info->codes->first_event; - *error_basep = info->codes->first_error; - return True; - } else { - return False; - } -} - - -Status SDL_NAME(XPanoramiXQueryVersion) (Display * dpy, - int *major_versionp, - int *minor_versionp) -{ - XExtDisplayInfo *info = find_display(dpy); - xPanoramiXQueryVersionReply rep; - register xPanoramiXQueryVersionReq *req; - - PanoramiXCheckExtension(dpy, info, 0); - - LockDisplay(dpy); - GetReq(PanoramiXQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXQueryVersion; - req->clientMajor = PANORAMIX_MAJOR_VERSION; - req->clientMinor = PANORAMIX_MINOR_VERSION; - if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - *major_versionp = rep.majorVersion; - *minor_versionp = rep.minorVersion; - UnlockDisplay(dpy); - SyncHandle(); - return 1; -} - -SDL_NAME(XPanoramiXInfo) * SDL_NAME(XPanoramiXAllocInfo) (void) -{ - return (SDL_NAME(XPanoramiXInfo) *) - Xmalloc(sizeof(SDL_NAME(XPanoramiXInfo))); -} - -Status SDL_NAME(XPanoramiXGetState) (Display * dpy, - Drawable drawable, - SDL_NAME(XPanoramiXInfo) * - panoramiX_info) -{ - XExtDisplayInfo *info = find_display(dpy); - xPanoramiXGetStateReply rep; - register xPanoramiXGetStateReq *req; - - PanoramiXCheckExtension(dpy, info, 0); - - LockDisplay(dpy); - GetReq(PanoramiXGetState, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetState; - req->window = drawable; - if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - UnlockDisplay(dpy); - SyncHandle(); - panoramiX_info->window = rep.window; - panoramiX_info->State = rep.state; - return 1; -} - -Status SDL_NAME(XPanoramiXGetScreenCount) (Display * dpy, - Drawable drawable, - SDL_NAME(XPanoramiXInfo) * - panoramiX_info) -{ - XExtDisplayInfo *info = find_display(dpy); - xPanoramiXGetScreenCountReply rep; - register xPanoramiXGetScreenCountReq *req; - - PanoramiXCheckExtension(dpy, info, 0); - - LockDisplay(dpy); - GetReq(PanoramiXGetScreenCount, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetScreenCount; - req->window = drawable; - if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - UnlockDisplay(dpy); - SyncHandle(); - panoramiX_info->window = rep.window; - panoramiX_info->ScreenCount = rep.ScreenCount; - return 1; -} - -Status SDL_NAME(XPanoramiXGetScreenSize) (Display * dpy, - Drawable drawable, - int screen_num, - SDL_NAME(XPanoramiXInfo) * - panoramiX_info) -{ - XExtDisplayInfo *info = find_display(dpy); - xPanoramiXGetScreenSizeReply rep; - register xPanoramiXGetScreenSizeReq *req; - - PanoramiXCheckExtension(dpy, info, 0); - - LockDisplay(dpy); - GetReq(PanoramiXGetScreenSize, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_PanoramiXGetScreenSize; - req->window = drawable; - req->screen = screen_num; /* need to define */ - if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return 0; - } - UnlockDisplay(dpy); - SyncHandle(); - panoramiX_info->window = rep.window; - panoramiX_info->screen = rep.screen; - panoramiX_info->width = rep.width; - panoramiX_info->height = rep.height; - return 1; -} - -/*******************************************************************\ - Alternate interface to make up for shortcomings in the original, - namely, the omission of the screen origin. The new interface is - in the "Xinerama" namespace instead of "PanoramiX". -\*******************************************************************/ - -Bool SDL_NAME(XineramaQueryExtension) (Display * dpy, - int *event_base, int *error_base) -{ - return SDL_NAME(XPanoramiXQueryExtension) (dpy, event_base, error_base); -} - -Status SDL_NAME(XineramaQueryVersion) (Display * dpy, int *major, int *minor) -{ - return SDL_NAME(XPanoramiXQueryVersion) (dpy, major, minor); -} - -Bool SDL_NAME(XineramaIsActive) (Display * dpy) -{ - xXineramaIsActiveReply rep; - xXineramaIsActiveReq *req; - XExtDisplayInfo *info = find_display(dpy); - - if (!XextHasExtension(info)) - return False; /* server doesn't even have the extension */ - - LockDisplay(dpy); - GetReq(XineramaIsActive, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_XineramaIsActive; - if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - UnlockDisplay(dpy); - SyncHandle(); - return rep.state; -} - -#include - -SDL_NAME(XineramaScreenInfo) * -SDL_NAME(XineramaQueryScreens) (Display * dpy, int *number) -{ - XExtDisplayInfo *info = find_display(dpy); - xXineramaQueryScreensReply rep; - xXineramaQueryScreensReq *req; - SDL_NAME(XineramaScreenInfo) * scrnInfo = NULL; - - PanoramiXCheckExtension(dpy, info, 0); - - LockDisplay(dpy); - GetReq(XineramaQueryScreens, req); - req->reqType = info->codes->major_opcode; - req->panoramiXReqType = X_XineramaQueryScreens; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - if (rep.number) { - if ((scrnInfo = - Xmalloc(sizeof(SDL_NAME(XineramaScreenInfo)) * rep.number))) { - xXineramaScreenInfo scratch; - int i; - - for (i = 0; i < rep.number; i++) { - _XRead(dpy, (char *) (&scratch), sz_XineramaScreenInfo); - scrnInfo[i].screen_number = i; - scrnInfo[i].x_org = scratch.x_org; - scrnInfo[i].y_org = scratch.y_org; - scrnInfo[i].width = scratch.width; - scrnInfo[i].height = scratch.height; - } - - *number = rep.number; - } else - _XEatData(dpy, rep.length << 2); - } - - UnlockDisplay(dpy); - SyncHandle(); - return scrnInfo; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/AllCmap.c b/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/AllCmap.c deleted file mode 100644 index aba19dbea..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/AllCmap.c +++ /dev/null @@ -1,159 +0,0 @@ -/* $Xorg: AllCmap.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */ - -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/AllCmap.c,v 1.7 2001/01/17 19:42:53 dawes Exp $ */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include -#include "../extensions/StdCmap.h" - -static XVisualInfo *getDeepestVisual(int, XVisualInfo *, int); - -/* - * To create all of the appropriate standard colormaps for every visual of - * every screen on a given display, use XmuAllStandardColormaps. - * - * Define and retain as permanent resources all standard colormaps which are - * meaningful for the visuals of each screen of the display. Return 0 on - * failure, non-zero on success. If the property of any standard colormap - * is already defined, redefine it. - * - * This interface is intended to be used by window managers or a client - * upon start-up of a session. - * - * The standard colormaps of a screen are defined by properties associated - * with the screen's root window. Each screen has exactly one root window. - * The property names of standard colormaps are predefined, and each property - * name may describe at most one colormap. - * - * The standard colormaps are - * RGB_BEST_MAP - * RGB_RED_MAP - * RGB_GREEN_MAP - * RGB_BLUE_MAP - * RGB_DEFAULT_MAP - * RGB_GRAY_MAP - * - * Therefore a screen may have at most 6 standard colormap properties defined. - * - * A standard colormap is associated with a particular visual of the screen. - * A screen may have multiple visuals defined, including visuals of the same - * class at different depths. Note that a visual id might be repeated for - * more than one depth, so the visual id and the depth of a visual identify - * the visual. The characteristics of the visual will determine which - * standard colormaps are meaningful under that visual, and will determine - * how the standard colormap is defined. Because a standard colormap is - * associated with a specific visual, there must be a method of determining - * which visuals take precedence in defining standard colormaps. - * - * The method used here is: for the visual of greatest depth, define all - * standard colormaps meaningful to that visual class, according to this - * order of (descending) precedence: - * 1. DirectColor - * 2. PseudoColor - * 3. TrueColor and GrayScale - * 4. StaticColor and StaticGray - * - * Allows partial success by screenful. For example, if a map on screen 1 - * fails, the maps on screen 0, created earlier, will remain. However, - * none on screen 1 will remain. If a map on 0 fails, none will remain. - * - * See the comments under XmuVisualStandardColormaps() for notes on which - * standard colormaps are meaningful under these classes of visuals. - */ - -Status -XmuAllStandardColormaps(Display * dpy) -{ - int nvisuals, scr; - Status status; - long vinfo_mask; - XVisualInfo template, *vinfo, *v1, *v2; - - status = 0; - /* for each screen, determine all visuals of this server */ - for (scr = 0; scr < ScreenCount(dpy); scr++) { - template.screen = scr; - vinfo_mask = VisualScreenMask; - vinfo = XGetVisualInfo(dpy, vinfo_mask, &template, &nvisuals); - if (vinfo == NULL) /* unexpected: a screen with no visuals */ - continue; - - v1 = getDeepestVisual(DirectColor, vinfo, nvisuals); - v2 = getDeepestVisual(PseudoColor, vinfo, nvisuals); - - if (v2 && - (!v1 || (v2->colormap_size >= - ((v1->red_mask | v1->green_mask | v1->blue_mask) + 1)))) - status = XmuVisualStandardColormaps(dpy, scr, v2->visualid, - (unsigned) v2->depth, 1, 1); - else if (v1) - status = XmuVisualStandardColormaps(dpy, scr, v1->visualid, - (unsigned) v1->depth, 1, 1); - - else { - if (((v1 = getDeepestVisual(TrueColor, vinfo, nvisuals)) != NULL) - || ((v1 = getDeepestVisual(StaticColor, vinfo, nvisuals)) != - NULL)) - status = XmuVisualStandardColormaps(dpy, scr, v1->visualid, - (unsigned) v1->depth, 1, - 1); - if (status - && - (((v1 = getDeepestVisual(GrayScale, vinfo, nvisuals)) != NULL) - || ((v1 = getDeepestVisual(StaticGray, vinfo, nvisuals)) != - NULL))) - status = - XmuVisualStandardColormaps(dpy, scr, v1->visualid, - (unsigned) v1->depth, 1, 1); - } - XFree((char *) vinfo); - if (!status) - break; - } - return status; -} - -static XVisualInfo * -getDeepestVisual(int visual_class, XVisualInfo * vinfo, int nvisuals) -{ - register int i; - register int maxdepth = 0; - XVisualInfo *v = NULL; - - for (i = 0; i < nvisuals; i++, vinfo++) - if (vinfo->class == visual_class && vinfo->depth > maxdepth) { - maxdepth = vinfo->depth; - v = vinfo; - } - return (v); -} diff --git a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/CmapAlloc.c b/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/CmapAlloc.c deleted file mode 100644 index 17019db86..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/CmapAlloc.c +++ /dev/null @@ -1,337 +0,0 @@ -/* $Xorg: CmapAlloc.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */ - -/* - -Copyright 1989, 1994, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/CmapAlloc.c,v 1.6 2001/01/17 19:42:53 dawes Exp $ */ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include "../extensions/StdCmap.h" -#include - -#define lowbit(x) ((x) & (~(x) + 1)) - -/* - * Prototypes - */ -static void best_allocation(XVisualInfo *, unsigned long *, unsigned long *, - unsigned long *); -static int default_allocation(XVisualInfo *, unsigned long *, - unsigned long *, unsigned long *); -static void gray_allocation(int, unsigned long *, unsigned long *, - unsigned long *); -static int icbrt(int); -static int icbrt_with_bits(int, int); -static int icbrt_with_guess(int, int); - -/* To determine the best allocation of reds, greens, and blues in a - * standard colormap, use XmuGetColormapAllocation. - * vinfo specifies visual information for a chosen visual - * property specifies one of the standard colormap property names - * red_max returns maximum red value - * green_max returns maximum green value - * blue_max returns maximum blue value - * - * XmuGetColormapAllocation returns 0 on failure, non-zero on success. - * It is assumed that the visual is appropriate for the colormap property. - */ - -Status -XmuGetColormapAllocation(XVisualInfo * vinfo, Atom property, - unsigned long *red_max, - unsigned long *green_max, unsigned long *blue_max) -{ - Status status = 1; - - if (vinfo->colormap_size <= 2) - return 0; - - switch (property) { - case XA_RGB_DEFAULT_MAP: - status = default_allocation(vinfo, red_max, green_max, blue_max); - break; - case XA_RGB_BEST_MAP: - best_allocation(vinfo, red_max, green_max, blue_max); - break; - case XA_RGB_GRAY_MAP: - gray_allocation(vinfo->colormap_size, red_max, green_max, blue_max); - break; - case XA_RGB_RED_MAP: - *red_max = vinfo->colormap_size - 1; - *green_max = *blue_max = 0; - break; - case XA_RGB_GREEN_MAP: - *green_max = vinfo->colormap_size - 1; - *red_max = *blue_max = 0; - break; - case XA_RGB_BLUE_MAP: - *blue_max = vinfo->colormap_size - 1; - *red_max = *green_max = 0; - break; - default: - status = 0; - } - return status; -} - -/****************************************************************************/ -/* Determine the appropriate color allocations of a gray scale. - * - * Keith Packard, MIT X Consortium - */ - -static void -gray_allocation(int n, unsigned long *red_max, unsigned long *green_max, - unsigned long *blue_max) -{ - *red_max = (n * 30) / 100; - *green_max = (n * 59) / 100; - *blue_max = (n * 11) / 100; - *green_max += ((n - 1) - (*red_max + *green_max + *blue_max)); -} - -/****************************************************************************/ -/* Determine an appropriate color allocation for the RGB_DEFAULT_MAP. - * If a map has less than a minimum number of definable entries, we do not - * produce an allocation for an RGB_DEFAULT_MAP. - * - * For 16 planes, the default colormap will have 27 each RGB; for 12 planes, - * 12 each. For 8 planes, let n = the number of colormap entries, which may - * be 256 or 254. Then, maximum red value = floor(cube_root(n - 125)) - 1. - * Maximum green and maximum blue values are identical to maximum red. - * This leaves at least 125 cells which clients can allocate. - * - * Return 0 if an allocation has been determined, non-zero otherwise. - */ - -static int -default_allocation(XVisualInfo * vinfo, unsigned long *red, - unsigned long *green, unsigned long *blue) -{ - int ngrays; /* number of gray cells */ - - switch (vinfo->class) { - case PseudoColor: - - if (vinfo->colormap_size > 65000) - /* intended for displays with 16 planes */ - *red = *green = *blue = (unsigned long) 27; - else if (vinfo->colormap_size > 4000) - /* intended for displays with 12 planes */ - *red = *green = *blue = (unsigned long) 12; - else if (vinfo->colormap_size < 250) - return 0; - else - /* intended for displays with 8 planes */ - *red = *green = *blue = (unsigned long) - (icbrt(vinfo->colormap_size - 125) - 1); - break; - - case DirectColor: - - if (vinfo->colormap_size < 10) - return 0; - *red = *green = *blue = vinfo->colormap_size / 2 - 1; - break; - - case TrueColor: - - *red = vinfo->red_mask / lowbit(vinfo->red_mask); - *green = vinfo->green_mask / lowbit(vinfo->green_mask); - *blue = vinfo->blue_mask / lowbit(vinfo->blue_mask); - break; - - case GrayScale: - - if (vinfo->colormap_size > 65000) - ngrays = 4096; - else if (vinfo->colormap_size > 4000) - ngrays = 512; - else if (vinfo->colormap_size < 250) - return 0; - else - ngrays = 12; - gray_allocation(ngrays, red, green, blue); - break; - - default: - return 0; - } - return 1; -} - -/****************************************************************************/ -/* Determine an appropriate color allocation for the RGB_BEST_MAP. - * - * For a DirectColor or TrueColor visual, the allocation is determined - * by the red_mask, green_mask, and blue_mask members of the visual info. - * - * Otherwise, if the colormap size is an integral power of 2, determine - * the allocation according to the number of bits given to each color, - * with green getting more than red, and red more than blue, if there - * are to be inequities in the distribution. If the colormap size is - * not an integral power of 2, let n = the number of colormap entries. - * Then maximum red value = floor(cube_root(n)) - 1; - * maximum blue value = floor(cube_root(n)) - 1; - * maximum green value = n / ((# red values) * (# blue values)) - 1; - * Which, on a GPX, allows for 252 entries in the best map, out of 254 - * defineable colormap entries. - */ - -static void -best_allocation(XVisualInfo * vinfo, unsigned long *red, unsigned long *green, - unsigned long *blue) -{ - - if (vinfo->class == DirectColor || vinfo->class == TrueColor) { - *red = vinfo->red_mask; - while ((*red & 01) == 0) - *red >>= 1; - *green = vinfo->green_mask; - while ((*green & 01) == 0) - *green >>= 1; - *blue = vinfo->blue_mask; - while ((*blue & 01) == 0) - *blue >>= 1; - } else { - register int bits, n; - - /* Determine n such that n is the least integral power of 2 which is - * greater than or equal to the number of entries in the colormap. - */ - n = 1; - bits = 0; - while (vinfo->colormap_size > n) { - n = n << 1; - bits++; - } - - /* If the number of entries in the colormap is a power of 2, determine - * the allocation by "dealing" the bits, first to green, then red, then - * blue. If not, find the maximum integral red, green, and blue values - * which, when multiplied together, do not exceed the number of - - * colormap entries. - */ - if (n == vinfo->colormap_size) { - register int r, g, b; - b = bits / 3; - g = b + ((bits % 3) ? 1 : 0); - r = b + (((bits % 3) == 2) ? 1 : 0); - *red = 1 << r; - *green = 1 << g; - *blue = 1 << b; - } else { - *red = icbrt_with_bits(vinfo->colormap_size, bits); - *blue = *red; - *green = (vinfo->colormap_size / ((*red) * (*blue))); - } - (*red)--; - (*green)--; - (*blue)--; - } - return; -} - -/* - * integer cube roots by Newton's method - * - * Stephen Gildea, MIT X Consortium, July 1991 - */ - -static int -icbrt(int a) -{ - register int bits = 0; - register unsigned n = a; - - while (n) { - bits++; - n >>= 1; - } - return icbrt_with_bits(a, bits); -} - - -static int -icbrt_with_bits(int a, int bits) - /* bits - log 2 of a */ -{ - return icbrt_with_guess(a, a >> 2 * bits / 3); -} - -#ifdef _X_ROOT_STATS -int icbrt_loopcount; -#endif - -/* Newton's Method: x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */ - -/* for cube roots, x^3 - a = 0, x_new = x - 1/3 (x - a/x^2) */ - -/* - * Quick and dirty cube roots. Nothing fancy here, just Newton's method. - * Only works for positive integers (since that's all we need). - * We actually return floor(cbrt(a)) because that's what we need here, too. - */ - -static int -icbrt_with_guess(int a, int guess) -{ - register int delta; - -#ifdef _X_ROOT_STATS - icbrt_loopcount = 0; -#endif - if (a <= 0) - return 0; - if (guess < 1) - guess = 1; - - do { -#ifdef _X_ROOT_STATS - icbrt_loopcount++; -#endif - delta = (guess - a / (guess * guess)) / 3; -#ifdef DEBUG - printf("pass %d: guess=%d, delta=%d\n", icbrt_loopcount, guess, - delta); -#endif - guess -= delta; - } while (delta != 0); - - if (guess * guess * guess > a) - guess--; - - return guess; -} diff --git a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/CrCmap.c b/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/CrCmap.c deleted file mode 100644 index 27e0046a2..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/CrCmap.c +++ /dev/null @@ -1,531 +0,0 @@ -/* $Xorg: CrCmap.c,v 1.4 2001/02/09 02:03:51 xorgcvs Exp $ */ - -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/CrCmap.c,v 3.6 2001/01/17 19:42:53 dawes Exp $ */ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -/* - * CreateCmap.c - given a standard colormap description, make the map. - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include -#include "../extensions/StdCmap.h" - -/* - * Prototypes - */ -/* allocate entire map Read Only */ -static int ROmap(Display *, Colormap, unsigned long[], int, int); - -/* allocate a cell, prefer Read Only */ -static Status ROorRWcell(Display *, Colormap, unsigned long[], int, - XColor *, unsigned long); - -/* allocate a cell Read Write */ -static Status RWcell(Display *, Colormap, XColor *, XColor *, - unsigned long *); - -/* for quicksort */ -static int compare(_Xconst void *, _Xconst void *); - -/* find contiguous sequence of cells */ -static Status contiguous(unsigned long[], int, int, unsigned long, int *, - int *); - -/* frees resources before quitting */ -static void free_cells(Display *, Colormap, unsigned long[], int, int); - -/* create a map in a RO visual type */ -static Status readonly_map(Display *, XVisualInfo *, XStandardColormap *); - -/* create a map in a RW visual type */ -static Status readwrite_map(Display *, XVisualInfo *, XStandardColormap *); - -#define lowbit(x) ((x) & (~(x) + 1)) -#define TRUEMATCH(mult,max,mask) \ - (colormap->max * colormap->mult <= vinfo->mask && \ - lowbit(vinfo->mask) == colormap->mult) - -/* - * To create any one colormap which is described by an XStandardColormap - * structure, use XmuCreateColormap(). - * - * Return 0 on failure, non-zero on success. - * Resources created by this function are not made permanent. - * No argument error checking is provided. Use at your own risk. - * - * All colormaps are created with read only allocations, with the exception - * of read only allocations of colors in the default map or otherwise - * which fail to return the expected pixel value, and these are individually - * defined as read/write allocations. This is done so that all the cells - * defined in the default map are contiguous, for use in image processing. - * This typically happens with White and Black in the default map. - * - * Colormaps of static visuals are considered to be successfully created if - * the map of the static visual matches the definition given in the - * standard colormap structure. - */ - -Status -XmuCreateColormap(Display * dpy, XStandardColormap * colormap) - /* dpy - specifies the connection under which the map is created - * colormap - specifies the map to be created, and returns, particularly - * if the map is created as a subset of the default colormap - * of the screen, the base_pixel of the map. - */ -{ - XVisualInfo vinfo_template; /* template visual information */ - XVisualInfo *vinfo; /* matching visual information */ - XVisualInfo *vpointer; /* for freeing the entire list */ - long vinfo_mask; /* specifies the visual mask value */ - int n; /* number of matching visuals */ - int status; - - vinfo_template.visualid = colormap->visualid; - vinfo_mask = VisualIDMask; - if ((vinfo = - XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) - return 0; - - /* A visual id may be valid on multiple screens. Also, there may - * be multiple visuals with identical visual ids at different depths. - * If the colormap is the Default Colormap, use the Default Visual. - * Otherwise, arbitrarily, use the deepest visual. - */ - vpointer = vinfo; - if (n > 1) { - register int i; - register int screen_number; - Bool def_cmap; - - def_cmap = False; - for (screen_number = ScreenCount(dpy); --screen_number >= 0;) - if (colormap->colormap == DefaultColormap(dpy, screen_number)) { - def_cmap = True; - break; - } - - if (def_cmap) { - for (i = 0; i < n; i++, vinfo++) { - if (vinfo->visual == DefaultVisual(dpy, screen_number)) - break; - } - } else { - int maxdepth = 0; - XVisualInfo *v = NULL; - - for (i = 0; i < n; i++, vinfo++) - if (vinfo->depth > maxdepth) { - maxdepth = vinfo->depth; - v = vinfo; - } - vinfo = v; - } - } - - if (vinfo->class == PseudoColor || vinfo->class == DirectColor || - vinfo->class == GrayScale) - status = readwrite_map(dpy, vinfo, colormap); - else if (vinfo->class == TrueColor) - status = TRUEMATCH(red_mult, red_max, red_mask) && - TRUEMATCH(green_mult, green_max, green_mask) && - TRUEMATCH(blue_mult, blue_max, blue_mask); - else - status = readonly_map(dpy, vinfo, colormap); - - XFree((char *) vpointer); - return status; -} - -/****************************************************************************/ -static Status -readwrite_map(Display * dpy, XVisualInfo * vinfo, - XStandardColormap * colormap) -{ - register unsigned long i, n; /* index counters */ - unsigned long ncolors; /* number of colors to be defined */ - int npixels; /* number of pixels allocated R/W */ - int first_index; /* first index of pixels to use */ - int remainder; /* first index of remainder */ - XColor color; /* the definition of a color */ - unsigned long *pixels; /* array of colormap pixels */ - unsigned long delta; - - - /* Determine ncolors, the number of colors to be defined. - * Insure that 1 < ncolors <= the colormap size. - */ - if (vinfo->class == DirectColor) { - ncolors = colormap->red_max; - if (colormap->green_max > ncolors) - ncolors = colormap->green_max; - if (colormap->blue_max > ncolors) - ncolors = colormap->blue_max; - ncolors++; - delta = lowbit(vinfo->red_mask) + - lowbit(vinfo->green_mask) + lowbit(vinfo->blue_mask); - } else { - ncolors = colormap->red_max * colormap->red_mult + - colormap->green_max * colormap->green_mult + - colormap->blue_max * colormap->blue_mult + 1; - delta = 1; - } - if (ncolors <= 1 || (int) ncolors > vinfo->colormap_size) - return 0; - - /* Allocate Read/Write as much of the colormap as we can possibly get. - * Then insure that the pixels we were allocated are given in - * monotonically increasing order, using a quicksort. Next, insure - * that our allocation includes a subset of contiguous pixels at least - * as long as the number of colors to be defined. Now we know that - * these conditions are met: - * 1) There are no free cells in the colormap. - * 2) We have a contiguous sequence of pixels, monotonically - * increasing, of length >= the number of colors requested. - * - * One cell at a time, we will free, compute the next color value, - * then allocate read only. This takes a long time. - * This is done to insure that cells are allocated read only in the - * contiguous order which we prefer. If the server has a choice of - * cells to grant to an allocation request, the server may give us any - * cell, so that is why we do these slow gymnastics. - */ - - if ((pixels = (unsigned long *) calloc((unsigned) vinfo->colormap_size, - sizeof(unsigned long))) == NULL) - return 0; - - if ((npixels = ROmap(dpy, colormap->colormap, pixels, - vinfo->colormap_size, ncolors)) == 0) { - free((char *) pixels); - return 0; - } - - qsort((char *) pixels, npixels, sizeof(unsigned long), compare); - - if (!contiguous - (pixels, npixels, ncolors, delta, &first_index, &remainder)) { - /* can't find enough contiguous cells, give up */ - XFreeColors(dpy, colormap->colormap, pixels, npixels, - (unsigned long) 0); - free((char *) pixels); - return 0; - } - colormap->base_pixel = pixels[first_index]; - - /* construct a gray map */ - if (colormap->red_mult == 1 && colormap->green_mult == 1 && - colormap->blue_mult == 1) - for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) { - color.pixel = n; - color.blue = color.green = color.red = - (unsigned short) ((i * 65535) / (colormap->red_max + - colormap->green_max + - colormap->blue_max)); - - if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } - - /* construct a red ramp map */ - else if (colormap->green_max == 0 && colormap->blue_max == 0) - for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) { - color.pixel = n; - color.red = (unsigned short) ((i * 65535) / colormap->red_max); - color.green = color.blue = 0; - - if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } - - /* construct a green ramp map */ - else if (colormap->red_max == 0 && colormap->blue_max == 0) - for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) { - color.pixel = n; - color.green = - (unsigned short) ((i * 65535) / colormap->green_max); - color.red = color.blue = 0; - - if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } - - /* construct a blue ramp map */ - else if (colormap->red_max == 0 && colormap->green_max == 0) - for (n = colormap->base_pixel, i = 0; i < ncolors; i++, n += delta) { - color.pixel = n; - color.blue = (unsigned short) ((i * 65535) / colormap->blue_max); - color.red = color.green = 0; - - if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } - - /* construct a standard red green blue cube map */ - else { -#define calc(max,mult) (((n / colormap->mult) % \ - (colormap->max + 1)) * 65535) / colormap->max - - for (n = 0, i = 0; i < ncolors; i++, n += delta) { - color.pixel = n + colormap->base_pixel; - color.red = calc(red_max, red_mult); - color.green = calc(green_max, green_mult); - color.blue = calc(blue_max, blue_mult); - if (!ROorRWcell(dpy, colormap->colormap, pixels, npixels, &color, - first_index + i)) - return 0; - } -#undef calc - } - /* We have a read-only map defined. Now free unused cells, - * first those occuring before the contiguous sequence begins, - * then any following the contiguous sequence. - */ - - if (first_index) - XFreeColors(dpy, colormap->colormap, pixels, first_index, - (unsigned long) 0); - if (remainder) - XFreeColors(dpy, colormap->colormap, - &(pixels[first_index + ncolors]), remainder, - (unsigned long) 0); - - free((char *) pixels); - return 1; -} - - -/****************************************************************************/ -static int -ROmap(Display * dpy, Colormap cmap, unsigned long pixels[], int m, int n) - /* - * dpy - the X server connection - * cmap - specifies colormap ID - * pixels - returns pixel allocations - * m - specifies colormap size - * n - specifies number of colors - */ -{ - register int p; - - /* first try to allocate the entire colormap */ - if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL, - (unsigned) 0, pixels, (unsigned) m)) - return m; - - /* Allocate all available cells in the colormap, using a binary - * algorithm to discover how many cells we can allocate in the colormap. - */ - m--; - while (n <= m) { - p = n + ((m - n + 1) / 2); - if (XAllocColorCells(dpy, cmap, 1, (unsigned long *) NULL, - (unsigned) 0, pixels, (unsigned) p)) { - if (p == m) - return p; - else { - XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0); - n = p; - } - } else - m = p - 1; - } - return 0; -} - - -/****************************************************************************/ -static Status -contiguous(unsigned long pixels[], int npixels, int ncolors, - unsigned long delta, int *first, int *rem) - /* pixels - specifies allocated pixels - * npixels - specifies count of alloc'd pixels - * ncolors - specifies needed sequence length - * delta - between pixels - * first - returns first index of sequence - * rem - returns first index after sequence, or 0, if none follow - */ -{ - register int i = 1; /* walking index into the pixel array */ - register int count = 1; /* length of sequence discovered so far */ - - *first = 0; - if (npixels == ncolors) { - *rem = 0; - return 1; - } - *rem = npixels - 1; - while (count < ncolors && ncolors - count <= *rem) { - if (pixels[i - 1] + delta == pixels[i]) - count++; - else { - count = 1; - *first = i; - } - i++; - (*rem)--; - } - if (count != ncolors) - return 0; - return 1; -} - - -/****************************************************************************/ -static Status -ROorRWcell(Display * dpy, Colormap cmap, unsigned long pixels[], - int npixels, XColor * color, unsigned long p) -{ - unsigned long pixel; - XColor request; - - /* Free the read/write allocation of one cell in the colormap. - * Request a read only allocation of one cell in the colormap. - * If the read only allocation cannot be granted, give up, because - * there must be no free cells in the colormap. - * If the read only allocation is granted, but gives us a cell which - * is not the one that we just freed, it is probably the case that - * we are trying allocate White or Black or some other color which - * already has a read-only allocation in the map. So we try to - * allocate the previously freed cell with a read/write allocation, - * because we want contiguous cells for image processing algorithms. - */ - - pixel = color->pixel; - request.red = color->red; - request.green = color->green; - request.blue = color->blue; - - XFreeColors(dpy, cmap, &pixel, 1, (unsigned long) 0); - if (!XAllocColor(dpy, cmap, color) - || (color->pixel != pixel && - (!RWcell(dpy, cmap, color, &request, &pixel)))) { - free_cells(dpy, cmap, pixels, npixels, (int) p); - return 0; - } - return 1; -} - - -/****************************************************************************/ -static void -free_cells(Display * dpy, Colormap cmap, unsigned long pixels[], - int npixels, int p) - /* - * pixels - to be freed - * npixels - original number allocated - */ -{ - /* One of the npixels allocated has already been freed. - * p is the index of the freed pixel. - * First free the pixels preceeding p, and there are p of them; - * then free the pixels following p, there are npixels - p - 1 of them. - */ - XFreeColors(dpy, cmap, pixels, p, (unsigned long) 0); - XFreeColors(dpy, cmap, &(pixels[p + 1]), npixels - p - 1, - (unsigned long) 0); - free((char *) pixels); -} - - -/****************************************************************************/ -static Status -RWcell(Display * dpy, Colormap cmap, XColor * color, XColor * request, - unsigned long *pixel) -{ - unsigned long n = *pixel; - - XFreeColors(dpy, cmap, &(color->pixel), 1, (unsigned long) 0); - if (!XAllocColorCells(dpy, cmap, (Bool) 0, (unsigned long *) NULL, - (unsigned) 0, pixel, (unsigned) 1)) - return 0; - if (*pixel != n) { - XFreeColors(dpy, cmap, pixel, 1, (unsigned long) 0); - return 0; - } - color->pixel = *pixel; - color->flags = DoRed | DoGreen | DoBlue; - color->red = request->red; - color->green = request->green; - color->blue = request->blue; - XStoreColors(dpy, cmap, color, 1); - return 1; -} - - -/****************************************************************************/ -static int -compare(_Xconst void *e1, _Xconst void *e2) -{ - return ((int) (*(long *) e1 - *(long *) e2)); -} - - -/****************************************************************************/ -static Status -readonly_map(Display * dpy, XVisualInfo * vinfo, XStandardColormap * colormap) -{ - int i, last_pixel; - XColor color; - - last_pixel = (colormap->red_max + 1) * (colormap->green_max + 1) * - (colormap->blue_max + 1) + colormap->base_pixel - 1; - - for (i = colormap->base_pixel; i <= last_pixel; i++) { - - color.pixel = (unsigned long) i; - color.red = (unsigned short) - (((i / colormap->red_mult) * 65535) / colormap->red_max); - - if (vinfo->class == StaticColor) { - color.green = (unsigned short) - ((((i / colormap->green_mult) % (colormap->green_max + 1)) * - 65535) / colormap->green_max); - color.blue = (unsigned short) - (((i % colormap->green_mult) * 65535) / colormap->blue_max); - } else /* vinfo->class == GrayScale, old style allocation XXX */ - color.green = color.blue = color.red; - - XAllocColor(dpy, colormap->colormap, &color); - if (color.pixel != (unsigned long) i) - return 0; - } - return 1; -} diff --git a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/DelCmap.c b/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/DelCmap.c deleted file mode 100644 index 77bf0d0e9..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/DelCmap.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $Xorg: DelCmap.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */ - -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/DelCmap.c,v 1.6 2001/01/17 19:42:54 dawes Exp $ */ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include "../extensions/StdCmap.h" - -/* To remove any standard colormap property, use XmuDeleteStandardColormap(). - * XmuDeleteStandardColormap() will remove the specified property from the - * specified screen, releasing any resources used by the colormap(s) of the - * property if possible. - */ - -void -XmuDeleteStandardColormap(Display * dpy, int screen, Atom property) - /* dpy; - specifies the X server to connect to - * screen - specifies the screen of the display - * property - specifies the standard colormap property - */ -{ - XStandardColormap *stdcmaps, *s; - int count = 0; - - if (XGetRGBColormaps(dpy, RootWindow(dpy, screen), &stdcmaps, &count, - property)) { - for (s = stdcmaps; count > 0; count--, s++) { - if ((s->killid == ReleaseByFreeingColormap) && - (s->colormap != None) && - (s->colormap != DefaultColormap(dpy, screen))) - XFreeColormap(dpy, s->colormap); - else if (s->killid != None) - XKillClient(dpy, s->killid); - } - XDeleteProperty(dpy, RootWindow(dpy, screen), property); - XFree((char *) stdcmaps); - XSync(dpy, False); - } -} diff --git a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/Distinct.c b/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/Distinct.c deleted file mode 100644 index 5fa357a7e..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/Distinct.c +++ /dev/null @@ -1,90 +0,0 @@ -/* $Xorg: Distinct.c,v 1.4 2001/02/09 02:03:52 xorgcvs Exp $ */ - -/* - -Copyright 1990, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/Distinct.c,v 3.5 2001/07/25 15:04:50 dawes Exp $ */ - -/* - * Author: Keith Packard, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include "../extensions/StdCmap.h" - -/* - * Distinguishable colors routine. Determines if two colors are - * distinguishable or not. Somewhat arbitrary meaning. - */ - -#define MIN_DISTINGUISH 10000.0 - -Bool -XmuDistinguishableColors(XColor * colors, int count) -{ - double deltaRed, deltaGreen, deltaBlue; - double dist; - int i, j; - - for (i = 0; i < count - 1; i++) - for (j = i + 1; j < count; j++) { - deltaRed = (double) colors[i].red - (double) colors[j].red; - deltaGreen = (double) colors[i].green - (double) colors[j].green; - deltaBlue = (double) colors[i].blue - (double) colors[j].blue; - dist = deltaRed * deltaRed + - deltaGreen * deltaGreen + deltaBlue * deltaBlue; - if (dist <= MIN_DISTINGUISH * MIN_DISTINGUISH) - return False; - } - return True; -} - -Bool -XmuDistinguishablePixels(Display * dpy, Colormap cmap, - unsigned long *pixels, int count) -{ - XColor *defs; - int i, j; - Bool ret; - - for (i = 0; i < count - 1; i++) - for (j = i + 1; j < count; j++) - if (pixels[i] == pixels[j]) - return False; - defs = (XColor *) malloc(count * sizeof(XColor)); - if (!defs) - return False; - for (i = 0; i < count; i++) - defs[i].pixel = pixels[i]; - XQueryColors(dpy, cmap, defs, count); - ret = XmuDistinguishableColors(defs, count); - free((char *) defs); - return ret; -} diff --git a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/LookupCmap.c b/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/LookupCmap.c deleted file mode 100644 index 219b8ac88..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/LookupCmap.c +++ /dev/null @@ -1,323 +0,0 @@ -/* $Xorg: LookupCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */ - -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/LookupCmap.c,v 1.7 2001/07/25 15:04:50 dawes Exp $ */ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include -#include "../extensions/StdCmap.h" -#include - -/* - * Prototypes - */ -static Status lookup(Display *, int, VisualID, Atom, XStandardColormap *, - Bool); - -/* - * To create a standard colormap if one does not currently exist, or - * replace the currently existing standard colormap, use - * XmuLookupStandardColormap(). - * - * Given a screen, a visual, and a property, XmuLookupStandardColormap() - * will determine the best allocation for the property under the specified - * visual, and determine the whether to create a new colormap or to use - * the default colormap of the screen. It will call XmuStandardColormap() - * to create the standard colormap. - * - * If replace is true, any previous definition of the property will be - * replaced. If retain is true, the property and the colormap will be - * made permanent for the duration of the server session. However, - * pre-existing property definitions which are not replaced cannot be made - * permanent by a call to XmuLookupStandardColormap(); a request to retain - * resources pertains to newly created resources. - * - * Returns 0 on failure, non-zero on success. A request to create a - * standard colormap upon a visual which cannot support such a map is - * considered a failure. An example of this would be requesting any - * standard colormap property on a monochrome visual, or, requesting an - * RGB_BEST_MAP on a display whose colormap size is 16. - */ - -Status -XmuLookupStandardColormap(Display * dpy, int screen, VisualID visualid, - unsigned int depth, Atom property, - Bool replace, Bool retain) - /* - * dpy - specifies X server connection - * screen - specifies screen of display - * visualid - specifies the visual type - * depth - specifies the visual type - * property - a standard colormap property - * replace - specifies whether to replace - * retain - specifies whether to retain - */ -{ - Display *odpy; /* original display connection */ - XStandardColormap *colormap; - XVisualInfo vinfo_template, *vinfo; /* visual */ - long vinfo_mask; - unsigned long r_max, g_max, b_max; /* allocation */ - int count; - Colormap cmap; /* colormap ID */ - Status status = 0; - - - /* Match the requested visual */ - - vinfo_template.visualid = visualid; - vinfo_template.screen = screen; - vinfo_template.depth = depth; - vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask; - if ((vinfo = XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &count)) == - NULL) - return 0; - - /* Monochrome visuals have no standard maps */ - - if (vinfo->colormap_size <= 2) { - XFree((char *) vinfo); - return 0; - } - - /* If the requested property already exists on this screen, and, - * if the replace flag has not been set to true, return success. - * lookup() will remove a pre-existing map if replace is true. - */ - - if (lookup(dpy, screen, visualid, property, (XStandardColormap *) NULL, - replace) && !replace) { - XFree((char *) vinfo); - return 1; - } - - /* Determine the best allocation for this property under the requested - * visualid and depth, and determine whether or not to use the default - * colormap of the screen. - */ - - if (!XmuGetColormapAllocation(vinfo, property, &r_max, &g_max, &b_max)) { - XFree((char *) vinfo); - return 0; - } - - cmap = (property == XA_RGB_DEFAULT_MAP && - visualid == XVisualIDFromVisual(DefaultVisual(dpy, screen))) - ? DefaultColormap(dpy, screen) : None; - - /* If retaining resources, open a new connection to the same server */ - - if (retain) { - odpy = dpy; - if ((dpy = XOpenDisplay(XDisplayString(odpy))) == NULL) { - XFree((char *) vinfo); - return 0; - } - } - - /* Create the standard colormap */ - - colormap = XmuStandardColormap(dpy, screen, visualid, depth, property, - cmap, r_max, g_max, b_max); - - /* Set the standard colormap property */ - - if (colormap) { - XGrabServer(dpy); - - if (lookup(dpy, screen, visualid, property, colormap, replace) && - !replace) { - /* Someone has defined the property since we last looked. - * Since we will not replace it, release our own resources. - * If this is the default map, our allocations will be freed - * when this connection closes. - */ - if (colormap->killid == ReleaseByFreeingColormap) - XFreeColormap(dpy, colormap->colormap); - } else if (retain) { - XSetCloseDownMode(dpy, RetainPermanent); - } - XUngrabServer(dpy); - XFree((char *) colormap); - status = 1; - } - - if (retain) - XCloseDisplay(dpy); - XFree((char *) vinfo); - return status; -} - -/***************************************************************************/ - -/* Lookup a standard colormap property. If the property is RGB_DEFAULT_MAP, - * the visualid is used to determine whether the indicated standard colormap - * exists. If the map exists and replace is true, delete the resources used - * by the map and remove the property. Return true if the map exists, - * or did exist and was deleted; return false if the map was not found. - * - * Note that this is not the way that a Status return is normally used. - * - * If new is not NULL, new points to an XStandardColormap structure which - * describes a standard colormap of the specified property. It will be made - * a standard colormap of the screen if none already exists, or if replace - * is true. - */ - -static Status -lookup(Display * dpy, int screen, VisualID visualid, Atom property, - XStandardColormap * cnew, Bool replace) - /* - * dpy - specifies display connection - * screen - specifies screen number - * visualid - specifies visualid for std map - * property - specifies colormap property name - * cnew - specifies a standard colormap - * replace - specifies whether to replace - */ -{ - register int i; - int count; - XStandardColormap *stdcmaps, *s; - Window win = RootWindow(dpy, screen); - - /* The property does not already exist */ - - if (!XGetRGBColormaps(dpy, win, &stdcmaps, &count, property)) { - if (cnew) - XSetRGBColormaps(dpy, win, cnew, 1, property); - return 0; - } - - /* The property exists and is not describing the RGB_DEFAULT_MAP */ - - if (property != XA_RGB_DEFAULT_MAP) { - if (replace) { - XmuDeleteStandardColormap(dpy, screen, property); - if (cnew) - XSetRGBColormaps(dpy, win, cnew, 1, property); - } - XFree((char *) stdcmaps); - return 1; - } - - /* The property exists and is RGB_DEFAULT_MAP */ - - for (i = 0, s = stdcmaps; (i < count) && (s->visualid != visualid); - i++, s++); - - /* No RGB_DEFAULT_MAP property matches the given visualid */ - - if (i == count) { - if (cnew) { - XStandardColormap *m, *maps; - - s = (XStandardColormap *) malloc((unsigned) ((count + 1) * sizeof - (XStandardColormap))); - - for (i = 0, m = s, maps = stdcmaps; i < count; i++, m++, maps++) { - m->colormap = maps->colormap; - m->red_max = maps->red_max; - m->red_mult = maps->red_mult; - m->green_max = maps->green_max; - m->green_mult = maps->green_mult; - m->blue_max = maps->blue_max; - m->blue_mult = maps->blue_mult; - m->base_pixel = maps->base_pixel; - m->visualid = maps->visualid; - m->killid = maps->killid; - } - m->colormap = cnew->colormap; - m->red_max = cnew->red_max; - m->red_mult = cnew->red_mult; - m->green_max = cnew->green_max; - m->green_mult = cnew->green_mult; - m->blue_max = cnew->blue_max; - m->blue_mult = cnew->blue_mult; - m->base_pixel = cnew->base_pixel; - m->visualid = cnew->visualid; - m->killid = cnew->killid; - - XSetRGBColormaps(dpy, win, s, ++count, property); - free((char *) s); - } - XFree((char *) stdcmaps); - return 0; - } - - /* Found an RGB_DEFAULT_MAP property with a matching visualid */ - - if (replace) { - /* Free old resources first - we may need them, particularly in - * the default colormap of the screen. However, because of this, - * it is possible that we will destroy the old resource and fail - * to create a new one if XmuStandardColormap() fails. - */ - - if (count == 1) { - XmuDeleteStandardColormap(dpy, screen, property); - if (cnew) - XSetRGBColormaps(dpy, win, cnew, 1, property); - } else { - XStandardColormap *map; - - /* s still points to the matching standard colormap */ - - if (s->killid == ReleaseByFreeingColormap) { - if ((s->colormap != None) && - (s->colormap != DefaultColormap(dpy, screen))) - XFreeColormap(dpy, s->colormap); - } else if (s->killid != None) - XKillClient(dpy, s->killid); - - map = (cnew) ? cnew : stdcmaps + --count; - - s->colormap = map->colormap; - s->red_max = map->red_max; - s->red_mult = map->red_mult; - s->green_max = map->green_max; - s->green_mult = map->green_mult; - s->blue_max = map->blue_max; - s->blue_mult = map->blue_mult; - s->visualid = map->visualid; - s->killid = map->killid; - - XSetRGBColormaps(dpy, win, stdcmaps, count, property); - } - } - XFree((char *) stdcmaps); - return 1; -} diff --git a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/StdCmap.c b/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/StdCmap.c deleted file mode 100644 index adfbaeda6..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/StdCmap.c +++ /dev/null @@ -1,236 +0,0 @@ -/* $Xorg: StdCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */ - -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/StdCmap.c,v 1.5 2001/01/17 19:42:56 dawes Exp $ */ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include -#include "../extensions/StdCmap.h" - -#define lowbit(x) ((x) & (~(x) + 1)) - -/* - * Prototypes - */ -/* argument restrictions */ -static Status valid_args(XVisualInfo *, unsigned long, unsigned long, - unsigned long, Atom); - -/* - * To create any one standard colormap, use XmuStandardColormap(). - * - * Create a standard colormap for the given screen, visualid, and visual - * depth, with the given red, green, and blue maximum values, with the - * given standard property name. Return a pointer to an XStandardColormap - * structure which describes the newly created colormap, upon success. - * Upon failure, return NULL. - * - * XmuStandardColormap() calls XmuCreateColormap() to create the map. - * - * Resources created by this function are not made permanent; that is the - * caller's responsibility. - */ - -XStandardColormap * -XmuStandardColormap(Display * dpy, int screen, VisualID visualid, - unsigned int depth, Atom property, Colormap cmap, - unsigned long red_max, unsigned long green_max, - unsigned long blue_max) - /* - * dpy - specifies X server connection - * screen - specifies display screen - * visualid - identifies the visual type - * depth - identifies the visual type - * property - a standard colormap property - * cmap - specifies colormap ID or None - * red_max, green_max, blue_max - allocations - */ -{ - XStandardColormap *stdcmap; - Status status; - XVisualInfo vinfo_template, *vinfo; - long vinfo_mask; - int n; - - /* Match the required visual information to an actual visual */ - vinfo_template.visualid = visualid; - vinfo_template.screen = screen; - vinfo_template.depth = depth; - vinfo_mask = VisualIDMask | VisualScreenMask | VisualDepthMask; - if ((vinfo = - XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) - return 0; - - /* Check the validity of the combination of visual characteristics, - * allocation, and colormap property. Create an XStandardColormap - * structure. - */ - - if (!valid_args(vinfo, red_max, green_max, blue_max, property) - || ((stdcmap = XAllocStandardColormap()) == NULL)) { - XFree((char *) vinfo); - return 0; - } - - /* Fill in the XStandardColormap structure */ - - if (cmap == DefaultColormap(dpy, screen)) { - /* Allocating out of the default map, cannot use XFreeColormap() */ - Window win = XCreateWindow(dpy, RootWindow(dpy, screen), 1, 1, 1, 1, - 0, 0, InputOnly, vinfo->visual, - (unsigned long) 0, - (XSetWindowAttributes *) NULL); - stdcmap->killid = (XID) XCreatePixmap(dpy, win, 1, 1, depth); - XDestroyWindow(dpy, win); - stdcmap->colormap = cmap; - } else { - stdcmap->killid = ReleaseByFreeingColormap; - stdcmap->colormap = XCreateColormap(dpy, RootWindow(dpy, screen), - vinfo->visual, AllocNone); - } - stdcmap->red_max = red_max; - stdcmap->green_max = green_max; - stdcmap->blue_max = blue_max; - if (property == XA_RGB_GRAY_MAP) - stdcmap->red_mult = stdcmap->green_mult = stdcmap->blue_mult = 1; - else if (vinfo->class == TrueColor || vinfo->class == DirectColor) { - stdcmap->red_mult = lowbit(vinfo->red_mask); - stdcmap->green_mult = lowbit(vinfo->green_mask); - stdcmap->blue_mult = lowbit(vinfo->blue_mask); - } else { - stdcmap->red_mult = (red_max > 0) - ? (green_max + 1) * (blue_max + 1) : 0; - stdcmap->green_mult = (green_max > 0) ? blue_max + 1 : 0; - stdcmap->blue_mult = (blue_max > 0) ? 1 : 0; - } - stdcmap->base_pixel = 0; /* base pixel may change */ - stdcmap->visualid = vinfo->visualid; - - /* Make the colormap */ - - status = XmuCreateColormap(dpy, stdcmap); - - /* Clean up */ - - XFree((char *) vinfo); - if (!status) { - - /* Free the colormap or the pixmap, if we created one */ - if (stdcmap->killid == ReleaseByFreeingColormap) - XFreeColormap(dpy, stdcmap->colormap); - else if (stdcmap->killid != None) - XFreePixmap(dpy, stdcmap->killid); - - XFree((char *) stdcmap); - return (XStandardColormap *) NULL; - } - return stdcmap; -} - -/****************************************************************************/ -static Status -valid_args(XVisualInfo * vinfo, unsigned long red_max, - unsigned long green_max, unsigned long blue_max, Atom property) - /* - * vinfo - specifies visual - * red_max, green_max, blue_max - specifies alloc - * property - specifies property name - */ -{ - unsigned long ncolors; /* number of colors requested */ - - /* Determine that the number of colors requested is <= map size */ - - if ((vinfo->class == DirectColor) || (vinfo->class == TrueColor)) { - unsigned long mask; - - mask = vinfo->red_mask; - while (!(mask & 1)) - mask >>= 1; - if (red_max > mask) - return 0; - mask = vinfo->green_mask; - while (!(mask & 1)) - mask >>= 1; - if (green_max > mask) - return 0; - mask = vinfo->blue_mask; - while (!(mask & 1)) - mask >>= 1; - if (blue_max > mask) - return 0; - } else if (property == XA_RGB_GRAY_MAP) { - ncolors = red_max + green_max + blue_max + 1; - if (ncolors > vinfo->colormap_size) - return 0; - } else { - ncolors = (red_max + 1) * (green_max + 1) * (blue_max + 1); - if (ncolors > vinfo->colormap_size) - return 0; - } - - /* Determine that the allocation and visual make sense for the property */ - - switch (property) { - case XA_RGB_DEFAULT_MAP: - if (red_max == 0 || green_max == 0 || blue_max == 0) - return 0; - break; - case XA_RGB_RED_MAP: - if (red_max == 0) - return 0; - break; - case XA_RGB_GREEN_MAP: - if (green_max == 0) - return 0; - break; - case XA_RGB_BLUE_MAP: - if (blue_max == 0) - return 0; - break; - case XA_RGB_BEST_MAP: - if (red_max == 0 || green_max == 0 || blue_max == 0) - return 0; - break; - case XA_RGB_GRAY_MAP: - if (red_max == 0 || blue_max == 0 || green_max == 0) - return 0; - break; - default: - return 0; - } - return 1; -} diff --git a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/VisCmap.c b/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/VisCmap.c deleted file mode 100644 index 0cf11516a..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/XmuStdCmap/VisCmap.c +++ /dev/null @@ -1,184 +0,0 @@ -/* $Xorg: VisCmap.c,v 1.4 2001/02/09 02:03:53 xorgcvs Exp $ */ - -/* - -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/VisCmap.c,v 1.6 2001/01/17 19:42:57 dawes Exp $ */ - -/* - * Author: Donna Converse, MIT X Consortium - */ - -#ifdef HAVE_CONFIG_H -#include -#endif -#include -#include -#include -#include -#include -#include "../extensions/StdCmap.h" - -/* - * To create all of the appropriate standard colormaps for a given visual on - * a given screen, use XmuVisualStandardColormaps. - * - * Define all appropriate standard colormap properties for the given visual. - * If replace is true, any previous definition will be removed. - * If retain is true, new properties will be retained for the duration of - * the server session. Return 0 on failure, non-zero on success. - * On failure, no new properties will be defined, and, old ones may have - * been removed if replace was True. - * - * Not all standard colormaps are meaningful to all visual classes. This - * routine will check and define the following properties for the following - * classes, provided that the size of the colormap is not too small. - * - * DirectColor and PseudoColor - * RGB_DEFAULT_MAP - * RGB_BEST_MAP - * RGB_RED_MAP - * RGB_GREEN_MAP - * RGB_BLUE_MAP - * RGB_GRAY_MAP - * - * TrueColor and StaticColor - * RGB_BEST_MAP - * - * GrayScale and StaticGray - * RGB_GRAY_MAP - */ - -Status -XmuVisualStandardColormaps(Display * dpy, int screen, VisualID visualid, - unsigned int depth, Bool replace, Bool retain) - /* - * dpy - specifies server connection - * screen - specifies screen number - * visualid - specifies the visual - * depth - specifies the visual - * replace specifies - whether to replace - * retain - specifies whether to retain - */ -{ - Status status; - int n; - long vinfo_mask; - XVisualInfo vinfo_template, *vinfo; - - status = 0; - vinfo_template.screen = screen; - vinfo_template.visualid = visualid; - vinfo_template.depth = depth; - vinfo_mask = VisualScreenMask | VisualIDMask | VisualDepthMask; - if ((vinfo = - XGetVisualInfo(dpy, vinfo_mask, &vinfo_template, &n)) == NULL) - return 0; - - if (vinfo->colormap_size <= 2) { - /* Monochrome visuals have no standard maps; considered successful */ - XFree((char *) vinfo); - return 1; - } - - switch (vinfo->class) { - case PseudoColor: - case DirectColor: - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_DEFAULT_MAP, replace, - retain); - if (!status) - break; - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_GRAY_MAP, replace, retain); - if (!status) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - break; - } - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_RED_MAP, replace, retain); - if (!status) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); - break; - } - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_GREEN_MAP, replace, retain); - if (!status) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); - break; - } - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_BLUE_MAP, replace, retain); - if (!status) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP); - break; - } - /* fall through */ - - case StaticColor: - case TrueColor: - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_BEST_MAP, replace, retain); - if (!status && (vinfo->class == PseudoColor || - vinfo->class == DirectColor)) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GRAY_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_RED_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_GREEN_MAP); - XmuDeleteStandardColormap(dpy, screen, XA_RGB_BLUE_MAP); - } - break; - /* the end for PseudoColor, DirectColor, StaticColor, and TrueColor */ - - case GrayScale: - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_DEFAULT_MAP, replace, - retain); - if (!status) - break; - /*FALLTHROUGH*/ case StaticGray: - - status = XmuLookupStandardColormap(dpy, screen, visualid, depth, - XA_RGB_GRAY_MAP, replace, retain); - if (!status && vinfo->class == GrayScale) { - XmuDeleteStandardColormap(dpy, screen, XA_RGB_DEFAULT_MAP); - break; - } - } - - XFree((char *) vinfo); - return status; -} diff --git a/project/jni/sdl-1.3/src/video/Xext/Xv/Xv.c b/project/jni/sdl-1.3/src/video/Xext/Xv/Xv.c deleted file mode 100644 index e7319e96e..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/Xv/Xv.c +++ /dev/null @@ -1,1097 +0,0 @@ -/*********************************************************** -Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, -and the Massachusetts Institute of Technology, Cambridge, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Digital or MIT not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* $XFree86: xc/lib/Xv/Xv.c,v 1.15 2001/05/11 08:23:22 alanh Exp $ */ -/* -** File: -** -** Xv.c --- Xv library extension module. -** -** Author: -** -** David Carver (Digital Workstation Engineering/Project Athena) -** -** Revisions: -** -** 26.06.91 Carver -** - changed XvFreeAdaptors to XvFreeAdaptorInfo -** - changed XvFreeEncodings to XvFreeEncodingInfo -** -** 11.06.91 Carver -** - changed SetPortControl to SetPortAttribute -** - changed GetPortControl to GetPortAttribute -** - changed QueryBestSize -** -** 15.05.91 Carver -** - version 2.0 upgrade -** -** 240.01.91 Carver -** - version 1.4 upgrade -** -*/ - -#include -#include "Xvlibint.h" -#include "../extensions/Xext.h" -#include -#include "../extensions/extutil.h" - -static XExtensionInfo _xv_info_data; -static XExtensionInfo *xv_info = &_xv_info_data; -static char *xv_extension_name = XvName; - -#define XvCheckExtension(dpy, i, val) \ - XextCheckExtension(dpy, i, xv_extension_name, val) - -static char *xv_error_string(); -static int xv_close_display(); -static Bool xv_wire_to_event(); - -static XExtensionHooks xv_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - xv_close_display, /* close_display */ - xv_wire_to_event, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - xv_error_string /* error_string */ -}; - - -static char *xv_error_list[] = { - "BadPort", /* XvBadPort */ - "BadEncoding", /* XvBadEncoding */ - "BadControl" /* XvBadControl */ -}; - -static -XEXT_GENERATE_CLOSE_DISPLAY(xv_close_display, xv_info) - static XEXT_GENERATE_FIND_DISPLAY(xv_find_display, xv_info, - xv_extension_name, - &xv_extension_hooks, XvNumEvents, NULL) - static XEXT_GENERATE_ERROR_STRING(xv_error_string, xv_extension_name, - XvNumErrors, xv_error_list) - int SDL_NAME(XvQueryExtension) (Display * dpy, - unsigned int *p_version, - unsigned int *p_revision, - unsigned int *p_requestBase, - unsigned int *p_eventBase, - unsigned int *p_errorBase) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvQueryExtensionReq *req; - xvQueryExtensionReply rep; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(QueryExtension, req); - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return XvBadExtension; - } - - *p_version = rep.version; - *p_revision = rep.revision; - *p_requestBase = info->codes->major_opcode; - *p_eventBase = info->codes->first_event; - *p_errorBase = info->codes->first_error; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int -SDL_NAME(XvQueryAdaptors) (Display * dpy, - Window window, - unsigned int *p_nAdaptors, - SDL_NAME(XvAdaptorInfo) ** p_pAdaptors) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvQueryAdaptorsReq *req; - xvQueryAdaptorsReply rep; - int size, ii, jj; - char *name; - SDL_NAME(XvAdaptorInfo) * pas, *pa; - SDL_NAME(XvFormat) * pfs, *pf; - char *buffer; - union - { - char *buffer; - char *string; - xvAdaptorInfo *pa; - xvFormat *pf; - } u; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(QueryAdaptors, req); - req->window = window; - - /* READ THE REPLY */ - - if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadReply); - } - - size = rep.length << 2; - if ((buffer = (char *) Xmalloc((unsigned) size)) == NULL) { - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadAlloc); - } - _XRead(dpy, buffer, size); - - u.buffer = buffer; - - /* GET INPUT ADAPTORS */ - - if (rep.num_adaptors == 0) { - pas = NULL; - } else { - size = rep.num_adaptors * sizeof(SDL_NAME(XvAdaptorInfo)); - if ((pas = (SDL_NAME(XvAdaptorInfo) *) Xmalloc(size)) == NULL) { - Xfree(buffer); - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadAlloc); - } - } - - /* INIT ADAPTOR FIELDS */ - - pa = pas; - for (ii = 0; ii < rep.num_adaptors; ii++) { - pa->num_adaptors = 0; - pa->name = (char *) NULL; - pa->formats = (SDL_NAME(XvFormat) *) NULL; - pa++; - } - - pa = pas; - for (ii = 0; ii < rep.num_adaptors; ii++) { - pa->type = u.pa->type; - pa->base_id = u.pa->base_id; - pa->num_ports = u.pa->num_ports; - pa->num_formats = u.pa->num_formats; - pa->num_adaptors = rep.num_adaptors - ii; - - /* GET ADAPTOR NAME */ - - size = u.pa->name_size; - u.buffer += (sz_xvAdaptorInfo + 3) & ~3; - - if ((name = (char *) Xmalloc(size + 1)) == NULL) { - SDL_NAME(XvFreeAdaptorInfo) (pas); - Xfree(buffer); - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadAlloc); - } - SDL_strlcpy(name, u.string, size); - pa->name = name; - - u.buffer += (size + 3) & ~3; - - /* GET FORMATS */ - - size = pa->num_formats * sizeof(SDL_NAME(XvFormat)); - if ((pfs = (SDL_NAME(XvFormat) *) Xmalloc(size)) == NULL) { - SDL_NAME(XvFreeAdaptorInfo) (pas); - Xfree(buffer); - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadAlloc); - } - - pf = pfs; - for (jj = 0; jj < pa->num_formats; jj++) { - pf->depth = u.pf->depth; - pf->visual_id = u.pf->visual; - pf++; - - u.buffer += (sz_xvFormat + 3) & ~3; - } - - pa->formats = pfs; - - pa++; - - } - - *p_nAdaptors = rep.num_adaptors; - *p_pAdaptors = pas; - - Xfree(buffer); - UnlockDisplay(dpy); - SyncHandle(); - - return (Success); -} - - -void SDL_NAME(XvFreeAdaptorInfo) (SDL_NAME(XvAdaptorInfo) * pAdaptors) -{ - - SDL_NAME(XvAdaptorInfo) * pa; - int ii; - - if (!pAdaptors) - return; - - pa = pAdaptors; - - for (ii = 0; ii < pAdaptors->num_adaptors; ii++, pa++) { - if (pa->name) { - Xfree(pa->name); - } - if (pa->formats) { - Xfree(pa->formats); - } - } - - Xfree(pAdaptors); -} - -int -SDL_NAME(XvQueryEncodings) (Display * dpy, - XvPortID port, - unsigned int *p_nEncodings, - SDL_NAME(XvEncodingInfo) ** p_pEncodings) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvQueryEncodingsReq *req; - xvQueryEncodingsReply rep; - int size, jj; - char *name; - SDL_NAME(XvEncodingInfo) * pes, *pe; - char *buffer; - union - { - char *buffer; - char *string; - xvEncodingInfo *pe; - } u; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(QueryEncodings, req); - req->port = port; - - /* READ THE REPLY */ - - if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadReply); - } - - size = rep.length << 2; - if ((buffer = (char *) Xmalloc((unsigned) size)) == NULL) { - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadAlloc); - } - _XRead(dpy, buffer, size); - - u.buffer = buffer; - - /* GET ENCODINGS */ - - size = rep.num_encodings * sizeof(SDL_NAME(XvEncodingInfo)); - if ((pes = (SDL_NAME(XvEncodingInfo) *) Xmalloc(size)) == NULL) { - Xfree(buffer); - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadAlloc); - } - - /* INITIALIZE THE ENCODING POINTER */ - - pe = pes; - for (jj = 0; jj < rep.num_encodings; jj++) { - pe->name = (char *) NULL; - pe->num_encodings = 0; - pe++; - } - - pe = pes; - for (jj = 0; jj < rep.num_encodings; jj++) { - pe->encoding_id = u.pe->encoding; - pe->width = u.pe->width; - pe->height = u.pe->height; - pe->rate.numerator = u.pe->rate.numerator; - pe->rate.denominator = u.pe->rate.denominator; - pe->num_encodings = rep.num_encodings - jj; - - size = u.pe->name_size; - u.buffer += (sz_xvEncodingInfo + 3) & ~3; - - if ((name = (char *) Xmalloc(size + 1)) == NULL) { - Xfree(buffer); - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadAlloc); - } - SDL_strlcpy(name, u.string, size); - pe->name = name; - pe++; - - u.buffer += (size + 3) & ~3; - } - - *p_nEncodings = rep.num_encodings; - *p_pEncodings = pes; - - Xfree(buffer); - UnlockDisplay(dpy); - SyncHandle(); - - return (Success); -} - -void SDL_NAME(XvFreeEncodingInfo) (SDL_NAME(XvEncodingInfo) * pEncodings) -{ - - SDL_NAME(XvEncodingInfo) * pe; - int ii; - - if (!pEncodings) - return; - - pe = pEncodings; - - for (ii = 0; ii < pEncodings->num_encodings; ii++, pe++) { - if (pe->name) - Xfree(pe->name); - } - - Xfree(pEncodings); -} - -int -SDL_NAME(XvPutVideo) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - int vx, int vy, - unsigned int vw, unsigned int vh, - int dx, int dy, unsigned int dw, unsigned int dh) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvPutVideoReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - FlushGC(dpy, gc); - - XvGetReq(PutVideo, req); - - req->port = port; - req->drawable = d; - req->gc = gc->gid; - req->vid_x = vx; - req->vid_y = vy; - req->vid_w = vw; - req->vid_h = vh; - req->drw_x = dx; - req->drw_y = dy; - req->drw_w = dw; - req->drw_h = dh; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int -SDL_NAME(XvPutStill) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - int vx, int vy, - unsigned int vw, unsigned int vh, - int dx, int dy, unsigned int dw, unsigned int dh) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvPutStillReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - FlushGC(dpy, gc); - - XvGetReq(PutStill, req); - req->port = port; - req->drawable = d; - req->gc = gc->gid; - req->vid_x = vx; - req->vid_y = vy; - req->vid_w = vw; - req->vid_h = vh; - req->drw_x = dx; - req->drw_y = dy; - req->drw_w = dw; - req->drw_h = dh; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int -SDL_NAME(XvGetVideo) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - int vx, int vy, - unsigned int vw, unsigned int vh, - int dx, int dy, unsigned int dw, unsigned int dh) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvGetVideoReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - FlushGC(dpy, gc); - - XvGetReq(GetVideo, req); - req->port = port; - req->drawable = d; - req->gc = gc->gid; - req->vid_x = vx; - req->vid_y = vy; - req->vid_w = vw; - req->vid_h = vh; - req->drw_x = dx; - req->drw_y = dy; - req->drw_w = dw; - req->drw_h = dh; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int -SDL_NAME(XvGetStill) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - int vx, int vy, - unsigned int vw, unsigned int vh, - int dx, int dy, unsigned int dw, unsigned int dh) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvGetStillReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - FlushGC(dpy, gc); - - XvGetReq(GetStill, req); - req->port = port; - req->drawable = d; - req->gc = gc->gid; - req->vid_x = vx; - req->vid_y = vy; - req->vid_w = vw; - req->vid_h = vh; - req->drw_x = dx; - req->drw_y = dy; - req->drw_w = dw; - req->drw_h = dh; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int SDL_NAME(XvStopVideo) (Display * dpy, XvPortID port, Drawable draw) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvStopVideoReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(StopVideo, req); - req->port = port; - req->drawable = draw; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int SDL_NAME(XvGrabPort) (Display * dpy, XvPortID port, Time time) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - int result; - xvGrabPortReply rep; - xvGrabPortReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(GrabPort, req); - req->port = port; - req->time = time; - - if (_XReply(dpy, (xReply *) & rep, 0, xTrue) == 0) - rep.result = GrabSuccess; - - result = rep.result; - - UnlockDisplay(dpy); - SyncHandle(); - - return result; -} - -int SDL_NAME(XvUngrabPort) (Display * dpy, XvPortID port, Time time) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvUngrabPortReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(UngrabPort, req); - req->port = port; - req->time = time; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int -SDL_NAME(XvSelectVideoNotify) (Display * dpy, Drawable drawable, Bool onoff) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvSelectVideoNotifyReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(SelectVideoNotify, req); - req->drawable = drawable; - req->onoff = onoff; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int SDL_NAME(XvSelectPortNotify) (Display * dpy, XvPortID port, Bool onoff) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvSelectPortNotifyReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(SelectPortNotify, req); - req->port = port; - req->onoff = onoff; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int -SDL_NAME(XvSetPortAttribute) (Display * dpy, - XvPortID port, Atom attribute, int value) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvSetPortAttributeReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(SetPortAttribute, req); - req->port = port; - req->attribute = attribute; - req->value = value; - - UnlockDisplay(dpy); - SyncHandle(); - - return (Success); -} - -int -SDL_NAME(XvGetPortAttribute) (Display * dpy, - XvPortID port, Atom attribute, int *p_value) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvGetPortAttributeReq *req; - xvGetPortAttributeReply rep; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(GetPortAttribute, req); - req->port = port; - req->attribute = attribute; - - /* READ THE REPLY */ - - if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadReply); - } - - *p_value = rep.value; - - UnlockDisplay(dpy); - SyncHandle(); - - return (Success); -} - -int -SDL_NAME(XvQueryBestSize) (Display * dpy, - XvPortID port, - Bool motion, - unsigned int vid_w, - unsigned int vid_h, - unsigned int drw_w, - unsigned int drw_h, - unsigned int *p_actual_width, - unsigned int *p_actual_height) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvQueryBestSizeReq *req; - xvQueryBestSizeReply rep; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - XvGetReq(QueryBestSize, req); - req->port = port; - req->motion = motion; - req->vid_w = vid_w; - req->vid_h = vid_h; - req->drw_w = drw_w; - req->drw_h = drw_h; - - /* READ THE REPLY */ - - if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return (XvBadReply); - } - - *p_actual_width = rep.actual_width; - *p_actual_height = rep.actual_height; - - UnlockDisplay(dpy); - SyncHandle(); - - return (Success); -} - - -SDL_NAME(XvAttribute) * -SDL_NAME(XvQueryPortAttributes) (Display * dpy, XvPortID port, int *num) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvQueryPortAttributesReq *req; - xvQueryPortAttributesReply rep; - SDL_NAME(XvAttribute) * ret = NULL; - - *num = 0; - - XvCheckExtension(dpy, info, NULL); - - LockDisplay(dpy); - - XvGetReq(QueryPortAttributes, req); - req->port = port; - - /* READ THE REPLY */ - - if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return ret; - } - - if (rep.num_attributes) { - int size = - (rep.num_attributes * sizeof(SDL_NAME(XvAttribute))) + - rep.text_size; - - if ((ret = Xmalloc(size))) { - char *marker = (char *) (&ret[rep.num_attributes]); - xvAttributeInfo Info; - int i; - - for (i = 0; i < rep.num_attributes; i++) { - _XRead(dpy, (char *) (&Info), sz_xvAttributeInfo); - ret[i].flags = (int) Info.flags; - ret[i].min_value = Info.min; - ret[i].max_value = Info.max; - ret[i].name = marker; - _XRead(dpy, marker, Info.size); - marker += Info.size; - (*num)++; - } - } else - _XEatData(dpy, rep.length << 2); - } - - UnlockDisplay(dpy); - SyncHandle(); - - return ret; -} - -SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) (Display * dpy, - XvPortID port, - int *num) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvListImageFormatsReq *req; - xvListImageFormatsReply rep; - SDL_NAME(XvImageFormatValues) * ret = NULL; - - *num = 0; - - XvCheckExtension(dpy, info, NULL); - - LockDisplay(dpy); - - XvGetReq(ListImageFormats, req); - req->port = port; - - /* READ THE REPLY */ - - if (_XReply(dpy, (xReply *) & rep, 0, xFalse) == 0) { - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - if (rep.num_formats) { - int size = (rep.num_formats * sizeof(SDL_NAME(XvImageFormatValues))); - - if ((ret = Xmalloc(size))) { - xvImageFormatInfo Info; - int i; - - for (i = 0; i < rep.num_formats; i++) { - _XRead(dpy, (char *) (&Info), sz_xvImageFormatInfo); - ret[i].id = Info.id; - ret[i].type = Info.type; - ret[i].byte_order = Info.byte_order; - memcpy(&(ret[i].guid[0]), &(Info.guid[0]), 16); - ret[i].bits_per_pixel = Info.bpp; - ret[i].format = Info.format; - ret[i].num_planes = Info.num_planes; - ret[i].depth = Info.depth; - ret[i].red_mask = Info.red_mask; - ret[i].green_mask = Info.green_mask; - ret[i].blue_mask = Info.blue_mask; - ret[i].y_sample_bits = Info.y_sample_bits; - ret[i].u_sample_bits = Info.u_sample_bits; - ret[i].v_sample_bits = Info.v_sample_bits; - ret[i].horz_y_period = Info.horz_y_period; - ret[i].horz_u_period = Info.horz_u_period; - ret[i].horz_v_period = Info.horz_v_period; - ret[i].vert_y_period = Info.vert_y_period; - ret[i].vert_u_period = Info.vert_u_period; - ret[i].vert_v_period = Info.vert_v_period; - memcpy(&(ret[i].component_order[0]), - &(Info.comp_order[0]), 32); - ret[i].scanline_order = Info.scanline_order; - (*num)++; - } - } else - _XEatData(dpy, rep.length << 2); - } - - UnlockDisplay(dpy); - SyncHandle(); - - return ret; -} - -SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) (Display * dpy, - XvPortID port, - int id, - char *data, - int width, int height) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvQueryImageAttributesReq *req; - xvQueryImageAttributesReply rep; - SDL_NAME(XvImage) * ret = NULL; - - XvCheckExtension(dpy, info, NULL); - - LockDisplay(dpy); - - XvGetReq(QueryImageAttributes, req); - req->id = id; - req->port = port; - req->width = width; - req->height = height; - - /* READ THE REPLY */ - - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return NULL; - } - - if ((ret = - (SDL_NAME(XvImage) *) Xmalloc(sizeof(SDL_NAME(XvImage)) + - (rep.num_planes << 3)))) { - ret->id = id; - ret->width = rep.width; - ret->height = rep.height; - ret->data_size = rep.data_size; - ret->num_planes = rep.num_planes; - ret->pitches = (int *) (&ret[1]); - ret->offsets = ret->pitches + rep.num_planes; - ret->data = data; - ret->obdata = NULL; - _XRead(dpy, (char *) (ret->pitches), rep.num_planes << 2); - _XRead(dpy, (char *) (ret->offsets), rep.num_planes << 2); - } else - _XEatData(dpy, rep.length << 2); - - UnlockDisplay(dpy); - SyncHandle(); - return ret; -} - -SDL_NAME(XvImage) * SDL_NAME(XvShmCreateImage) (Display * dpy, - XvPortID port, - int id, - char *data, - int width, - int height, - XShmSegmentInfo * shminfo) -{ - SDL_NAME(XvImage) * ret; - - ret = SDL_NAME(XvCreateImage) (dpy, port, id, data, width, height); - - if (ret) - ret->obdata = (XPointer) shminfo; - - return ret; -} - -int SDL_NAME(XvPutImage) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - SDL_NAME(XvImage) * image, - int src_x, - int src_y, - unsigned int src_w, - unsigned int src_h, - int dest_x, - int dest_y, - unsigned int dest_w, unsigned int dest_h) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - xvPutImageReq *req; - int len; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - FlushGC(dpy, gc); - - XvGetReq(PutImage, req); - - req->port = port; - req->drawable = d; - req->gc = gc->gid; - req->id = image->id; - req->src_x = src_x; - req->src_y = src_y; - req->src_w = src_w; - req->src_h = src_h; - req->drw_x = dest_x; - req->drw_y = dest_y; - req->drw_w = dest_w; - req->drw_h = dest_h; - req->width = image->width; - req->height = image->height; - - len = (image->data_size + 3) >> 2; - SetReqLen(req, len, len); - - /* Yes it's kindof lame that we are sending the whole thing, - but for video all of it may be needed even if displaying - only a subsection, and I don't want to go through the - trouble of creating subregions to send */ - Data(dpy, (char *) image->data, image->data_size); - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - -int SDL_NAME(XvShmPutImage) (Display * dpy, - XvPortID port, - Drawable d, - GC gc, - SDL_NAME(XvImage) * image, - int src_x, - int src_y, - unsigned int src_w, - unsigned int src_h, - int dest_x, - int dest_y, - unsigned int dest_w, - unsigned int dest_h, Bool send_event) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - XShmSegmentInfo *shminfo = (XShmSegmentInfo *) image->obdata; - xvShmPutImageReq *req; - - XvCheckExtension(dpy, info, XvBadExtension); - - LockDisplay(dpy); - - FlushGC(dpy, gc); - - XvGetReq(ShmPutImage, req); - - req->port = port; - req->drawable = d; - req->gc = gc->gid; - req->shmseg = shminfo->shmseg; - req->id = image->id; - req->src_x = src_x; - req->src_y = src_y; - req->src_w = src_w; - req->src_h = src_h; - req->drw_x = dest_x; - req->drw_y = dest_y; - req->drw_w = dest_w; - req->drw_h = dest_h; - req->offset = image->data - shminfo->shmaddr; - req->width = image->width; - req->height = image->height; - req->send_event = send_event; - - UnlockDisplay(dpy); - SyncHandle(); - - return Success; -} - - -static Bool -xv_wire_to_event(Display * dpy, XEvent * host, xEvent * wire) -{ - XExtDisplayInfo *info = xv_find_display(dpy); - SDL_NAME(XvEvent) * re = (SDL_NAME(XvEvent) *) host; - xvEvent *event = (xvEvent *) wire; - - XvCheckExtension(dpy, info, False); - - switch ((event->u.u.type & 0x7F) - info->codes->first_event) { - case XvVideoNotify: - re->xvvideo.type = event->u.u.type & 0x7f; - re->xvvideo.serial = - _XSetLastRequestRead(dpy, (xGenericReply *) event); - re->xvvideo.send_event = ((event->u.u.type & 0x80) != 0); - re->xvvideo.display = dpy; - re->xvvideo.time = event->u.videoNotify.time; - re->xvvideo.reason = event->u.videoNotify.reason; - re->xvvideo.drawable = event->u.videoNotify.drawable; - re->xvvideo.port_id = event->u.videoNotify.port; - break; - case XvPortNotify: - re->xvport.type = event->u.u.type & 0x7f; - re->xvport.serial = - _XSetLastRequestRead(dpy, (xGenericReply *) event); - re->xvport.send_event = ((event->u.u.type & 0x80) != 0); - re->xvport.display = dpy; - re->xvport.time = event->u.portNotify.time; - re->xvport.port_id = event->u.portNotify.port; - re->xvport.attribute = event->u.portNotify.attribute; - re->xvport.value = event->u.portNotify.value; - break; - default: - return False; - } - - return (True); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/Xv/Xvlibint.h b/project/jni/sdl-1.3/src/video/Xext/Xv/Xvlibint.h deleted file mode 100644 index bfe40da11..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/Xv/Xvlibint.h +++ /dev/null @@ -1,82 +0,0 @@ -/*********************************************************** -Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, -and the Massachusetts Institute of Technology, Cambridge, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Digital or MIT not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* $XFree86: xc/lib/Xv/Xvlibint.h,v 1.5 2001/07/25 15:04:53 dawes Exp $ */ - -#ifndef XVLIBINT_H -#define XVLIBINT_H -/* -** File: -** -** Xvlibint.h --- Xv library internal header file -** -** Author: -** -** David Carver (Digital Workstation Engineering/Project Athena) -** -** Revisions: -** -** 01.24.91 Carver -** - version 1.4 upgrade -** -*/ - -#define NEED_REPLIES - -/* Apparently some X11 systems can't include this multiple times... */ -#ifndef SDL_INCLUDED_XLIBINT_H -#define SDL_INCLUDED_XLIBINT_H 1 -#include -#endif - -#include "../extensions/Xvproto.h" -#include "../extensions/Xvlib.h" - -#if !defined(UNIXCPP) -#define XvGetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xv##name##Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xv##name##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = info->codes->major_opcode;\ - req->xvReqType = xv_##name; \ - req->length = (SIZEOF(xv##name##Req))>>2;\ - dpy->bufptr += SIZEOF(xv##name##Req);\ - dpy->request++ - -#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ -#define XvGetReq(name, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(xv/**/name/**/Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (xv/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = info->codes->major_opcode;\ - req->xvReqType = xv_/**/name;\ - req->length = (SIZEOF(xv/**/name/**/Req))>>2;\ - dpy->bufptr += SIZEOF(xv/**/name/**/Req);\ - dpy->request++ -#endif - - -#endif /* XVLIBINT_H */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/Xxf86vm/XF86VMode.c b/project/jni/sdl-1.3/src/video/Xext/Xxf86vm/XF86VMode.c deleted file mode 100644 index e4a6e2b44..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/Xxf86vm/XF86VMode.c +++ /dev/null @@ -1,1263 +0,0 @@ -/* $XConsortium: XF86VMode.c /main/2 1995/11/14 18:17:58 kaleb $ */ -/* $XFree86: xc/lib/Xxf86vm/XF86VMode.c,v 3.32 2001/07/25 15:04:54 dawes Exp $ */ -/* - -Copyright (c) 1995 Kaleb S. KEITHLEY - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Kaleb S. KEITHLEY -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -from Kaleb S. KEITHLEY. - -*/ -/* $XConsortium: XF86VMode.c /main/4 1996/01/16 07:52:25 kaleb CHECKEDOUT $ */ - -/* THIS IS NOT AN X CONSORTIUM STANDARD */ - -#define NEED_EVENTS -#define NEED_REPLIES - -#ifndef XBUILD_IN_CLIENT - -/* Apparently some X11 systems can't include this multiple times... */ -#ifndef SDL_INCLUDED_XLIBINT_H -#define SDL_INCLUDED_XLIBINT_H 1 -#include -#endif - -#include "../extensions/xf86vmstr.h" -#include "../extensions/Xext.h" -#include "../extensions/extutil.h" -#else -#include "include/extensions/xf86vmstr.h" -#include "include/extensions/Xext.h" -#include "include/extensions/extutil.h" -#endif - -#ifdef DEBUG -#include -#endif - -#ifndef MODE_BAD -#define MODE_BAD 255 -#endif - -static XExtensionInfo _xf86vidmode_info_data; -static XExtensionInfo *xf86vidmode_info = &_xf86vidmode_info_data; -static char *xf86vidmode_extension_name = XF86VIDMODENAME; - -#define XF86VidModeCheckExtension(dpy,i,val) \ - XextCheckExtension (dpy, i, xf86vidmode_extension_name, val) - -/***************************************************************************** - * * - * private utility routines * - * * - *****************************************************************************/ - -static XEXT_CLOSE_DISPLAY_PROTO(close_display); -static /* const */ XExtensionHooks xf86vidmode_extension_hooks = { - NULL, /* create_gc */ - NULL, /* copy_gc */ - NULL, /* flush_gc */ - NULL, /* free_gc */ - NULL, /* create_font */ - NULL, /* free_font */ - close_display, /* close_display */ - NULL, /* wire_to_event */ - NULL, /* event_to_wire */ - NULL, /* error */ - NULL, /* error_string */ -}; - -static -XEXT_GENERATE_FIND_DISPLAY(find_display, xf86vidmode_info, - xf86vidmode_extension_name, - &xf86vidmode_extension_hooks, 0, NULL) - static XEXT_GENERATE_CLOSE_DISPLAY(close_display, xf86vidmode_info) -/***************************************************************************** - * * - * public XFree86-VidMode Extension routines * - * * - *****************************************************************************/ - Bool -SDL_NAME(XF86VidModeQueryExtension) (dpy, event_basep, error_basep) - Display *dpy; - int *event_basep, *error_basep; -{ - XExtDisplayInfo *info = find_display(dpy); - - if (XextHasExtension(info)) { - *event_basep = info->codes->first_event; - *error_basep = info->codes->first_error; - return True; - } else { - return False; - } -} - -Bool SDL_NAME(XF86VidModeQueryVersion) (dpy, majorVersion, minorVersion) - Display * - dpy; - int * - majorVersion; - int * - minorVersion; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeQueryVersionReply rep; - xXF86VidModeQueryVersionReq *req; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeQueryVersion, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeQueryVersion; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *majorVersion = rep.majorVersion; - *minorVersion = rep.minorVersion; - UnlockDisplay(dpy); - SyncHandle(); - if (*majorVersion >= 2) - SDL_NAME(XF86VidModeSetClientVersion) (dpy); - return True; -} - -Bool SDL_NAME(XF86VidModeSetClientVersion) (Display * dpy) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeSetClientVersionReq *req; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeSetClientVersion, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeSetClientVersion; - req->major = XF86VIDMODE_MAJOR_VERSION; - req->minor = XF86VIDMODE_MINOR_VERSION; - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool -SDL_NAME(XF86VidModeSetGamma) (Display * dpy, int screen, - SDL_NAME(XF86VidModeGamma) * Gamma) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeSetGammaReq *req; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeSetGamma, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeSetGamma; - req->screen = screen; - req->red = (CARD32) (Gamma->red * 10000.); - req->green = (CARD32) (Gamma->green * 10000.); - req->blue = (CARD32) (Gamma->blue * 10000.); - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool -SDL_NAME(XF86VidModeGetGamma) (Display * dpy, int screen, - SDL_NAME(XF86VidModeGamma) * Gamma) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeGetGammaReply rep; - xXF86VidModeGetGammaReq *req; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeGetGamma, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeGetGamma; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - Gamma->red = ((float) rep.red) / 10000.; - Gamma->green = ((float) rep.green) / 10000.; - Gamma->blue = ((float) rep.blue) / 10000.; - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeGetModeLine) (dpy, screen, dotclock, modeline) - Display * - dpy; - int - screen; - int * - dotclock; -SDL_NAME(XF86VidModeModeLine) * modeline; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeGetModeLineReply rep; - xXF86OldVidModeGetModeLineReply oldrep; - xXF86VidModeGetModeLineReq *req; - int majorVersion, minorVersion; - - XF86VidModeCheckExtension(dpy, info, False); - SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - - LockDisplay(dpy); - GetReq(XF86VidModeGetModeLine, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeGetModeLine; - req->screen = screen; - - if (majorVersion < 2) { - if (!_XReply(dpy, (xReply *) & oldrep, - (SIZEOF(xXF86OldVidModeGetModeLineReply) - - SIZEOF(xReply)) >> 2, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *dotclock = oldrep.dotclock; - modeline->hdisplay = oldrep.hdisplay; - modeline->hsyncstart = oldrep.hsyncstart; - modeline->hsyncend = oldrep.hsyncend; - modeline->htotal = oldrep.htotal; - modeline->hskew = 0; - modeline->vdisplay = oldrep.vdisplay; - modeline->vsyncstart = oldrep.vsyncstart; - modeline->vsyncend = oldrep.vsyncend; - modeline->vtotal = oldrep.vtotal; - modeline->flags = oldrep.flags; - modeline->privsize = oldrep.privsize; - } else { - if (!_XReply(dpy, (xReply *) & rep, - (SIZEOF(xXF86VidModeGetModeLineReply) - - SIZEOF(xReply)) >> 2, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *dotclock = rep.dotclock; - modeline->hdisplay = rep.hdisplay; - modeline->hsyncstart = rep.hsyncstart; - modeline->hsyncend = rep.hsyncend; - modeline->htotal = rep.htotal; - modeline->hskew = rep.hskew; - modeline->vdisplay = rep.vdisplay; - modeline->vsyncstart = rep.vsyncstart; - modeline->vsyncend = rep.vsyncend; - modeline->vtotal = rep.vtotal; - modeline->flags = rep.flags; - modeline->privsize = rep.privsize; - } - - if (modeline->privsize > 0) { - if (!(modeline->private = Xcalloc(modeline->privsize, sizeof(INT32)))) { - _XEatData(dpy, (modeline->privsize) * sizeof(INT32)); - Xfree(modeline->private); - return False; - } - _XRead(dpy, (char *) modeline->private, - modeline->privsize * sizeof(INT32)); - } else { - modeline->private = NULL; - } - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool -SDL_NAME(XF86VidModeGetAllModeLines) (dpy, screen, modecount, modelinesPtr) - Display *dpy; - int screen; - int *modecount; -SDL_NAME(XF86VidModeModeInfo) *** modelinesPtr; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeGetAllModeLinesReply rep; - xXF86VidModeGetAllModeLinesReq *req; - SDL_NAME(XF86VidModeModeInfo) * mdinfptr, **modelines; - xXF86VidModeModeInfo xmdline; - xXF86OldVidModeModeInfo oldxmdline; - int i; - int majorVersion, minorVersion; - Bool protocolBug = False; - - XF86VidModeCheckExtension(dpy, info, False); - - /* - * Note: There was a bug in the protocol implementation in versions - * 0.x with x < 8 (the .private field wasn't being passed over the wire). - * Check the server's version, and accept the old format if appropriate. - */ - - SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - if (majorVersion == 0 && minorVersion < 8) { - protocolBug = True; -#ifdef DEBUG - fprintf(stderr, "XF86VidModeGetAllModeLines: Warning: Xserver is" - "running an old version (%d.%d)\n", majorVersion, - minorVersion); -#endif - } - - LockDisplay(dpy); - GetReq(XF86VidModeGetAllModeLines, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeGetAllModeLines; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, - (SIZEOF(xXF86VidModeGetAllModeLinesReply) - - SIZEOF(xReply)) >> 2, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - *modecount = rep.modecount; - - if (! - (modelines = - (SDL_NAME(XF86VidModeModeInfo) **) Xcalloc(rep.modecount, - sizeof(SDL_NAME - (XF86VidModeModeInfo) - *) + - sizeof(SDL_NAME - (XF86VidModeModeInfo))))) - { - if (majorVersion < 2) - _XEatData(dpy, (rep.modecount) * sizeof(xXF86OldVidModeModeInfo)); - else - _XEatData(dpy, (rep.modecount) * sizeof(xXF86VidModeModeInfo)); - Xfree(modelines); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - mdinfptr = (SDL_NAME(XF86VidModeModeInfo) *) ((char *) modelines - + - rep.modecount * - sizeof(SDL_NAME - (XF86VidModeModeInfo) - *)); - - for (i = 0; i < rep.modecount; i++) { - modelines[i] = mdinfptr++; - if (majorVersion < 2) { - _XRead(dpy, (char *) &oldxmdline, - sizeof(xXF86OldVidModeModeInfo)); - modelines[i]->dotclock = oldxmdline.dotclock; - modelines[i]->hdisplay = oldxmdline.hdisplay; - modelines[i]->hsyncstart = oldxmdline.hsyncstart; - modelines[i]->hsyncend = oldxmdline.hsyncend; - modelines[i]->htotal = oldxmdline.htotal; - modelines[i]->hskew = 0; - modelines[i]->vdisplay = oldxmdline.vdisplay; - modelines[i]->vsyncstart = oldxmdline.vsyncstart; - modelines[i]->vsyncend = oldxmdline.vsyncend; - modelines[i]->vtotal = oldxmdline.vtotal; - modelines[i]->flags = oldxmdline.flags; - if (protocolBug) { - modelines[i]->privsize = 0; - modelines[i]->private = NULL; - } else { - modelines[i]->privsize = oldxmdline.privsize; - if (oldxmdline.privsize > 0) { - if (!(modelines[i]->private = - Xcalloc(oldxmdline.privsize, sizeof(INT32)))) { - _XEatData(dpy, (oldxmdline.privsize) * sizeof(INT32)); - Xfree(modelines[i]->private); - } else { - _XRead(dpy, (char *) modelines[i]->private, - oldxmdline.privsize * sizeof(INT32)); - } - } else { - modelines[i]->private = NULL; - } - } - } else { - _XRead(dpy, (char *) &xmdline, sizeof(xXF86VidModeModeInfo)); - modelines[i]->dotclock = xmdline.dotclock; - modelines[i]->hdisplay = xmdline.hdisplay; - modelines[i]->hsyncstart = xmdline.hsyncstart; - modelines[i]->hsyncend = xmdline.hsyncend; - modelines[i]->htotal = xmdline.htotal; - modelines[i]->hskew = xmdline.hskew; - modelines[i]->vdisplay = xmdline.vdisplay; - modelines[i]->vsyncstart = xmdline.vsyncstart; - modelines[i]->vsyncend = xmdline.vsyncend; - modelines[i]->vtotal = xmdline.vtotal; - modelines[i]->flags = xmdline.flags; - if (protocolBug) { - modelines[i]->privsize = 0; - modelines[i]->private = NULL; - } else { - modelines[i]->privsize = xmdline.privsize; - if (xmdline.privsize > 0) { - if (!(modelines[i]->private = - Xcalloc(xmdline.privsize, sizeof(INT32)))) { - _XEatData(dpy, (xmdline.privsize) * sizeof(INT32)); - Xfree(modelines[i]->private); - } else { - _XRead(dpy, (char *) modelines[i]->private, - xmdline.privsize * sizeof(INT32)); - } - } else { - modelines[i]->private = NULL; - } - } - } - } - *modelinesPtr = modelines; - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -/* - * GetReq replacement for use with VidMode protocols earlier than 2.0 - */ -#if !defined(UNIXCPP) || defined(ANSICPP) -#define GetOldReq(name, oldname, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x##oldname##Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x##oldname##Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_##name;\ - req->length = (SIZEOF(x##oldname##Req))>>2;\ - dpy->bufptr += SIZEOF(x##oldname##Req);\ - dpy->request++ - -#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */ -#define GetOldReq(name, oldname, req) \ - WORD64ALIGN\ - if ((dpy->bufptr + SIZEOF(x/**/oldname/**/Req)) > dpy->bufmax)\ - _XFlush(dpy);\ - req = (x/**/oldname/**/Req *)(dpy->last_req = dpy->bufptr);\ - req->reqType = X_/**/name;\ - req->length = (SIZEOF(x/**/oldname/**/Req))>>2;\ - dpy->bufptr += SIZEOF(x/**/oldname/**/Req);\ - dpy->request++ -#endif - -Bool -SDL_NAME(XF86VidModeAddModeLine) (dpy, screen, newmodeline, aftermodeline) - Display *dpy; - int screen; -SDL_NAME(XF86VidModeModeInfo) * newmodeline; -SDL_NAME(XF86VidModeModeInfo) * aftermodeline; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeAddModeLineReq *req; - xXF86OldVidModeAddModeLineReq *oldreq; - int majorVersion, minorVersion; - - XF86VidModeCheckExtension(dpy, info, False); - SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - - LockDisplay(dpy); - if (majorVersion < 2) { - GetOldReq(XF86VidModeAddModeLine, XF86OldVidModeAddModeLine, oldreq); - oldreq->reqType = info->codes->major_opcode; - oldreq->xf86vidmodeReqType = X_XF86VidModeAddModeLine; - oldreq->screen = screen; - oldreq->dotclock = newmodeline->dotclock; - oldreq->hdisplay = newmodeline->hdisplay; - oldreq->hsyncstart = newmodeline->hsyncstart; - oldreq->hsyncend = newmodeline->hsyncend; - oldreq->htotal = newmodeline->htotal; - oldreq->vdisplay = newmodeline->vdisplay; - oldreq->vsyncstart = newmodeline->vsyncstart; - oldreq->vsyncend = newmodeline->vsyncend; - oldreq->vtotal = newmodeline->vtotal; - oldreq->flags = newmodeline->flags; - oldreq->privsize = newmodeline->privsize; - if (aftermodeline != NULL) { - oldreq->after_dotclock = aftermodeline->dotclock; - oldreq->after_hdisplay = aftermodeline->hdisplay; - oldreq->after_hsyncstart = aftermodeline->hsyncstart; - oldreq->after_hsyncend = aftermodeline->hsyncend; - oldreq->after_htotal = aftermodeline->htotal; - oldreq->after_vdisplay = aftermodeline->vdisplay; - oldreq->after_vsyncstart = aftermodeline->vsyncstart; - oldreq->after_vsyncend = aftermodeline->vsyncend; - oldreq->after_vtotal = aftermodeline->vtotal; - oldreq->after_flags = aftermodeline->flags; - } else { - oldreq->after_dotclock = 0; - oldreq->after_hdisplay = 0; - oldreq->after_hsyncstart = 0; - oldreq->after_hsyncend = 0; - oldreq->after_htotal = 0; - oldreq->after_vdisplay = 0; - oldreq->after_vsyncstart = 0; - oldreq->after_vsyncend = 0; - oldreq->after_vtotal = 0; - oldreq->after_flags = 0; - } - if (newmodeline->privsize) { - oldreq->length += newmodeline->privsize; - Data32(dpy, (long *) newmodeline->private, - newmodeline->privsize * sizeof(INT32)); - } - } else { - GetReq(XF86VidModeAddModeLine, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeAddModeLine; - req->screen = screen; - req->dotclock = newmodeline->dotclock; - req->hdisplay = newmodeline->hdisplay; - req->hsyncstart = newmodeline->hsyncstart; - req->hsyncend = newmodeline->hsyncend; - req->htotal = newmodeline->htotal; - req->hskew = newmodeline->hskew; - req->vdisplay = newmodeline->vdisplay; - req->vsyncstart = newmodeline->vsyncstart; - req->vsyncend = newmodeline->vsyncend; - req->vtotal = newmodeline->vtotal; - req->flags = newmodeline->flags; - req->privsize = newmodeline->privsize; - if (aftermodeline != NULL) { - req->after_dotclock = aftermodeline->dotclock; - req->after_hdisplay = aftermodeline->hdisplay; - req->after_hsyncstart = aftermodeline->hsyncstart; - req->after_hsyncend = aftermodeline->hsyncend; - req->after_htotal = aftermodeline->htotal; - req->after_hskew = aftermodeline->hskew; - req->after_vdisplay = aftermodeline->vdisplay; - req->after_vsyncstart = aftermodeline->vsyncstart; - req->after_vsyncend = aftermodeline->vsyncend; - req->after_vtotal = aftermodeline->vtotal; - req->after_flags = aftermodeline->flags; - } else { - req->after_dotclock = 0; - req->after_hdisplay = 0; - req->after_hsyncstart = 0; - req->after_hsyncend = 0; - req->after_htotal = 0; - req->after_hskew = 0; - req->after_vdisplay = 0; - req->after_vsyncstart = 0; - req->after_vsyncend = 0; - req->after_vtotal = 0; - req->after_flags = 0; - } - if (newmodeline->privsize) { - req->length += newmodeline->privsize; - Data32(dpy, (long *) newmodeline->private, - newmodeline->privsize * sizeof(INT32)); - } - } - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeDeleteModeLine) (dpy, screen, modeline) - Display * - dpy; - int - screen; -SDL_NAME(XF86VidModeModeInfo) * modeline; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeDeleteModeLineReq *req; - xXF86OldVidModeDeleteModeLineReq *oldreq; - int majorVersion, minorVersion; - - XF86VidModeCheckExtension(dpy, info, 0); - SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - - LockDisplay(dpy); - if (majorVersion < 2) { - GetOldReq(XF86VidModeDeleteModeLine, XF86OldVidModeDeleteModeLine, - oldreq); - oldreq->reqType = info->codes->major_opcode; - oldreq->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine; - oldreq->screen = screen; - oldreq->dotclock = modeline->dotclock; - oldreq->hdisplay = modeline->hdisplay; - oldreq->hsyncstart = modeline->hsyncstart; - oldreq->hsyncend = modeline->hsyncend; - oldreq->htotal = modeline->htotal; - oldreq->vdisplay = modeline->vdisplay; - oldreq->vsyncstart = modeline->vsyncstart; - oldreq->vsyncend = modeline->vsyncend; - oldreq->vtotal = modeline->vtotal; - oldreq->flags = modeline->flags; - oldreq->privsize = modeline->privsize; - if (modeline->privsize) { - oldreq->length += modeline->privsize; - Data32(dpy, (long *) modeline->private, - modeline->privsize * sizeof(INT32)); - } - } else { - GetReq(XF86VidModeDeleteModeLine, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeDeleteModeLine; - req->screen = screen; - req->dotclock = modeline->dotclock; - req->hdisplay = modeline->hdisplay; - req->hsyncstart = modeline->hsyncstart; - req->hsyncend = modeline->hsyncend; - req->htotal = modeline->htotal; - req->hskew = modeline->hskew; - req->vdisplay = modeline->vdisplay; - req->vsyncstart = modeline->vsyncstart; - req->vsyncend = modeline->vsyncend; - req->vtotal = modeline->vtotal; - req->flags = modeline->flags; - req->privsize = modeline->privsize; - if (modeline->privsize) { - req->length += modeline->privsize; - Data32(dpy, (long *) modeline->private, - modeline->privsize * sizeof(INT32)); - } - } - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeModModeLine) (dpy, screen, modeline) - Display * - dpy; - int - screen; -SDL_NAME(XF86VidModeModeLine) * modeline; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeModModeLineReq *req; - xXF86OldVidModeModModeLineReq *oldreq; - int majorVersion, minorVersion; - - XF86VidModeCheckExtension(dpy, info, 0); - SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - - LockDisplay(dpy); - if (majorVersion < 2) { - GetOldReq(XF86VidModeModModeLine, XF86OldVidModeModModeLine, oldreq); - oldreq->reqType = info->codes->major_opcode; - oldreq->xf86vidmodeReqType = X_XF86VidModeModModeLine; - oldreq->screen = screen; - oldreq->hdisplay = modeline->hdisplay; - oldreq->hsyncstart = modeline->hsyncstart; - oldreq->hsyncend = modeline->hsyncend; - oldreq->htotal = modeline->htotal; - oldreq->vdisplay = modeline->vdisplay; - oldreq->vsyncstart = modeline->vsyncstart; - oldreq->vsyncend = modeline->vsyncend; - oldreq->vtotal = modeline->vtotal; - oldreq->flags = modeline->flags; - oldreq->privsize = modeline->privsize; - if (modeline->privsize) { - oldreq->length += modeline->privsize; - Data32(dpy, (long *) modeline->private, - modeline->privsize * sizeof(INT32)); - } - } else { - GetReq(XF86VidModeModModeLine, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeModModeLine; - req->screen = screen; - req->hdisplay = modeline->hdisplay; - req->hsyncstart = modeline->hsyncstart; - req->hsyncend = modeline->hsyncend; - req->htotal = modeline->htotal; - req->hskew = modeline->hskew; - req->vdisplay = modeline->vdisplay; - req->vsyncstart = modeline->vsyncstart; - req->vsyncend = modeline->vsyncend; - req->vtotal = modeline->vtotal; - req->flags = modeline->flags; - req->privsize = modeline->privsize; - if (modeline->privsize) { - req->length += modeline->privsize; - Data32(dpy, (long *) modeline->private, - modeline->privsize * sizeof(INT32)); - } - } - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Status SDL_NAME(XF86VidModeValidateModeLine) (dpy, screen, modeline) - Display * - dpy; - int - screen; -SDL_NAME(XF86VidModeModeInfo) * modeline; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeValidateModeLineReq *req; - xXF86OldVidModeValidateModeLineReq *oldreq; - xXF86VidModeValidateModeLineReply rep; - int majorVersion, minorVersion; - - XF86VidModeCheckExtension(dpy, info, 0); - SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - - LockDisplay(dpy); - - if (majorVersion < 2) { - GetOldReq(XF86VidModeValidateModeLine, - XF86OldVidModeValidateModeLine, oldreq); - oldreq->reqType = info->codes->major_opcode; - oldreq->xf86vidmodeReqType = X_XF86VidModeValidateModeLine; - oldreq->screen = screen; - oldreq->dotclock = modeline->dotclock; - oldreq->hdisplay = modeline->hdisplay; - oldreq->hsyncstart = modeline->hsyncstart; - oldreq->hsyncend = modeline->hsyncend; - oldreq->htotal = modeline->htotal; - oldreq->vdisplay = modeline->vdisplay; - oldreq->vsyncstart = modeline->vsyncstart; - oldreq->vsyncend = modeline->vsyncend; - oldreq->vtotal = modeline->vtotal; - oldreq->flags = modeline->flags; - oldreq->privsize = modeline->privsize; - if (modeline->privsize) { - oldreq->length += modeline->privsize; - Data32(dpy, (long *) modeline->private, - modeline->privsize * sizeof(INT32)); - } - } else { - GetReq(XF86VidModeValidateModeLine, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeValidateModeLine; - req->screen = screen; - req->dotclock = modeline->dotclock; - req->hdisplay = modeline->hdisplay; - req->hsyncstart = modeline->hsyncstart; - req->hsyncend = modeline->hsyncend; - req->htotal = modeline->htotal; - req->hskew = modeline->hskew; - req->vdisplay = modeline->vdisplay; - req->vsyncstart = modeline->vsyncstart; - req->vsyncend = modeline->vsyncend; - req->vtotal = modeline->vtotal; - req->flags = modeline->flags; - req->privsize = modeline->privsize; - if (modeline->privsize) { - req->length += modeline->privsize; - Data32(dpy, (long *) modeline->private, - modeline->privsize * sizeof(INT32)); - } - } - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return MODE_BAD; - } - UnlockDisplay(dpy); - SyncHandle(); - return rep.status; -} - -Bool SDL_NAME(XF86VidModeSwitchMode) (dpy, screen, zoom) - Display * - dpy; - int - screen; - int - zoom; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeSwitchModeReq *req; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeSwitchMode, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeSwitchMode; - req->screen = screen; - req->zoom = zoom; - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeSwitchToMode) (dpy, screen, modeline) - Display * - dpy; - int - screen; -SDL_NAME(XF86VidModeModeInfo) * modeline; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeSwitchToModeReq *req; - xXF86OldVidModeSwitchToModeReq *oldreq; - int majorVersion, minorVersion; - Bool protocolBug = False; - - XF86VidModeCheckExtension(dpy, info, False); - - /* - * Note: There was a bug in the protocol implementation in versions - * 0.x with x < 8 (the .private field wasn't expected to be sent over - * the wire). Check the server's version, and accept the old format - * if appropriate. - */ - - SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - if (majorVersion == 0 && minorVersion < 8) { - protocolBug = True; -#ifdef DEBUG - fprintf(stderr, "XF86VidModeSwitchToMode: Warning: Xserver is" - "running an old version (%d.%d)\n", majorVersion, - minorVersion); -#endif - } - - LockDisplay(dpy); - if (majorVersion < 2) { - GetOldReq(XF86VidModeSwitchToMode, XF86OldVidModeSwitchToMode, - oldreq); - oldreq->reqType = info->codes->major_opcode; - oldreq->xf86vidmodeReqType = X_XF86VidModeSwitchToMode; - oldreq->screen = screen; - oldreq->dotclock = modeline->dotclock; - oldreq->hdisplay = modeline->hdisplay; - oldreq->hsyncstart = modeline->hsyncstart; - oldreq->hsyncend = modeline->hsyncend; - oldreq->htotal = modeline->htotal; - oldreq->vdisplay = modeline->vdisplay; - oldreq->vsyncstart = modeline->vsyncstart; - oldreq->vsyncend = modeline->vsyncend; - oldreq->vtotal = modeline->vtotal; - oldreq->flags = modeline->flags; - if (protocolBug) { - oldreq->privsize = 0; - } else { - oldreq->privsize = modeline->privsize; - if (modeline->privsize) { - oldreq->length += modeline->privsize; - Data32(dpy, (long *) modeline->private, - modeline->privsize * sizeof(INT32)); - } - } - } else { - GetReq(XF86VidModeSwitchToMode, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeSwitchToMode; - req->screen = screen; - req->dotclock = modeline->dotclock; - req->hdisplay = modeline->hdisplay; - req->hsyncstart = modeline->hsyncstart; - req->hsyncend = modeline->hsyncend; - req->htotal = modeline->htotal; - req->hskew = modeline->hskew; - req->vdisplay = modeline->vdisplay; - req->vsyncstart = modeline->vsyncstart; - req->vsyncend = modeline->vsyncend; - req->vtotal = modeline->vtotal; - req->flags = modeline->flags; - if (protocolBug) { - req->privsize = 0; - } else { - req->privsize = modeline->privsize; - if (modeline->privsize) { - req->length += modeline->privsize; - Data32(dpy, (long *) modeline->private, - modeline->privsize * sizeof(INT32)); - } - } - } - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeLockModeSwitch) (dpy, screen, lock) - Display * - dpy; - int - screen; - int - lock; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeLockModeSwitchReq *req; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeLockModeSwitch, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeLockModeSwitch; - req->screen = screen; - req->lock = lock; - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeGetMonitor) (dpy, screen, monitor) - Display * - dpy; - int - screen; -SDL_NAME(XF86VidModeMonitor) * monitor; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeGetMonitorReply rep; - xXF86VidModeGetMonitorReq *req; - CARD32 syncrange; - int i; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeGetMonitor, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeGetMonitor; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - monitor->nhsync = rep.nhsync; - monitor->nvsync = rep.nvsync; -#if 0 - monitor->bandwidth = (float) rep.bandwidth / 1e6; -#endif - if (rep.vendorLength) { - if (!(monitor->vendor = (char *) Xcalloc(rep.vendorLength + 1, 1))) { - _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - } else { - monitor->vendor = NULL; - } - if (rep.modelLength) { - if (!(monitor->model = Xcalloc(rep.modelLength + 1, 1))) { - _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)); - if (monitor->vendor) - Xfree(monitor->vendor); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - } else { - monitor->model = NULL; - } - if (! - (monitor->hsync = - Xcalloc(rep.nhsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { - _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)); - - if (monitor->vendor) - Xfree(monitor->vendor); - if (monitor->model) - Xfree(monitor->model); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - if (! - (monitor->vsync = - Xcalloc(rep.nvsync, sizeof(SDL_NAME(XF86VidModeSyncRange))))) { - _XEatData(dpy, (rep.nhsync + rep.nvsync) * 4 + - ((rep.vendorLength + 3) & ~3) + - ((rep.modelLength + 3) & ~3)); - if (monitor->vendor) - Xfree(monitor->vendor); - if (monitor->model) - Xfree(monitor->model); - Xfree(monitor->hsync); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - for (i = 0; i < rep.nhsync; i++) { - _XRead(dpy, (char *) &syncrange, 4); - monitor->hsync[i].lo = (float) (syncrange & 0xFFFF) / 100.0; - monitor->hsync[i].hi = (float) (syncrange >> 16) / 100.0; - } - for (i = 0; i < rep.nvsync; i++) { - _XRead(dpy, (char *) &syncrange, 4); - monitor->vsync[i].lo = (float) (syncrange & 0xFFFF) / 100.0; - monitor->vsync[i].hi = (float) (syncrange >> 16) / 100.0; - } - if (rep.vendorLength) - _XReadPad(dpy, monitor->vendor, rep.vendorLength); - else - monitor->vendor = ""; - if (rep.modelLength) - _XReadPad(dpy, monitor->model, rep.modelLength); - else - monitor->model = ""; - - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeGetViewPort) (dpy, screen, x, y) - Display * - dpy; - int - screen; - int * - x, * - y; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeGetViewPortReply rep; - xXF86VidModeGetViewPortReq *req; - int majorVersion, minorVersion; - Bool protocolBug = False; - - XF86VidModeCheckExtension(dpy, info, False); - - /* - * Note: There was a bug in the protocol implementation in versions - * 0.x with x < 8 (no reply was sent, so the client would hang) - * Check the server's version, and don't wait for a reply with older - * versions. - */ - - SDL_NAME(XF86VidModeQueryVersion) (dpy, &majorVersion, &minorVersion); - if (majorVersion == 0 && minorVersion < 8) { - protocolBug = True; -#ifdef DEBUG - fprintf(stderr, "XF86VidModeGetViewPort: Warning: Xserver is" - "running an old version (%d.%d)\n", majorVersion, - minorVersion); -#endif - } - LockDisplay(dpy); - GetReq(XF86VidModeGetViewPort, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeGetViewPort; - req->screen = screen; - if (protocolBug) { - *x = 0; - *y = 0; - } else { - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *x = rep.x; - *y = rep.y; - } - - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeSetViewPort) (dpy, screen, x, y) - Display * - dpy; - int - screen; - int - x, - y; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeSetViewPortReq *req; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeSetViewPort, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeSetViewPort; - req->screen = screen; - req->x = x; - req->y = y; - - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool -SDL_NAME(XF86VidModeGetDotClocks) (dpy, screen, - flagsPtr, numclocksPtr, maxclocksPtr, - clocksPtr) - Display *dpy; - int screen; - int *flagsPtr, *numclocksPtr, *maxclocksPtr, *clocksPtr[]; -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeGetDotClocksReply rep; - xXF86VidModeGetDotClocksReq *req; - int i, *dotclocks; - CARD32 dotclk; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeGetDotClocks, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeGetDotClocks; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, - (SIZEOF(xXF86VidModeGetDotClocksReply) - - SIZEOF(xReply)) >> 2, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *numclocksPtr = rep.clocks; - *maxclocksPtr = rep.maxclocks; - *flagsPtr = rep.flags; - - if (!(dotclocks = (int *) Xcalloc(rep.clocks, sizeof(int)))) { - _XEatData(dpy, (rep.clocks) * 4); - Xfree(dotclocks); - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - - for (i = 0; i < rep.clocks; i++) { - _XRead(dpy, (char *) &dotclk, 4); - dotclocks[i] = dotclk; - } - *clocksPtr = dotclocks; - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool -SDL_NAME(XF86VidModeSetGammaRamp) (Display * dpy, - int screen, - int size, - unsigned short *red, - unsigned short *green, - unsigned short *blue) -{ - int length = (size + 1) & ~1; - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeSetGammaRampReq *req; - - XF86VidModeCheckExtension(dpy, info, False); - LockDisplay(dpy); - GetReq(XF86VidModeSetGammaRamp, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeSetGammaRamp; - req->screen = screen; - req->length += (length >> 1) * 3; - req->size = size; - _XSend(dpy, (char *) red, size * 2); - _XSend(dpy, (char *) green, size * 2); - _XSend(dpy, (char *) blue, size * 2); - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - - -Bool -SDL_NAME(XF86VidModeGetGammaRamp) (Display * dpy, - int screen, - int size, - unsigned short *red, - unsigned short *green, - unsigned short *blue) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeGetGammaRampReq *req; - xXF86VidModeGetGammaRampReply rep; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeGetGammaRamp, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeGetGammaRamp; - req->screen = screen; - req->size = size; - if (!_XReply(dpy, (xReply *) & rep, 0, xFalse)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - if (rep.size) { - _XRead(dpy, (char *) red, rep.size << 1); - _XRead(dpy, (char *) green, rep.size << 1); - _XRead(dpy, (char *) blue, rep.size << 1); - } - - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -Bool SDL_NAME(XF86VidModeGetGammaRampSize) (Display * dpy, - int screen, int *size) -{ - XExtDisplayInfo *info = find_display(dpy); - xXF86VidModeGetGammaRampSizeReq *req; - xXF86VidModeGetGammaRampSizeReply rep; - - *size = 0; - - XF86VidModeCheckExtension(dpy, info, False); - - LockDisplay(dpy); - GetReq(XF86VidModeGetGammaRampSize, req); - req->reqType = info->codes->major_opcode; - req->xf86vidmodeReqType = X_XF86VidModeGetGammaRampSize; - req->screen = screen; - if (!_XReply(dpy, (xReply *) & rep, 0, xTrue)) { - UnlockDisplay(dpy); - SyncHandle(); - return False; - } - *size = rep.size; - UnlockDisplay(dpy); - SyncHandle(); - return True; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/StdCmap.h b/project/jni/sdl-1.3/src/video/Xext/extensions/StdCmap.h deleted file mode 100644 index 82d25f012..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/StdCmap.h +++ /dev/null @@ -1,80 +0,0 @@ -/* $Xorg: StdCmap.h,v 1.5 2001/02/09 02:03:53 xorgcvs Exp $ */ - -/* - -Copyright 1988, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - -*/ -/* $XFree86: xc/lib/Xmu/StdCmap.h,v 1.8 2001/01/23 17:38:14 keithp Exp $ */ - -/* - * The interfaces described by this header file are for miscellaneous utilities - * and are not part of the Xlib standard. - */ - -#ifndef _XMU_STDCMAP_H_ -#define _XMU_STDCMAP_H_ - -#include -#include "SDL_name.h" - -_XFUNCPROTOBEGIN extern Status XmuAllStandardColormaps(Display * dpy); - -extern Status XmuCreateColormap(Display * dpy, XStandardColormap * colormap); - -extern void XmuDeleteStandardColormap - (Display * dpy, int screen, Atom property); - -extern Status XmuGetColormapAllocation - (XVisualInfo * vinfo, - Atom property, - unsigned long *red_max_return, - unsigned long *green_max_return, unsigned long *blue_max_return); - -extern Status XmuLookupStandardColormap - (Display * dpy, - int screen, - VisualID visualid, - unsigned int depth, Atom property, Bool replace, Bool retain); - -extern XStandardColormap *XmuStandardColormap - (Display * dpy, - int screen, - VisualID visualid, - unsigned int depth, - Atom property, - Colormap cmap, - unsigned long red_max, unsigned long green_max, unsigned long blue_max); - -extern Status XmuVisualStandardColormaps - (Display * dpy, - int screen, - VisualID visualid, unsigned int depth, Bool replace, Bool retain); - -extern Bool XmuDistinguishableColors(XColor * colors, int count); - -extern Bool XmuDistinguishablePixels - (Display * dpy, Colormap cmap, unsigned long *pixels, int count); - -_XFUNCPROTOEND -#endif /* _XMU_STDCMAP_H_ */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/Xext.h b/project/jni/sdl-1.3/src/video/Xext/extensions/Xext.h deleted file mode 100644 index 092ac4369..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/Xext.h +++ /dev/null @@ -1,46 +0,0 @@ -/* -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - */ -/* $XFree86: xc/include/extensions/Xext.h,v 1.7 2005/01/27 03:03:09 dawes Exp $ */ - -#ifndef _XEXT_H_ -#define _XEXT_H_ - -#include - -_XFUNCPROTOBEGIN - typedef int (*XExtensionErrorHandler) (Display *, _Xconst char *, - _Xconst char *); - -extern XExtensionErrorHandler -XSetExtensionErrorHandler(XExtensionErrorHandler handler); - -extern int XMissingExtension(Display * /* dpy */ , - _Xconst char * /* ext_name */ - ); - -_XFUNCPROTOEND -#define X_EXTENSION_UNKNOWN "unknown" -#define X_EXTENSION_MISSING "missing" -#endif /* _XEXT_H_ */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/Xinerama.h b/project/jni/sdl-1.3/src/video/Xext/extensions/Xinerama.h deleted file mode 100644 index 899f51f6f..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/Xinerama.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $XFree86: xc/include/extensions/Xinerama.h,v 3.2 2000/03/01 01:04:20 dawes Exp $ */ - -#ifndef _Xinerama_h -#define _Xinerama_h - -#include "SDL_name.h" - -typedef struct -{ - int screen_number; - short x_org; - short y_org; - short width; - short height; -} SDL_NAME(XineramaScreenInfo); - -Bool SDL_NAME(XineramaQueryExtension) (Display * dpy, - int *event_base, int *error_base); - -Status SDL_NAME(XineramaQueryVersion) (Display * dpy, int *major, int *minor); - -Bool SDL_NAME(XineramaIsActive) (Display * dpy); - - -/* - Returns the number of heads and a pointer to an array of - structures describing the position and size of the individual - heads. Returns NULL and number = 0 if Xinerama is not active. - - Returned array should be freed with XFree(). -*/ - -SDL_NAME(XineramaScreenInfo) * -SDL_NAME(XineramaQueryScreens) (Display * dpy, int *number); - -#endif /* _Xinerama_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/Xv.h b/project/jni/sdl-1.3/src/video/Xext/extensions/Xv.h deleted file mode 100644 index ecbc7a3b6..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/Xv.h +++ /dev/null @@ -1,129 +0,0 @@ -/*********************************************************** -Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, -and the Massachusetts Institute of Technology, Cambridge, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Digital or MIT not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* $XFree86: xc/include/extensions/Xv.h,v 1.5 1999/12/11 19:28:48 mvojkovi Exp $ */ - -#ifndef XV_H -#define XV_H -/* -** File: -** -** Xv.h --- Xv shared library and server header file -** -** Author: -** -** David Carver (Digital Workstation Engineering/Project Athena) -** -** Revisions: -** -** 05.15.91 Carver -** - version 2.0 upgrade -** -** 01.24.91 Carver -** - version 1.4 upgrade -** -*/ - -#include - -#define XvName "XVideo" -#define XvVersion 2 -#define XvRevision 2 - -/* Symbols */ - -typedef XID XvPortID; -typedef XID XvEncodingID; - -#define XvNone 0 - -#define XvInput 0 -#define XvOutput 1 - -#define XvInputMask (1L< -#include "Xv.h" -#include "SDL_name.h" - -typedef struct -{ - int numerator; - int denominator; -} SDL_NAME(XvRational); - -typedef struct -{ - int flags; /* XvGettable, XvSettable */ - int min_value; - int max_value; - char *name; -} SDL_NAME(XvAttribute); - -typedef struct -{ - XvEncodingID encoding_id; - char *name; - unsigned long width; - unsigned long height; - SDL_NAME(XvRational) rate; - unsigned long num_encodings; -} SDL_NAME(XvEncodingInfo); - -typedef struct -{ - char depth; - unsigned long visual_id; -} SDL_NAME(XvFormat); - -typedef struct -{ - XvPortID base_id; - unsigned long num_ports; - char type; - char *name; - unsigned long num_formats; - SDL_NAME(XvFormat) * formats; - unsigned long num_adaptors; -} SDL_NAME(XvAdaptorInfo); - -typedef struct -{ - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - Drawable drawable; /* drawable */ - unsigned long reason; /* what generated this event */ - XvPortID port_id; /* what port */ - Time time; /* milliseconds */ -} SDL_NAME(XvVideoNotifyEvent); - -typedef struct -{ - int type; - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent request */ - Display *display; /* Display the event was read from */ - XvPortID port_id; /* what port */ - Time time; /* milliseconds */ - Atom attribute; /* atom that identifies attribute */ - long value; /* value of attribute */ -} SDL_NAME(XvPortNotifyEvent); - -typedef union -{ - int type; - SDL_NAME(XvVideoNotifyEvent) xvvideo; - SDL_NAME(XvPortNotifyEvent) xvport; - long pad[24]; -} SDL_NAME(XvEvent); - -typedef struct -{ - int id; /* Unique descriptor for the format */ - int type; /* XvRGB, XvYUV */ - int byte_order; /* LSBFirst, MSBFirst */ - char guid[16]; /* Globally Unique IDentifier */ - int bits_per_pixel; - int format; /* XvPacked, XvPlanar */ - int num_planes; - - /* for RGB formats only */ - int depth; - unsigned int red_mask; - unsigned int green_mask; - unsigned int blue_mask; - - /* for YUV formats only */ - unsigned int y_sample_bits; - unsigned int u_sample_bits; - unsigned int v_sample_bits; - unsigned int horz_y_period; - unsigned int horz_u_period; - unsigned int horz_v_period; - unsigned int vert_y_period; - unsigned int vert_u_period; - unsigned int vert_v_period; - char component_order[32]; /* eg. UYVY */ - int scanline_order; /* XvTopToBottom, XvBottomToTop */ -} SDL_NAME(XvImageFormatValues); - -typedef struct -{ - int id; - int width, height; - int data_size; /* bytes */ - int num_planes; - int *pitches; /* bytes */ - int *offsets; /* bytes */ - char *data; - XPointer obdata; -} SDL_NAME(XvImage); - -_XFUNCPROTOBEGIN extern int SDL_NAME(XvQueryExtension) ( -#if NeedFunctionPrototypes - Display * - /* display */ , - unsigned int * - /* p_version */ , - unsigned int * - /* p_revision */ , - unsigned int * - /* p_requestBase */ - , unsigned int * - /* p_eventBase */ - , unsigned int * /* p_errorBase */ -#endif - ); - -extern int SDL_NAME(XvQueryAdaptors) ( -#if NeedFunctionPrototypes - Display * /* display */ , - Window /* window */ , - unsigned int * /* p_nAdaptors */ , - SDL_NAME(XvAdaptorInfo) ** /* p_pAdaptors */ -#endif - ); - -extern int SDL_NAME(XvQueryEncodings) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - unsigned int * /* p_nEncoding */ , - SDL_NAME(XvEncodingInfo) ** /* p_pEncoding */ -#endif - ); - -extern int SDL_NAME(XvPutVideo) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* d */ , - GC /* gc */ , - int /* vx */ , - int /* vy */ , - unsigned int /* vw */ , - unsigned int /* vh */ , - int /* dx */ , - int /* dy */ , - unsigned int /* dw */ , - unsigned int /* dh */ -#endif - ); - -extern int SDL_NAME(XvPutStill) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* d */ , - GC /* gc */ , - int /* vx */ , - int /* vy */ , - unsigned int /* vw */ , - unsigned int /* vh */ , - int /* dx */ , - int /* dy */ , - unsigned int /* dw */ , - unsigned int /* dh */ -#endif - ); - -extern int SDL_NAME(XvGetVideo) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* d */ , - GC /* gc */ , - int /* vx */ , - int /* vy */ , - unsigned int /* vw */ , - unsigned int /* vh */ , - int /* dx */ , - int /* dy */ , - unsigned int /* dw */ , - unsigned int /* dh */ -#endif - ); - -extern int SDL_NAME(XvGetStill) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* d */ , - GC /* gc */ , - int /* vx */ , - int /* vy */ , - unsigned int /* vw */ , - unsigned int /* vh */ , - int /* dx */ , - int /* dy */ , - unsigned int /* dw */ , - unsigned int /* dh */ -#endif - ); - -extern int SDL_NAME(XvStopVideo) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Drawable /* drawable */ -#endif - ); - -extern int SDL_NAME(XvGrabPort) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Time /* time */ -#endif - ); - -extern int SDL_NAME(XvUngrabPort) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Time /* time */ -#endif - ); - -extern int SDL_NAME(XvSelectVideoNotify) ( -#if NeedFunctionPrototypes - Display * /* display */ , - Drawable /* drawable */ , - Bool /* onoff */ -#endif - ); - -extern int SDL_NAME(XvSelectPortNotify) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Bool /* onoff */ -#endif - ); - -extern int SDL_NAME(XvSetPortAttribute) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Atom /* attribute */ , - int /* value */ -#endif - ); - -extern int SDL_NAME(XvGetPortAttribute) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Atom /* attribute */ , - int * /* p_value */ -#endif - ); - -extern int SDL_NAME(XvQueryBestSize) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - Bool /* motion */ , - unsigned int /* vid_w */ , - unsigned int /* vid_h */ , - unsigned int /* drw_w */ , - unsigned int /* drw_h */ , - unsigned int * /* p_actual_width */ - , unsigned int * /* p_actual_width */ -#endif - ); - -extern -SDL_NAME(XvAttribute) * -SDL_NAME(XvQueryPortAttributes) ( -#if NeedFunctionPrototypes - Display * /* display */ , - XvPortID /* port */ , - int * /* number */ -#endif - ); - - - extern void SDL_NAME(XvFreeAdaptorInfo) ( -#if NeedFunctionPrototypes - SDL_NAME(XvAdaptorInfo) * /* adaptors */ -#endif - ); - - extern void SDL_NAME(XvFreeEncodingInfo) ( -#if NeedFunctionPrototypes - SDL_NAME(XvEncodingInfo) * /* encodings */ -#endif - ); - - - extern SDL_NAME(XvImageFormatValues) * SDL_NAME(XvListImageFormats) ( -#if NeedFunctionPrototypes - Display - * - display, - XvPortID - port_id, - int - *count_return -#endif - ); - - extern SDL_NAME(XvImage) * SDL_NAME(XvCreateImage) ( -#if NeedFunctionPrototypes - Display * - display, - XvPortID port, - int id, - char *data, - int width, - int height -#endif - ); - - extern int SDL_NAME(XvPutImage) ( -#if NeedFunctionPrototypes - Display * display, - XvPortID id, - Drawable d, - GC gc, - SDL_NAME(XvImage) * image, - int src_x, - int src_y, - unsigned int src_w, - unsigned int src_h, - int dest_x, - int dest_y, - unsigned int dest_w, - unsigned int dest_h -#endif - ); - - extern int SDL_NAME(XvShmPutImage) ( -#if NeedFunctionPrototypes - Display * display, - XvPortID id, - Drawable d, - GC gc, - SDL_NAME(XvImage) * image, - int src_x, - int src_y, - unsigned int src_w, - unsigned int src_h, - int dest_x, - int dest_y, - unsigned int dest_w, - unsigned int dest_h, - Bool send_event -#endif - ); - -#ifdef _XSHM_H_ - - extern SDL_NAME(XvImage) * SDL_NAME(XvShmCreateImage) ( -#if NeedFunctionPrototypes - Display * - display, - XvPortID - port, int id, - char *data, - int width, - int height, - XShmSegmentInfo - * shminfo -#endif - ); - -#endif - - -_XFUNCPROTOEND -#endif /* XVLIB_H */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/Xvproto.h b/project/jni/sdl-1.3/src/video/Xext/extensions/Xvproto.h deleted file mode 100644 index 985aa8535..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/Xvproto.h +++ /dev/null @@ -1,644 +0,0 @@ -/*********************************************************** -Copyright 1991 by Digital Equipment Corporation, Maynard, Massachusetts, -and the Massachusetts Institute of Technology, Cambridge, Massachusetts. - - All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that copyright notice and this permission notice appear in -supporting documentation, and that the names of Digital or MIT not be -used in advertising or publicity pertaining to distribution of the -software without specific, written prior permission. - -DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING -ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL -DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR -ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -******************************************************************/ -/* $XFree86: xc/include/extensions/Xvproto.h,v 1.6 2001/05/07 21:37:12 tsi Exp $ */ - -#ifndef XVPROTO_H -#define XVPROTO_H -/* -** File: -** -** Xvproto.h --- Xv protocol header file -** -** Author: -** -** David Carver (Digital Workstation Engineering/Project Athena) -** -** Revisions: -** -** 11.06.91 Carver -** - changed SetPortControl to SetPortAttribute -** - changed GetPortControl to GetPortAttribute -** - changed QueryBestSize -** -** 15.05.91 Carver -** - version 2.0 upgrade -** -** 24.01.91 Carver -** - version 1.4 upgrade -** -*/ - -#include - -/* Symbols: These are undefined at the end of this file to restore the - values they have in Xv.h */ - -#define XvPortID CARD32 -#define XvEncodingID CARD32 -#define ShmSeg CARD32 -#define VisualID CARD32 -#define Drawable CARD32 -#define GContext CARD32 -#define Time CARD32 -#define Atom CARD32 - -/* Structures */ - -typedef struct -{ - INT32 numerator B32; - INT32 denominator B32; -} xvRational; -#define sz_xvRational 8 - -typedef struct -{ - XvPortID base_id B32; - CARD16 name_size B16; - CARD16 num_ports B16; - CARD16 num_formats B16; - CARD8 type; - CARD8 pad; -} xvAdaptorInfo; -#define sz_xvAdaptorInfo 12 - -typedef struct -{ - XvEncodingID encoding B32; - CARD16 name_size B16; - CARD16 width B16, height B16; - xvRational rate; - CARD16 pad B16; -} xvEncodingInfo; -#define sz_xvEncodingInfo (12 + sz_xvRational) - -typedef struct -{ - VisualID visual B32; - CARD8 depth; - CARD8 pad1; - CARD16 pad2 B16; -} xvFormat; -#define sz_xvFormat 8 - -typedef struct -{ - CARD32 flags B32; - INT32 min B32; - INT32 max B32; - CARD32 size B32; -} xvAttributeInfo; -#define sz_xvAttributeInfo 16 - -typedef struct -{ - CARD32 id B32; - CARD8 type; - CARD8 byte_order; - CARD16 pad1 B16; - CARD8 guid[16]; - CARD8 bpp; - CARD8 num_planes; - CARD16 pad2 B16; - CARD8 depth; - CARD8 pad3; - CARD16 pad4 B16; - CARD32 red_mask B32; - CARD32 green_mask B32; - CARD32 blue_mask B32; - CARD8 format; - CARD8 pad5; - CARD16 pad6 B16; - CARD32 y_sample_bits B32; - CARD32 u_sample_bits B32; - CARD32 v_sample_bits B32; - CARD32 horz_y_period B32; - CARD32 horz_u_period B32; - CARD32 horz_v_period B32; - CARD32 vert_y_period B32; - CARD32 vert_u_period B32; - CARD32 vert_v_period B32; - CARD8 comp_order[32]; - CARD8 scanline_order; - CARD8 pad7; - CARD16 pad8 B16; - CARD32 pad9 B32; - CARD32 pad10 B32; -} xvImageFormatInfo; -#define sz_xvImageFormatInfo 128 - - -/* Requests */ - -#define xv_QueryExtension 0 -#define xv_QueryAdaptors 1 -#define xv_QueryEncodings 2 -#define xv_GrabPort 3 -#define xv_UngrabPort 4 -#define xv_PutVideo 5 -#define xv_PutStill 6 -#define xv_GetVideo 7 -#define xv_GetStill 8 -#define xv_StopVideo 9 -#define xv_SelectVideoNotify 10 -#define xv_SelectPortNotify 11 -#define xv_QueryBestSize 12 -#define xv_SetPortAttribute 13 -#define xv_GetPortAttribute 14 -#define xv_QueryPortAttributes 15 -#define xv_ListImageFormats 16 -#define xv_QueryImageAttributes 17 -#define xv_PutImage 18 -#define xv_ShmPutImage 19 -#define xv_LastRequest xv_ShmPutImage - -#define xvNumRequests (xv_LastRequest + 1) - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; -} xvQueryExtensionReq; -#define sz_xvQueryExtensionReq 4 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - CARD32 window B32; -} xvQueryAdaptorsReq; -#define sz_xvQueryAdaptorsReq 8 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - CARD32 port B32; -} xvQueryEncodingsReq; -#define sz_xvQueryEncodingsReq 8 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Drawable drawable B32; - GContext gc B32; - INT16 vid_x B16; - INT16 vid_y B16; - CARD16 vid_w B16; - CARD16 vid_h B16; - INT16 drw_x B16; - INT16 drw_y B16; - CARD16 drw_w B16; - CARD16 drw_h B16; -} xvPutVideoReq; -#define sz_xvPutVideoReq 32 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Drawable drawable B32; - GContext gc B32; - INT16 vid_x B16; - INT16 vid_y B16; - CARD16 vid_w B16; - CARD16 vid_h B16; - INT16 drw_x B16; - INT16 drw_y B16; - CARD16 drw_w B16; - CARD16 drw_h B16; -} xvPutStillReq; -#define sz_xvPutStillReq 32 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Drawable drawable B32; - GContext gc B32; - INT16 vid_x B16; - INT16 vid_y B16; - CARD16 vid_w B16; - CARD16 vid_h B16; - INT16 drw_x B16; - INT16 drw_y B16; - CARD16 drw_w B16; - CARD16 drw_h B16; -} xvGetVideoReq; -#define sz_xvGetVideoReq 32 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Drawable drawable B32; - GContext gc B32; - INT16 vid_x B16; - INT16 vid_y B16; - CARD16 vid_w B16; - CARD16 vid_h B16; - INT16 drw_x B16; - INT16 drw_y B16; - CARD16 drw_w B16; - CARD16 drw_h B16; -} xvGetStillReq; -#define sz_xvGetStillReq 32 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Time time B32; -} xvGrabPortReq; -#define sz_xvGrabPortReq 12 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Time time B32; -} xvUngrabPortReq; -#define sz_xvUngrabPortReq 12 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - Drawable drawable B32; - BOOL onoff; - CARD8 pad1; - CARD16 pad2; -} xvSelectVideoNotifyReq; -#define sz_xvSelectVideoNotifyReq 12 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - BOOL onoff; - CARD8 pad1; - CARD16 pad2; -} xvSelectPortNotifyReq; -#define sz_xvSelectPortNotifyReq 12 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Drawable drawable B32; -} xvStopVideoReq; -#define sz_xvStopVideoReq 12 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Atom attribute B32; - INT32 value B32; -} xvSetPortAttributeReq; -#define sz_xvSetPortAttributeReq 16 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Atom attribute B32; -} xvGetPortAttributeReq; -#define sz_xvGetPortAttributeReq 12 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - CARD16 vid_w B16; - CARD16 vid_h B16; - CARD16 drw_w B16; - CARD16 drw_h B16; - CARD8 motion; - CARD8 pad1; - CARD16 pad2 B16; -} xvQueryBestSizeReq; -#define sz_xvQueryBestSizeReq 20 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; -} xvQueryPortAttributesReq; -#define sz_xvQueryPortAttributesReq 8 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Drawable drawable B32; - GContext gc B32; - CARD32 id B32; - INT16 src_x B16; - INT16 src_y B16; - CARD16 src_w B16; - CARD16 src_h B16; - INT16 drw_x B16; - INT16 drw_y B16; - CARD16 drw_w B16; - CARD16 drw_h B16; - CARD16 width B16; - CARD16 height B16; -} xvPutImageReq; -#define sz_xvPutImageReq 40 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; - Drawable drawable B32; - GContext gc B32; - ShmSeg shmseg B32; - CARD32 id B32; - CARD32 offset B32; - INT16 src_x B16; - INT16 src_y B16; - CARD16 src_w B16; - CARD16 src_h B16; - INT16 drw_x B16; - INT16 drw_y B16; - CARD16 drw_w B16; - CARD16 drw_h B16; - CARD16 width B16; - CARD16 height B16; - CARD8 send_event; - CARD8 pad1; - CARD16 pad2 B16; -} xvShmPutImageReq; -#define sz_xvShmPutImageReq 52 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - XvPortID port B32; -} xvListImageFormatsReq; -#define sz_xvListImageFormatsReq 8 - -typedef struct -{ - CARD8 reqType; - CARD8 xvReqType; - CARD16 length B16; - CARD32 port B32; - CARD32 id B32; - CARD16 width B16; - CARD16 height B16; -} xvQueryImageAttributesReq; -#define sz_xvQueryImageAttributesReq 16 - - -/* Replies */ - -typedef struct _QueryExtensionReply -{ - BYTE type; /* X_Reply */ - CARD8 padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 version B16; - CARD16 revision B16; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvQueryExtensionReply; -#define sz_xvQueryExtensionReply 32 - -typedef struct _QueryAdaptorsReply -{ - BYTE type; /* X_Reply */ - CARD8 padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 num_adaptors B16; - CARD16 pads3 B16; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvQueryAdaptorsReply; -#define sz_xvQueryAdaptorsReply 32 - -typedef struct _QueryEncodingsReply -{ - BYTE type; /* X_Reply */ - CARD8 padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 num_encodings B16; - CARD32 padl3 B32; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvQueryEncodingsReply; -#define sz_xvQueryEncodingsReply 32 - -typedef struct -{ - BYTE type; /* X_Reply */ - BYTE result; - CARD16 sequenceNumber B16; - CARD32 length B32; /* 0 */ - CARD32 padl3 B32; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvGrabPortReply; -#define sz_xvGrabPortReply 32 - -typedef struct -{ - BYTE type; /* X_Reply */ - BYTE padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; /* 0 */ - INT32 value B32; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvGetPortAttributeReply; -#define sz_xvGetPortAttributeReply 32 - -typedef struct -{ - BYTE type; /* X_Reply */ - BYTE padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; /* 0 */ - CARD16 actual_width B16; - CARD16 actual_height B16; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvQueryBestSizeReply; -#define sz_xvQueryBestSizeReply 32 - -typedef struct -{ - BYTE type; /* X_Reply */ - BYTE padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; /* 0 */ - CARD32 num_attributes B32; - CARD32 text_size B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvQueryPortAttributesReply; -#define sz_xvQueryPortAttributesReply 32 - -typedef struct -{ - BYTE type; /* X_Reply */ - BYTE padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 num_formats B32; - CARD32 padl4 B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvListImageFormatsReply; -#define sz_xvListImageFormatsReply 32 - -typedef struct -{ - BYTE type; /* X_Reply */ - BYTE padb1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 num_planes B32; - CARD32 data_size B32; - CARD16 width B16; - CARD16 height B16; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; -} xvQueryImageAttributesReply; -#define sz_xvQueryImageAttributesReply 32 - -/* DEFINE EVENT STRUCTURE */ - -typedef struct -{ - union - { - struct - { - BYTE type; - BYTE detail; - CARD16 sequenceNumber B16; - } u; - struct - { - BYTE type; - BYTE reason; - CARD16 sequenceNumber B16; - Time time B32; - Drawable drawable B32; - XvPortID port B32; - CARD32 padl5 B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; - } videoNotify; - struct - { - BYTE type; - BYTE padb1; - CARD16 sequenceNumber B16; - Time time B32; - XvPortID port B32; - Atom attribute B32; - INT32 value B32; - CARD32 padl6 B32; - CARD32 padl7 B32; - CARD32 padl8 B32; - } portNotify; - } u; -} xvEvent; - -#undef XvPortID -#undef XvEncodingID -#undef ShmSeg -#undef VisualID -#undef Drawable -#undef GContext -#undef Time -#undef Atom - -#endif /* XVPROTO_H */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/extutil.h b/project/jni/sdl-1.3/src/video/Xext/extensions/extutil.h deleted file mode 100644 index 1b78623e0..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/extutil.h +++ /dev/null @@ -1,230 +0,0 @@ -/* - * $Xorg: extutil.h,v 1.4 2001/02/09 02:03:24 xorgcvs Exp $ - * -Copyright 1989, 1998 The Open Group - -Permission to use, copy, modify, distribute, and sell this software and its -documentation for any purpose is hereby granted without fee, provided that -the above copyright notice appear in all copies and that both that -copyright notice and this permission notice appear in supporting -documentation. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN -AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN -CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of The Open Group shall not be -used in advertising or otherwise to promote the sale, use or other dealings -in this Software without prior written authorization from The Open Group. - * - * Author: Jim Fulton, MIT The Open Group - * - * Xlib Extension-Writing Utilities - * - * This package contains utilities for writing the client API for various - * protocol extensions. THESE INTERFACES ARE NOT PART OF THE X STANDARD AND - * ARE SUBJECT TO CHANGE! - */ -/* $XFree86: xc/include/extensions/extutil.h,v 1.9 2001/12/14 19:53:28 dawes Exp $ */ - -#ifndef _EXTUTIL_H_ -#define _EXTUTIL_H_ - -#include "SDL_stdinc.h" /* For portable string functions */ - -#include "./Xext.h" - -/* - * We need to keep a list of open displays since the Xlib display list isn't - * public. We also have to per-display info in a separate block since it isn't - * stored directly in the Display structure. - */ -typedef struct _XExtDisplayInfo -{ - struct _XExtDisplayInfo *next; /* keep a linked list */ - Display *display; /* which display this is */ - XExtCodes *codes; /* the extension protocol codes */ - XPointer data; /* extra data for extension to use */ -} XExtDisplayInfo; - -typedef struct _XExtensionInfo -{ - XExtDisplayInfo *head; /* start of list */ - XExtDisplayInfo *cur; /* most recently used */ - int ndisplays; /* number of displays */ -} XExtensionInfo; - -typedef struct _XExtensionHooks -{ - int (*create_gc) ( -#if NeedNestedPrototypes - Display * /* display */ , - GC /* gc */ , - XExtCodes * /* codes */ -#endif - ); - int (*copy_gc) ( -#if NeedNestedPrototypes - Display * /* display */ , - GC /* gc */ , - XExtCodes * /* codes */ -#endif - ); - int (*flush_gc) ( -#if NeedNestedPrototypes - Display * /* display */ , - GC /* gc */ , - XExtCodes * /* codes */ -#endif - ); - int (*free_gc) ( -#if NeedNestedPrototypes - Display * /* display */ , - GC /* gc */ , - XExtCodes * /* codes */ -#endif - ); - int (*create_font) ( -#if NeedNestedPrototypes - Display * /* display */ , - XFontStruct * /* fs */ , - XExtCodes * /* codes */ -#endif - ); - int (*free_font) ( -#if NeedNestedPrototypes - Display * /* display */ , - XFontStruct * /* fs */ , - XExtCodes * /* codes */ -#endif - ); - int (*close_display) ( -#if NeedNestedPrototypes - Display * /* display */ , - XExtCodes * /* codes */ -#endif - ); - Bool(*wire_to_event) ( -#if NeedNestedPrototypes - Display * /* display */ , - XEvent * /* re */ , - xEvent * /* event */ -#endif - ); - Status(*event_to_wire) ( -#if NeedNestedPrototypes - Display * /* display */ , - XEvent * /* re */ , - xEvent * /* event */ -#endif - ); - int (*error) ( -#if NeedNestedPrototypes - Display * /* display */ , - xError * /* err */ , - XExtCodes * /* codes */ , - int * /* ret_code */ -#endif - ); - char *(*error_string) ( -#if NeedNestedPrototypes - Display * /* display */ , - int /* code */ , - XExtCodes * /* codes */ , - char * /* buffer */ , - int /* nbytes */ -#endif - ); -} XExtensionHooks; - -extern XExtensionInfo *XextCreateExtension( -#if NeedFunctionPrototypes - void -#endif - ); -extern void XextDestroyExtension( -#if NeedFunctionPrototypes - XExtensionInfo * /* info */ -#endif - ); -extern XExtDisplayInfo *XextAddDisplay( -#if NeedFunctionPrototypes - XExtensionInfo * /* extinfo */ , - Display * /* dpy */ , - char * /* ext_name */ , - XExtensionHooks * /* hooks */ , - int /* nevents */ , - XPointer /* data */ -#endif - ); -extern int XextRemoveDisplay( -#if NeedFunctionPrototypes - XExtensionInfo * /* extinfo */ , - Display * /* dpy */ -#endif - ); -extern XExtDisplayInfo *XextFindDisplay( -#if NeedFunctionPrototypes - XExtensionInfo * /* extinfo */ , - Display * /* dpy */ -#endif - ); - -#define XextHasExtension(i) ((i) && ((i)->codes)) -#define XextCheckExtension(dpy,i,name,val) \ - if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return val; } -#define XextSimpleCheckExtension(dpy,i,name) \ - if (!XextHasExtension(i)) { XMissingExtension (dpy, name); return; } - - -/* - * helper macros to generate code that is common to all extensions; caller - * should prefix it with static if extension source is in one file; this - * could be a utility function, but have to stack 6 unused arguments for - * something that is called many, many times would be bad. - */ -#define XEXT_GENERATE_FIND_DISPLAY(proc,extinfo,extname,hooks,nev,data) \ -XExtDisplayInfo *proc (Display *dpy) \ -{ \ - XExtDisplayInfo *dpyinfo; \ - if (!extinfo) { if (!(extinfo = XextCreateExtension())) return NULL; } \ - if (!(dpyinfo = XextFindDisplay (extinfo, dpy))) \ - dpyinfo = XextAddDisplay (extinfo,dpy,extname,hooks,nev,data); \ - return dpyinfo; \ -} - -#define XEXT_FIND_DISPLAY_PROTO(proc) \ - XExtDisplayInfo *proc(Display *dpy) - -#define XEXT_GENERATE_CLOSE_DISPLAY(proc,extinfo) \ -int proc (Display *dpy, XExtCodes *codes) \ -{ \ - return XextRemoveDisplay (extinfo, dpy); \ -} - -#define XEXT_CLOSE_DISPLAY_PROTO(proc) \ - int proc(Display *dpy, XExtCodes *codes) - -#define XEXT_GENERATE_ERROR_STRING(proc,extname,nerr,errl) \ -char *proc (Display *dpy, int code, XExtCodes *codes, char *buf, int n) \ -{ \ - code -= codes->first_error; \ - if (code >= 0 && code < nerr) { \ - char tmp[256]; \ - SDL_snprintf (tmp, SDL_arraysize(tmp), "%s.%d", extname, code); \ - XGetErrorDatabaseText (dpy, "XProtoError", tmp, errl[code], buf, n); \ - return buf; \ - } \ - return (char *)0; \ -} - -#define XEXT_ERROR_STRING_PROTO(proc) \ - char *proc(Display *dpy, int code, XExtCodes *codes, char *buf, int n) -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/panoramiXext.h b/project/jni/sdl-1.3/src/video/Xext/extensions/panoramiXext.h deleted file mode 100644 index 37d04a531..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/panoramiXext.h +++ /dev/null @@ -1,56 +0,0 @@ -/* $Xorg: panoramiXext.h,v 1.4 2000/08/18 04:05:45 coskrey Exp $ */ -/***************************************************************** -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. -******************************************************************/ -/* - * PanoramiX definitions - */ -/* $XFree86: xc/include/extensions/panoramiXext.h,v 3.6 2001/01/17 17:53:22 dawes Exp $ */ - -#include "SDL_name.h" - -/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ - -#define PANORAMIX_MAJOR_VERSION 1 /* current version number */ -#define PANORAMIX_MINOR_VERSION 1 - -typedef struct -{ - Window window; /* PanoramiX window - may not exist */ - int screen; - int State; /* PanroamiXOff, PanoramiXOn */ - int width; /* width of this screen */ - int height; /* height of this screen */ - int ScreenCount; /* real physical number of screens */ - XID eventMask; /* selected events for this client */ -} SDL_NAME(XPanoramiXInfo); - -extern -SDL_NAME(XPanoramiXInfo) * -SDL_NAME(XPanoramiXAllocInfo) ( -#if NeedFunctionPrototypes - void -#endif - ); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/panoramiXproto.h b/project/jni/sdl-1.3/src/video/Xext/extensions/panoramiXproto.h deleted file mode 100644 index 69a0ce3f5..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/panoramiXproto.h +++ /dev/null @@ -1,206 +0,0 @@ -/* $Xorg: panoramiXproto.h,v 1.4 2000/08/18 04:05:45 coskrey Exp $ */ -/***************************************************************** -Copyright (c) 1991, 1997 Digital Equipment Corporation, Maynard, Massachusetts. -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software. - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -DIGITAL EQUIPMENT CORPORATION BE LIABLE FOR ANY CLAIM, DAMAGES, INCLUDING, -BUT NOT LIMITED TO CONSEQUENTIAL OR INCIDENTAL DAMAGES, OR OTHER LIABILITY, -WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR -IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Digital Equipment Corporation -shall not be used in advertising or otherwise to promote the sale, use or other -dealings in this Software without prior written authorization from Digital -Equipment Corporation. -******************************************************************/ -/* $XFree86: xc/include/extensions/panoramiXproto.h,v 3.6 2001/01/17 17:53:22 dawes Exp $ */ - -/* THIS IS NOT AN X PROJECT TEAM SPECIFICATION */ - -#ifndef _PANORAMIXPROTO_H_ -#define _PANORAMIXPROTO_H_ - -#define PANORAMIX_PROTOCOL_NAME "XINERAMA" - -#define X_PanoramiXQueryVersion 0 -#define X_PanoramiXGetState 1 -#define X_PanoramiXGetScreenCount 2 -#define X_PanoramiXGetScreenSize 3 - -#define X_XineramaIsActive 4 -#define X_XineramaQueryScreens 5 - -typedef struct _PanoramiXQueryVersion -{ - CARD8 reqType; /* always PanoramiXReqCode */ - CARD8 panoramiXReqType; /* always X_PanoramiXQueryVersion */ - CARD16 length B16; - CARD8 clientMajor; - CARD8 clientMinor; - CARD16 unused B16; -} xPanoramiXQueryVersionReq; - -#define sz_xPanoramiXQueryVersionReq 8 - -typedef struct -{ - CARD8 type; /* must be X_Reply */ - CARD8 pad1; /* unused */ - CARD16 sequenceNumber B16; /* last sequence number */ - CARD32 length B32; /* 0 */ - CARD16 majorVersion B16; - CARD16 minorVersion B16; - CARD32 pad2 B32; /* unused */ - CARD32 pad3 B32; /* unused */ - CARD32 pad4 B32; /* unused */ - CARD32 pad5 B32; /* unused */ - CARD32 pad6 B32; /* unused */ -} xPanoramiXQueryVersionReply; - -#define sz_xPanoramiXQueryVersionReply 32 - - -typedef struct _PanoramiXGetState -{ - CARD8 reqType; /* always PanoramiXReqCode */ - CARD8 panoramiXReqType; /* always X_PanoramiXGetState */ - CARD16 length B16; - CARD32 window B32; -} xPanoramiXGetStateReq; -#define sz_xPanoramiXGetStateReq 8 - -typedef struct -{ - BYTE type; - BYTE state; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 window B32; - CARD32 pad1 B32; /* unused */ - CARD32 pad2 B32; /* unused */ - CARD32 pad3 B32; /* unused */ - CARD32 pad4 B32; /* unused */ - CARD32 pad5 B32; /* unused */ -} xPanoramiXGetStateReply; - -#define sz_panoramiXGetStateReply 32 - -typedef struct _PanoramiXGetScreenCount -{ - CARD8 reqType; /* always PanoramiXReqCode */ - CARD8 panoramiXReqType; /* always X_PanoramiXGetScreenCount */ - CARD16 length B16; - CARD32 window B32; -} xPanoramiXGetScreenCountReq; -#define sz_xPanoramiXGetScreenCountReq 8 - -typedef struct -{ - BYTE type; - BYTE ScreenCount; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 window B32; - CARD32 pad1 B32; /* unused */ - CARD32 pad2 B32; /* unused */ - CARD32 pad3 B32; /* unused */ - CARD32 pad4 B32; /* unused */ - CARD32 pad5 B32; /* unused */ -} xPanoramiXGetScreenCountReply; -#define sz_panoramiXGetScreenCountReply 32 - -typedef struct _PanoramiXGetScreenSize -{ - CARD8 reqType; /* always PanoramiXReqCode */ - CARD8 panoramiXReqType; /* always X_PanoramiXGetState */ - CARD16 length B16; - CARD32 window B32; - CARD32 screen B32; -} xPanoramiXGetScreenSizeReq; -#define sz_xPanoramiXGetScreenSizeReq 12 - -typedef struct -{ - BYTE type; - CARD8 pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 width B32; - CARD32 height B32; - CARD32 window B32; - CARD32 screen B32; - CARD32 pad2 B32; /* unused */ - CARD32 pad3 B32; /* unused */ -} xPanoramiXGetScreenSizeReply; -#define sz_panoramiXGetScreenSizeReply 32 - -/************ Alternate protocol ******************/ - -typedef struct -{ - CARD8 reqType; - CARD8 panoramiXReqType; - CARD16 length B16; -} xXineramaIsActiveReq; -#define sz_xXineramaIsActiveReq 4 - -typedef struct -{ - BYTE type; - CARD8 pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 state B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXineramaIsActiveReply; -#define sz_XineramaIsActiveReply 32 - - -typedef struct -{ - CARD8 reqType; - CARD8 panoramiXReqType; - CARD16 length B16; -} xXineramaQueryScreensReq; -#define sz_xXineramaQueryScreensReq 4 - -typedef struct -{ - BYTE type; - CARD8 pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 number B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXineramaQueryScreensReply; -#define sz_XineramaQueryScreensReply 32 - -typedef struct -{ - INT16 x_org B16; - INT16 y_org B16; - CARD16 width B16; - CARD16 height B16; -} xXineramaScreenInfo; -#define sz_XineramaScreenInfo 8 - -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga.h b/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga.h deleted file mode 100644 index e64056061..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga.h +++ /dev/null @@ -1,221 +0,0 @@ -/* - Copyright (c) 1999 XFree86 Inc -*/ -/* $XFree86: xc/include/extensions/xf86dga.h,v 3.21 2001/08/01 00:44:36 tsi Exp $ */ - -#ifndef _XF86DGA_H_ -#define _XF86DGA_H_ - -#include -#include "xf86dga1.h" -#include "SDL_name.h" - -#define X_XDGAQueryVersion 0 - -/* 1 through 9 are in xf86dga1.h */ - -/* 10 and 11 are reserved to avoid conflicts with rogue DGA extensions */ - -#define X_XDGAQueryModes 12 -#define X_XDGASetMode 13 -#define X_XDGASetViewport 14 -#define X_XDGAInstallColormap 15 -#define X_XDGASelectInput 16 -#define X_XDGAFillRectangle 17 -#define X_XDGACopyArea 18 -#define X_XDGACopyTransparentArea 19 -#define X_XDGAGetViewportStatus 20 -#define X_XDGASync 21 -#define X_XDGAOpenFramebuffer 22 -#define X_XDGACloseFramebuffer 23 -#define X_XDGASetClientVersion 24 -#define X_XDGAChangePixmapMode 25 -#define X_XDGACreateColormap 26 - - -#define XDGAConcurrentAccess 0x00000001 -#define XDGASolidFillRect 0x00000002 -#define XDGABlitRect 0x00000004 -#define XDGABlitTransRect 0x00000008 -#define XDGAPixmap 0x00000010 - -#define XDGAInterlaced 0x00010000 -#define XDGADoublescan 0x00020000 - -#define XDGAFlipImmediate 0x00000001 -#define XDGAFlipRetrace 0x00000002 - -#define XDGANeedRoot 0x00000001 - -#define XF86DGANumberEvents 7 - -#define XDGAPixmapModeLarge 0 -#define XDGAPixmapModeSmall 1 - -#define XF86DGAClientNotLocal 0 -#define XF86DGANoDirectVideoMode 1 -#define XF86DGAScreenNotActive 2 -#define XF86DGADirectNotActivated 3 -#define XF86DGAOperationNotSupported 4 -#define XF86DGANumberErrors (XF86DGAOperationNotSupported + 1) - - -typedef struct -{ - int num; /* A unique identifier for the mode (num > 0) */ - char *name; /* name of mode given in the XF86Config */ - float verticalRefresh; - int flags; /* DGA_CONCURRENT_ACCESS, etc... */ - int imageWidth; /* linear accessible portion (pixels) */ - int imageHeight; - int pixmapWidth; /* Xlib accessible portion (pixels) */ - int pixmapHeight; /* both fields ignored if no concurrent access */ - int bytesPerScanline; - int byteOrder; /* MSBFirst, LSBFirst */ - int depth; - int bitsPerPixel; - unsigned long redMask; - unsigned long greenMask; - unsigned long blueMask; - short visualClass; - int viewportWidth; - int viewportHeight; - int xViewportStep; /* viewport position granularity */ - int yViewportStep; - int maxViewportX; /* max viewport origin */ - int maxViewportY; - int viewportFlags; /* types of page flipping possible */ - int reserved1; - int reserved2; -} SDL_NAME(XDGAMode); - - -typedef struct -{ - SDL_NAME(XDGAMode) mode; - unsigned char *data; - Pixmap pixmap; -} SDL_NAME(XDGADevice); - - -#ifndef _XF86DGA_SERVER_ -_XFUNCPROTOBEGIN typedef struct -{ - int type; - unsigned long serial; - Display *display; - int screen; - Time time; - unsigned int state; - unsigned int button; -} SDL_NAME(XDGAButtonEvent); - -typedef struct -{ - int type; - unsigned long serial; - Display *display; - int screen; - Time time; - unsigned int state; - unsigned int keycode; -} SDL_NAME(XDGAKeyEvent); - -typedef struct -{ - int type; - unsigned long serial; - Display *display; - int screen; - Time time; - unsigned int state; - int dx; - int dy; -} SDL_NAME(XDGAMotionEvent); - -typedef union -{ - int type; - SDL_NAME(XDGAButtonEvent) xbutton; - SDL_NAME(XDGAKeyEvent) xkey; - SDL_NAME(XDGAMotionEvent) xmotion; - long pad[24]; -} SDL_NAME(XDGAEvent); - -Bool SDL_NAME(XDGAQueryExtension) (Display * dpy, - int *eventBase, int *erroBase); - -Bool SDL_NAME(XDGAQueryVersion) (Display * dpy, - int *majorVersion, int *minorVersion); - -SDL_NAME(XDGAMode) * SDL_NAME(XDGAQueryModes) (Display * dpy, - int screen, int *num); - -SDL_NAME(XDGADevice) * SDL_NAME(XDGASetMode) (Display * dpy, - int screen, int mode); - -Bool -SDL_NAME(XDGAOpenFramebuffer) (Display * dpy, int screen); - - void SDL_NAME(XDGACloseFramebuffer) (Display * dpy, int screen); - - void SDL_NAME(XDGASetViewport) (Display * dpy, - int screen, int x, int y, int flags); - - void SDL_NAME(XDGAInstallColormap) (Display * dpy, - int screen, Colormap cmap); - -Colormap -SDL_NAME(XDGACreateColormap) (Display * dpy, - int screen, - SDL_NAME(XDGADevice) * device, int alloc); - - void SDL_NAME(XDGASelectInput) (Display * dpy, int screen, - long event_mask); - - void SDL_NAME(XDGAFillRectangle) (Display * dpy, - int screen, - int x, - int y, - unsigned int width, - unsigned int height, - unsigned long color); - - - void SDL_NAME(XDGACopyArea) (Display * dpy, - int screen, - int srcx, - int srcy, - unsigned int width, - unsigned int height, int dstx, int dsty); - - - void SDL_NAME(XDGACopyTransparentArea) (Display * dpy, - int screen, - int srcx, - int srcy, - unsigned int width, - unsigned int height, - int dstx, - int dsty, unsigned long key); - - int SDL_NAME(XDGAGetViewportStatus) (Display * dpy, int screen); - - void SDL_NAME(XDGASync) (Display * dpy, int screen); - -Bool -SDL_NAME(XDGASetClientVersion) (Display * dpy); - - void SDL_NAME(XDGAChangePixmapMode) (Display * dpy, - int screen, int *x, int *y, - int mode); - - - void SDL_NAME(XDGAKeyEventToXKeyEvent) (SDL_NAME(XDGAKeyEvent) * dk, - XKeyEvent * xk); - - -_XFUNCPROTOEND -#endif /* _XF86DGA_SERVER_ */ -#endif /* _XF86DGA_H_ */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga1.h b/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga1.h deleted file mode 100644 index 976378743..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga1.h +++ /dev/null @@ -1,167 +0,0 @@ -/* $XFree86: xc/include/extensions/xf86dga1.h,v 1.2 1999/04/17 07:05:41 dawes Exp $ */ -/* - -Copyright (c) 1995 Jon Tombs -Copyright (c) 1995 XFree86 Inc - -*/ - -/************************************************************************ - - THIS IS THE OLD DGA API AND IS OBSOLETE. PLEASE DO NOT USE IT ANYMORE - -************************************************************************/ - -#ifndef _XF86DGA1_H_ -#define _XF86DGA1_H_ - -#include -#include "SDL_name.h" - -#define X_XF86DGAQueryVersion 0 -#define X_XF86DGAGetVideoLL 1 -#define X_XF86DGADirectVideo 2 -#define X_XF86DGAGetViewPortSize 3 -#define X_XF86DGASetViewPort 4 -#define X_XF86DGAGetVidPage 5 -#define X_XF86DGASetVidPage 6 -#define X_XF86DGAInstallColormap 7 -#define X_XF86DGAQueryDirectVideo 8 -#define X_XF86DGAViewPortChanged 9 - -#define XF86DGADirectPresent 0x0001 -#define XF86DGADirectGraphics 0x0002 -#define XF86DGADirectMouse 0x0004 -#define XF86DGADirectKeyb 0x0008 -#define XF86DGAHasColormap 0x0100 -#define XF86DGADirectColormap 0x0200 - - - - -#ifndef _XF86DGA_SERVER_ - -_XFUNCPROTOBEGIN Bool SDL_NAME(XF86DGAQueryVersion) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int * - /* majorVersion */ , - int * /* minorVersion */ -#endif - ); - -Bool SDL_NAME(XF86DGAQueryExtension) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int * /* event_base */ , - int * /* error_base */ -#endif - ); - -Status SDL_NAME(XF86DGAGetVideoLL) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int * /* base addr */ , - int * /* width */ , - int * /* bank_size */ , - int * /* ram_size */ -#endif - ); - -Status SDL_NAME(XF86DGAGetVideo) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - char ** /* base addr */ , - int * /* width */ , - int * /* bank_size */ , - int * /* ram_size */ -#endif - ); - -Status SDL_NAME(XF86DGADirectVideo) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int /* enable */ -#endif - ); - -Status SDL_NAME(XF86DGADirectVideoLL) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int /* enable */ -#endif - ); - -Status SDL_NAME(XF86DGAGetViewPortSize) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int * /* width */ , - int * /* height */ -#endif - ); - -Status SDL_NAME(XF86DGASetViewPort) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int x /* X */ , - int y /* Y */ -#endif - ); - -Status SDL_NAME(XF86DGAGetVidPage) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int * /* vid page */ -#endif - ); - -Status SDL_NAME(XF86DGASetVidPage) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int /* vid page */ -#endif - ); - -Status SDL_NAME(XF86DGAInstallColormap) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - Colormap /*Colormap */ -#endif - ); - -int SDL_NAME(XF86DGAForkApp) ( -#if NeedFunctionPrototypes - int screen -#endif - ); - -Status SDL_NAME(XF86DGAQueryDirectVideo) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int * /* flags */ -#endif - ); - -Bool SDL_NAME(XF86DGAViewPortChanged) ( -#if NeedFunctionPrototypes - Display * /* dpy */ , - int /* screen */ , - int /* n */ -#endif - ); - - -_XFUNCPROTOEND -#endif /* _XF86DGA_SERVER_ */ -#endif /* _XF86DGA1_H_ */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga1str.h b/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga1str.h deleted file mode 100644 index 5ad889efc..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dga1str.h +++ /dev/null @@ -1,210 +0,0 @@ -/* $XFree86: xc/include/extensions/xf86dga1str.h,v 1.2 1999/05/03 12:15:37 dawes Exp $ */ -/* - -Copyright (c) 1995 Jon Tombs -Copyright (c) 1995 XFree86 Inc. - -*/ - -#ifndef _XF86DGASTR1_H_ -#define _XF86DGASTR1_H_ - -typedef struct _XF86DGAQueryVersion -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_DGAQueryVersion */ - CARD16 length B16; -} xXF86DGAQueryVersionReq; -#define sz_xXF86DGAQueryVersionReq 4 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of DGA protocol */ - CARD16 minorVersion B16; /* minor version of DGA protocol */ - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86DGAQueryVersionReply; -#define sz_xXF86DGAQueryVersionReply 32 - -typedef struct _XF86DGAGetVideoLL -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_XF86DGAGetVideoLL */ - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; -} xXF86DGAGetVideoLLReq; -#define sz_xXF86DGAGetVideoLLReq 8 - -typedef struct _XF86DGAInstallColormap -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD16 screen B16; - CARD16 pad2; - CARD32 id B32; /* colormap. */ -} xXF86DGAInstallColormapReq; -#define sz_xXF86DGAInstallColormapReq 12 - - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 offset B32; - CARD32 width B32; - CARD32 bank_size B32; - CARD32 ram_size B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXF86DGAGetVideoLLReply; -#define sz_xXF86DGAGetVideoLLReply 32 - -typedef struct _XF86DGADirectVideo -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_XF86DGADirectVideo */ - CARD16 length B16; - CARD16 screen B16; - CARD16 enable B16; -} xXF86DGADirectVideoReq; -#define sz_xXF86DGADirectVideoReq 8 - - -typedef struct _XF86DGAGetViewPortSize -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_XF86DGAGetViewPort */ - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; -} xXF86DGAGetViewPortSizeReq; -#define sz_xXF86DGAGetViewPortSizeReq 8 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 width B32; - CARD32 height B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXF86DGAGetViewPortSizeReply; -#define sz_xXF86DGAGetViewPortSizeReply 32 - -typedef struct _XF86DGASetViewPort -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_XF86DGASetViewPort */ - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; - CARD32 x B32; - CARD32 y B32; -} xXF86DGASetViewPortReq; -#define sz_xXF86DGASetViewPortReq 16 - -typedef struct _XF86DGAGetVidPage -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_XF86DGAGetVidPage */ - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; -} xXF86DGAGetVidPageReq; -#define sz_xXF86DGAGetVidPageReq 8 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 vpage B32; - CARD32 pad B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXF86DGAGetVidPageReply; -#define sz_xXF86DGAGetVidPageReply 32 - - -typedef struct _XF86DGASetVidPage -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_XF86DGASetVidPage */ - CARD16 length B16; - CARD16 screen B16; - CARD16 vpage B16; -} xXF86DGASetVidPageReq; -#define sz_xXF86DGASetVidPageReq 8 - - -typedef struct _XF86DGAQueryDirectVideo -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_DGAQueryVersion */ - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; -} xXF86DGAQueryDirectVideoReq; -#define sz_xXF86DGAQueryDirectVideoReq 8 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 flags B32; - CARD32 pad B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXF86DGAQueryDirectVideoReply; -#define sz_xXF86DGAQueryDirectVideoReply 32 - - -typedef struct _XF86DGAViewPortChanged -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_DGAQueryVersion */ - CARD16 length B16; - CARD16 screen B16; - CARD16 n B16; -} xXF86DGAViewPortChangedReq; -#define sz_xXF86DGAViewPortChangedReq 8 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 result B32; - CARD32 pad B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXF86DGAViewPortChangedReply; -#define sz_xXF86DGAViewPortChangedReply 32 - -#endif /* _XF86DGASTR1_H_ */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dgastr.h b/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dgastr.h deleted file mode 100644 index 9546b4f8d..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86dgastr.h +++ /dev/null @@ -1,372 +0,0 @@ -/* $XFree86: xc/include/extensions/xf86dgastr.h,v 3.14 2001/08/01 00:44:36 tsi Exp $ */ -/* - -Copyright (c) 1995 Jon Tombs -Copyright (c) 1995 XFree86 Inc. - -*/ - -#ifndef _XF86DGASTR_H_ -#define _XF86DGASTR_H_ - -#include "xf86dga1str.h" - -#define XF86DGANAME "XFree86-DGA" - -#define XDGA_MAJOR_VERSION 2 /* current version numbers */ -#define XDGA_MINOR_VERSION 0 - - -typedef struct _XDGAQueryVersion -{ - CARD8 reqType; /* always DGAReqCode */ - CARD8 dgaReqType; /* always X_DGAQueryVersion */ - CARD16 length B16; -} xXDGAQueryVersionReq; -#define sz_xXDGAQueryVersionReq 4 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of DGA protocol */ - CARD16 minorVersion B16; /* minor version of DGA protocol */ - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXDGAQueryVersionReply; -#define sz_xXDGAQueryVersionReply 32 - -typedef struct _XDGAQueryModes -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; -} xXDGAQueryModesReq; -#define sz_xXDGAQueryModesReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 number B32; /* number of modes available */ - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXDGAQueryModesReply; -#define sz_xXDGAQueryModesReply 32 - - -typedef struct _XDGASetMode -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 mode B32; /* mode number to init */ - CARD32 pid B32; /* Pixmap descriptor */ -} xXDGASetModeReq; -#define sz_xXDGASetModeReq 16 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 offset B32; /* offset into framebuffer map */ - CARD32 flags B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXDGASetModeReply; -#define sz_xXDGASetModeReply 32 - -typedef struct -{ - CARD8 byte_order; - CARD8 depth; - CARD16 num B16; - CARD16 bpp B16; - CARD16 name_size B16; - CARD32 vsync_num B32; - CARD32 vsync_den B32; - CARD32 flags B32; - CARD16 image_width B16; - CARD16 image_height B16; - CARD16 pixmap_width B16; - CARD16 pixmap_height B16; - CARD32 bytes_per_scanline B32; - CARD32 red_mask B32; - CARD32 green_mask B32; - CARD32 blue_mask B32; - CARD16 visual_class B16; - CARD16 pad1 B16; - CARD16 viewport_width B16; - CARD16 viewport_height B16; - CARD16 viewport_xstep B16; - CARD16 viewport_ystep B16; - CARD16 viewport_xmax B16; - CARD16 viewport_ymax B16; - CARD32 viewport_flags B32; - CARD32 reserved1 B32; - CARD32 reserved2 B32; -} xXDGAModeInfo; -#define sz_xXDGAModeInfo 72 - -typedef struct _XDGAOpenFramebuffer -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; -} xXDGAOpenFramebufferReq; -#define sz_xXDGAOpenFramebufferReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; /* device name size if there is one */ - CARD32 mem1 B32; /* physical memory */ - CARD32 mem2 B32; /* spillover for _alpha_ */ - CARD32 size B32; /* size of map in bytes */ - CARD32 offset B32; /* optional offset into device */ - CARD32 extra B32; /* extra info associated with the map */ - CARD32 pad2 B32; -} xXDGAOpenFramebufferReply; -#define sz_xXDGAOpenFramebufferReply 32 - - -typedef struct _XDGACloseFramebuffer -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; -} xXDGACloseFramebufferReq; -#define sz_xXDGACloseFramebufferReq 8 - - -typedef struct _XDGASetViewport -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD16 x B16; - CARD16 y B16; - CARD32 flags B32; -} xXDGASetViewportReq; -#define sz_xXDGASetViewportReq 16 - - -typedef struct _XDGAInstallColormap -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 cmap B32; -} xXDGAInstallColormapReq; -#define sz_xXDGAInstallColormapReq 12 - -typedef struct _XDGASelectInput -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 mask B32; -} xXDGASelectInputReq; -#define sz_xXDGASelectInputReq 12 - -typedef struct _XDGAFillRectangle -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD16 x B16; - CARD16 y B16; - CARD16 width B16; - CARD16 height B16; - CARD32 color B32; -} xXDGAFillRectangleReq; -#define sz_xXDGAFillRectangleReq 20 - - -typedef struct _XDGACopyArea -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD16 srcx B16; - CARD16 srcy B16; - CARD16 width B16; - CARD16 height B16; - CARD16 dstx B16; - CARD16 dsty B16; -} xXDGACopyAreaReq; -#define sz_xXDGACopyAreaReq 20 - -typedef struct _XDGACopyTransparentArea -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD16 srcx B16; - CARD16 srcy B16; - CARD16 width B16; - CARD16 height B16; - CARD16 dstx B16; - CARD16 dsty B16; - CARD32 key B32; -} xXDGACopyTransparentAreaReq; -#define sz_xXDGACopyTransparentAreaReq 24 - - -typedef struct _XDGAGetViewportStatus -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; -} xXDGAGetViewportStatusReq; -#define sz_xXDGAGetViewportStatusReq 8 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 status B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXDGAGetViewportStatusReply; -#define sz_xXDGAGetViewportStatusReply 32 - -typedef struct _XDGASync -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; -} xXDGASyncReq; -#define sz_xXDGASyncReq 8 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; -} xXDGASyncReply; -#define sz_xXDGASyncReply 32 - -typedef struct _XDGASetClientVersion -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD16 major B16; - CARD16 minor B16; -} xXDGASetClientVersionReq; -#define sz_xXDGASetClientVersionReq 8 - - -typedef struct -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD16 x B16; - CARD16 y B16; - CARD32 flags B32; -} xXDGAChangePixmapModeReq; -#define sz_xXDGAChangePixmapModeReq 16 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 x B16; - CARD16 y B16; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; - CARD32 pad7 B32; -} xXDGAChangePixmapModeReply; -#define sz_xXDGAChangePixmapModeReply 32 - -typedef struct _XDGACreateColormap -{ - CARD8 reqType; - CARD8 dgaReqType; - CARD16 length B16; - CARD32 screen B32; - CARD32 id B32; - CARD32 mode B32; - CARD8 alloc; - CARD8 pad1; - CARD16 pad2; -} xXDGACreateColormapReq; -#define sz_xXDGACreateColormapReq 20 - - -typedef struct -{ - union - { - struct - { - BYTE type; - BYTE detail; - CARD16 sequenceNumber B16; - } u; - struct - { - CARD32 pad0 B32; - CARD32 time B32; - INT16 dx B16; - INT16 dy B16; - INT16 screen B16; - CARD16 state B16; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - } event; - } u; -} dgaEvent; - - -#endif /* _XF86DGASTR_H_ */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86vmode.h b/project/jni/sdl-1.3/src/video/Xext/extensions/xf86vmode.h deleted file mode 100644 index bedb47a9d..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86vmode.h +++ /dev/null @@ -1,298 +0,0 @@ -/* $XFree86: xc/include/extensions/xf86vmode.h,v 3.30 2001/05/07 20:09:50 mvojkovi Exp $ */ -/* - -Copyright 1995 Kaleb S. KEITHLEY - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Kaleb S. KEITHLEY -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -from Kaleb S. KEITHLEY - -*/ -/* $Xorg: xf86vmode.h,v 1.3 2000/08/18 04:05:46 coskrey Exp $ */ - -/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ - -#ifndef _XF86VIDMODE_H_ -#define _XF86VIDMODE_H_ - -#include -#include -#include "SDL_name.h" - -#define X_XF86VidModeQueryVersion 0 -#define X_XF86VidModeGetModeLine 1 -#define X_XF86VidModeModModeLine 2 -#define X_XF86VidModeSwitchMode 3 -#define X_XF86VidModeGetMonitor 4 -#define X_XF86VidModeLockModeSwitch 5 -#define X_XF86VidModeGetAllModeLines 6 -#define X_XF86VidModeAddModeLine 7 -#define X_XF86VidModeDeleteModeLine 8 -#define X_XF86VidModeValidateModeLine 9 -#define X_XF86VidModeSwitchToMode 10 -#define X_XF86VidModeGetViewPort 11 -#define X_XF86VidModeSetViewPort 12 -/* new for version 2.x of this extension */ -#define X_XF86VidModeGetDotClocks 13 -#define X_XF86VidModeSetClientVersion 14 -#define X_XF86VidModeSetGamma 15 -#define X_XF86VidModeGetGamma 16 -#define X_XF86VidModeGetGammaRamp 17 -#define X_XF86VidModeSetGammaRamp 18 -#define X_XF86VidModeGetGammaRampSize 19 - -#define CLKFLAG_PROGRAMABLE 1 - -#ifdef XF86VIDMODE_EVENTS -#define XF86VidModeNotify 0 -#define XF86VidModeNumberEvents (XF86VidModeNotify + 1) - -#define XF86VidModeNotifyMask 0x00000001 - -#define XF86VidModeNonEvent 0 -#define XF86VidModeModeChange 1 -#else -#define XF86VidModeNumberEvents 0 -#endif - -#define XF86VidModeBadClock 0 -#define XF86VidModeBadHTimings 1 -#define XF86VidModeBadVTimings 2 -#define XF86VidModeModeUnsuitable 3 -#define XF86VidModeExtensionDisabled 4 -#define XF86VidModeClientNotLocal 5 -#define XF86VidModeZoomLocked 6 -#define XF86VidModeNumberErrors (XF86VidModeZoomLocked + 1) - -#ifndef _XF86VIDMODE_SERVER_ - -typedef struct -{ - unsigned short hdisplay; - unsigned short hsyncstart; - unsigned short hsyncend; - unsigned short htotal; - unsigned short hskew; - unsigned short vdisplay; - unsigned short vsyncstart; - unsigned short vsyncend; - unsigned short vtotal; - unsigned int flags; - int privsize; -#if defined(__cplusplus) || defined(c_plusplus) - /* private is a C++ reserved word */ - INT32 *c_private; -#else - INT32 *private; -#endif -} SDL_NAME(XF86VidModeModeLine); - -typedef struct -{ - unsigned int dotclock; - unsigned short hdisplay; - unsigned short hsyncstart; - unsigned short hsyncend; - unsigned short htotal; - unsigned short hskew; - unsigned short vdisplay; - unsigned short vsyncstart; - unsigned short vsyncend; - unsigned short vtotal; - unsigned int flags; - int privsize; -#if defined(__cplusplus) || defined(c_plusplus) - /* private is a C++ reserved word */ - INT32 *c_private; -#else - INT32 *private; -#endif -} SDL_NAME(XF86VidModeModeInfo); - -typedef struct -{ - float hi; - float lo; -} SDL_NAME(XF86VidModeSyncRange); - -typedef struct -{ - char *vendor; - char *model; - float EMPTY; - unsigned char nhsync; - SDL_NAME(XF86VidModeSyncRange) * hsync; - unsigned char nvsync; - SDL_NAME(XF86VidModeSyncRange) * vsync; -} SDL_NAME(XF86VidModeMonitor); - -typedef struct -{ - int type; /* of event */ - unsigned long serial; /* # of last request processed by server */ - Bool send_event; /* true if this came from a SendEvent req */ - Display *display; /* Display the event was read from */ - Window root; /* root window of event screen */ - int state; /* What happened */ - int kind; /* What happened */ - Bool forced; /* extents of new region */ - Time time; /* event timestamp */ -} SDL_NAME(XF86VidModeNotifyEvent); - -typedef struct -{ - float red; /* Red Gamma value */ - float green; /* Green Gamma value */ - float blue; /* Blue Gamma value */ -} SDL_NAME(XF86VidModeGamma); - - -#define SDL_XF86VidModeSelectNextMode(disp, scr) \ - SDL_NAME(XF86VidModeSwitchMode)(disp, scr, 1) -#define SDL_XF86VidModeSelectPrevMode(disp, scr) \ - SDL_NAME(XF86VidModeSwitchMode)(disp, scr, -1) - -_XFUNCPROTOBEGIN Bool SDL_NAME(XF86VidModeQueryVersion) (Display * /* dpy */ , - int * - /* majorVersion */ , - int * /* minorVersion */ - ); - -Bool SDL_NAME(XF86VidModeQueryExtension) (Display * /* dpy */ , - int * /* event_base */ , - int * /* error_base */ - ); - -Bool SDL_NAME(XF86VidModeSetClientVersion) (Display * /* dpy */ - ); - -Bool SDL_NAME(XF86VidModeGetModeLine) (Display * /* dpy */ , - int /* screen */ , - int * /* dotclock */ , - SDL_NAME(XF86VidModeModeLine) * /* modeline */ - ); - -Bool SDL_NAME(XF86VidModeGetAllModeLines) (Display * /* dpy */ , - int /* screen */ , - int * /* modecount */ , - SDL_NAME(XF86VidModeModeInfo) *** /* modelinesPtr */ - ); - -Bool SDL_NAME(XF86VidModeAddModeLine) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME(XF86VidModeModeInfo) * - /* new modeline */ , - SDL_NAME(XF86VidModeModeInfo) * /* after modeline */ - ); - -Bool SDL_NAME(XF86VidModeDeleteModeLine) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME(XF86VidModeModeInfo) * /* modeline */ - ); - -Bool SDL_NAME(XF86VidModeModModeLine) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME(XF86VidModeModeLine) * /* modeline */ - ); - -Status SDL_NAME(XF86VidModeValidateModeLine) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME(XF86VidModeModeInfo) * /* modeline */ - ); - -Bool SDL_NAME(XF86VidModeSwitchMode) (Display * /* dpy */ , - int /* screen */ , - int /* zoom */ - ); - -Bool SDL_NAME(XF86VidModeSwitchToMode) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME(XF86VidModeModeInfo) * /* modeline */ - ); - -Bool SDL_NAME(XF86VidModeLockModeSwitch) (Display * /* dpy */ , - int /* screen */ , - int /* lock */ - ); - -Bool SDL_NAME(XF86VidModeGetMonitor) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME(XF86VidModeMonitor) * /* monitor */ - ); - -Bool SDL_NAME(XF86VidModeGetViewPort) (Display * /* dpy */ , - int /* screen */ , - int * /* x return */ , - int * /* y return */ - ); - -Bool SDL_NAME(XF86VidModeSetViewPort) (Display * /* dpy */ , - int /* screen */ , - int /* x */ , - int /* y */ - ); - -Bool SDL_NAME(XF86VidModeGetDotClocks) (Display * /* dpy */ , - int /* screen */ , - int * /* flags return */ , - int * /* number of clocks return */ , - int * /* max dot clock return */ , - int ** /* clocks return */ - ); - -Bool SDL_NAME(XF86VidModeGetGamma) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME(XF86VidModeGamma) * /* Gamma */ - ); - -Bool SDL_NAME(XF86VidModeSetGamma) (Display * /* dpy */ , - int /* screen */ , - SDL_NAME(XF86VidModeGamma) * /* Gamma */ - ); - -Bool SDL_NAME(XF86VidModeSetGammaRamp) (Display * /* dpy */ , - int /* screen */ , - int /* size */ , - unsigned short * /* red array */ , - unsigned short * /* green array */ , - unsigned short * /* blue array */ - ); - -Bool SDL_NAME(XF86VidModeGetGammaRamp) (Display * /* dpy */ , - int /* screen */ , - int /* size */ , - unsigned short * /* red array */ , - unsigned short * /* green array */ , - unsigned short * /* blue array */ - ); - -Bool SDL_NAME(XF86VidModeGetGammaRampSize) (Display * /* dpy */ , - int /* screen */ , - int * /* size */ - ); - - -_XFUNCPROTOEND -#endif -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86vmstr.h b/project/jni/sdl-1.3/src/video/Xext/extensions/xf86vmstr.h deleted file mode 100644 index b1f476d51..000000000 --- a/project/jni/sdl-1.3/src/video/Xext/extensions/xf86vmstr.h +++ /dev/null @@ -1,573 +0,0 @@ -/* $XFree86: xc/include/extensions/xf86vmstr.h,v 3.27 2001/08/01 00:44:36 tsi Exp $ */ -/* - -Copyright 1995 Kaleb S. KEITHLEY - -Permission is hereby granted, free of charge, to any person obtaining -a copy of this software and associated documentation files (the -"Software"), to deal in the Software without restriction, including -without limitation the rights to use, copy, modify, merge, publish, -distribute, sublicense, and/or sell copies of the Software, and to -permit persons to whom the Software is furnished to do so, subject to -the following conditions: - -The above copyright notice and this permission notice shall be -included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -IN NO EVENT SHALL Kaleb S. KEITHLEY BE LIABLE FOR ANY CLAIM, DAMAGES -OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -OTHER DEALINGS IN THE SOFTWARE. - -Except as contained in this notice, the name of Kaleb S. KEITHLEY -shall not be used in advertising or otherwise to promote the sale, use -or other dealings in this Software without prior written authorization -from Kaleb S. KEITHLEY - -*/ -/* $Xorg: xf86vmstr.h,v 1.3 2000/08/18 04:05:46 coskrey Exp $ */ - -/* THIS IS NOT AN X CONSORTIUM STANDARD OR AN X PROJECT TEAM SPECIFICATION */ - -#ifndef _XF86VIDMODESTR_H_ -#define _XF86VIDMODESTR_H_ - -#include "xf86vmode.h" - -#define XF86VIDMODENAME "XFree86-VidModeExtension" - -#define XF86VIDMODE_MAJOR_VERSION 2 /* current version numbers */ -#define XF86VIDMODE_MINOR_VERSION 1 -/* - * major version 0 == uses parameter-to-wire functions in XFree86 libXxf86vm. - * major version 1 == uses parameter-to-wire functions hard-coded in xvidtune - * client. - * major version 2 == uses new protocol version in XFree86 4.0. - */ - -typedef struct _XF86VidModeQueryVersion -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; /* always X_XF86VidModeQueryVersion */ - CARD16 length B16; -} xXF86VidModeQueryVersionReq; -#define sz_xXF86VidModeQueryVersionReq 4 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 majorVersion B16; /* major version of XF86VidMode */ - CARD16 minorVersion B16; /* minor version of XF86VidMode */ - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86VidModeQueryVersionReply; -#define sz_xXF86VidModeQueryVersionReply 32 - -typedef struct _XF86VidModeGetModeLine -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; -} xXF86VidModeGetModeLineReq, - xXF86VidModeGetAllModeLinesReq, - xXF86VidModeGetMonitorReq, - xXF86VidModeGetViewPortReq, xXF86VidModeGetDotClocksReq; -#define sz_xXF86VidModeGetModeLineReq 8 -#define sz_xXF86VidModeGetAllModeLinesReq 8 -#define sz_xXF86VidModeGetMonitorReq 8 -#define sz_xXF86VidModeGetViewPortReq 8 -#define sz_xXF86VidModeGetDotClocksReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 dotclock B32; - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 hskew B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD16 pad2 B16; - CARD32 flags B32; - CARD32 reserved1 B32; - CARD32 reserved2 B32; - CARD32 reserved3 B32; - CARD32 privsize B32; -} xXF86VidModeGetModeLineReply; -#define sz_xXF86VidModeGetModeLineReply 52 - -/* 0.x version */ -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 dotclock B32; - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD32 flags B32; - CARD32 privsize B32; -} xXF86OldVidModeGetModeLineReply; -#define sz_xXF86OldVidModeGetModeLineReply 36 - -typedef struct -{ - CARD32 dotclock B32; - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD32 hskew B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD16 pad1 B16; - CARD32 flags B32; - CARD32 reserved1 B32; - CARD32 reserved2 B32; - CARD32 reserved3 B32; - CARD32 privsize B32; -} xXF86VidModeModeInfo; - -/* 0.x version */ -typedef struct -{ - CARD32 dotclock B32; - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD32 flags B32; - CARD32 privsize B32; -} xXF86OldVidModeModeInfo; - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 modecount B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86VidModeGetAllModeLinesReply; -#define sz_xXF86VidModeGetAllModeLinesReply 32 - -typedef struct _XF86VidModeAddModeLine -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; /* always X_XF86VidModeAddMode */ - CARD16 length B16; - CARD32 screen B32; /* could be CARD16 but need the pad */ - CARD32 dotclock B32; - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 hskew B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD16 pad1 B16; - CARD32 flags B32; - CARD32 reserved1 B32; - CARD32 reserved2 B32; - CARD32 reserved3 B32; - CARD32 privsize B32; - CARD32 after_dotclock B32; - CARD16 after_hdisplay B16; - CARD16 after_hsyncstart B16; - CARD16 after_hsyncend B16; - CARD16 after_htotal B16; - CARD16 after_hskew B16; - CARD16 after_vdisplay B16; - CARD16 after_vsyncstart B16; - CARD16 after_vsyncend B16; - CARD16 after_vtotal B16; - CARD16 pad2 B16; - CARD32 after_flags B32; - CARD32 reserved4 B32; - CARD32 reserved5 B32; - CARD32 reserved6 B32; -} xXF86VidModeAddModeLineReq; -#define sz_xXF86VidModeAddModeLineReq 92 - -/* 0.x version */ -typedef struct _XF86OldVidModeAddModeLine -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; /* always X_XF86VidModeAddMode */ - CARD16 length B16; - CARD32 screen B32; /* could be CARD16 but need the pad */ - CARD32 dotclock B32; - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD32 flags B32; - CARD32 privsize B32; - CARD32 after_dotclock B32; - CARD16 after_hdisplay B16; - CARD16 after_hsyncstart B16; - CARD16 after_hsyncend B16; - CARD16 after_htotal B16; - CARD16 after_vdisplay B16; - CARD16 after_vsyncstart B16; - CARD16 after_vsyncend B16; - CARD16 after_vtotal B16; - CARD32 after_flags B32; -} xXF86OldVidModeAddModeLineReq; -#define sz_xXF86OldVidModeAddModeLineReq 60 - -typedef struct _XF86VidModeModModeLine -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; /* always X_XF86VidModeModModeLine */ - CARD16 length B16; - CARD32 screen B32; /* could be CARD16 but need the pad */ - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 hskew B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD16 pad1 B16; - CARD32 flags B32; - CARD32 reserved1 B32; - CARD32 reserved2 B32; - CARD32 reserved3 B32; - CARD32 privsize B32; -} xXF86VidModeModModeLineReq; -#define sz_xXF86VidModeModModeLineReq 48 - -/* 0.x version */ -typedef struct _XF86OldVidModeModModeLine -{ - CARD8 reqType; /* always XF86OldVidModeReqCode */ - CARD8 xf86vidmodeReqType; /* always X_XF86OldVidModeModModeLine */ - CARD16 length B16; - CARD32 screen B32; /* could be CARD16 but need the pad */ - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD32 flags B32; - CARD32 privsize B32; -} xXF86OldVidModeModModeLineReq; -#define sz_xXF86OldVidModeModModeLineReq 32 - -typedef struct _XF86VidModeValidateModeLine -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD32 screen B32; /* could be CARD16 but need the pad */ - CARD32 dotclock B32; - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 hskew B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD16 pad1 B16; - CARD32 flags B32; - CARD32 reserved1 B32; - CARD32 reserved2 B32; - CARD32 reserved3 B32; - CARD32 privsize B32; -} xXF86VidModeDeleteModeLineReq, - xXF86VidModeValidateModeLineReq, xXF86VidModeSwitchToModeReq; -#define sz_xXF86VidModeDeleteModeLineReq 52 -#define sz_xXF86VidModeValidateModeLineReq 52 -#define sz_xXF86VidModeSwitchToModeReq 52 - -/* 0.x version */ -typedef struct _XF86OldVidModeValidateModeLine -{ - CARD8 reqType; /* always XF86OldVidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD32 screen B32; /* could be CARD16 but need the pad */ - CARD32 dotclock B32; - CARD16 hdisplay B16; - CARD16 hsyncstart B16; - CARD16 hsyncend B16; - CARD16 htotal B16; - CARD16 vdisplay B16; - CARD16 vsyncstart B16; - CARD16 vsyncend B16; - CARD16 vtotal B16; - CARD32 flags B32; - CARD32 privsize B32; -} xXF86OldVidModeDeleteModeLineReq, - xXF86OldVidModeValidateModeLineReq, xXF86OldVidModeSwitchToModeReq; -#define sz_xXF86OldVidModeDeleteModeLineReq 36 -#define sz_xXF86OldVidModeValidateModeLineReq 36 -#define sz_xXF86OldVidModeSwitchToModeReq 36 - -typedef struct _XF86VidModeSwitchMode -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; /* always X_XF86VidModeSwitchMode */ - CARD16 length B16; - CARD16 screen B16; - CARD16 zoom B16; -} xXF86VidModeSwitchModeReq; -#define sz_xXF86VidModeSwitchModeReq 8 - -typedef struct _XF86VidModeLockModeSwitch -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; /* always X_XF86VidModeLockModeSwitch */ - CARD16 length B16; - CARD16 screen B16; - CARD16 lock B16; -} xXF86VidModeLockModeSwitchReq; -#define sz_xXF86VidModeLockModeSwitchReq 8 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 status B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86VidModeValidateModeLineReply; -#define sz_xXF86VidModeValidateModeLineReply 32 - -typedef struct -{ - BYTE type; /* X_Reply */ - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD8 vendorLength; - CARD8 modelLength; - CARD8 nhsync; - CARD8 nvsync; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86VidModeGetMonitorReply; -#define sz_xXF86VidModeGetMonitorReply 32 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 x B32; - CARD32 y B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXF86VidModeGetViewPortReply; -#define sz_xXF86VidModeGetViewPortReply 32 - -typedef struct _XF86VidModeSetViewPort -{ - CARD8 reqType; /* always VidModeReqCode */ - CARD8 xf86vidmodeReqType; /* always X_XF86VidModeSetViewPort */ - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; - CARD32 x B32; - CARD32 y B32; -} xXF86VidModeSetViewPortReq; -#define sz_xXF86VidModeSetViewPortReq 16 - -typedef struct -{ - BYTE type; - BOOL pad1; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 flags B32; - CARD32 clocks B32; - CARD32 maxclocks B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; -} xXF86VidModeGetDotClocksReply; -#define sz_xXF86VidModeGetDotClocksReply 32 - -typedef struct _XF86VidModeSetClientVersion -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD16 major B16; - CARD16 minor B16; -} xXF86VidModeSetClientVersionReq; -#define sz_xXF86VidModeSetClientVersionReq 8 - -typedef struct _XF86VidModeGetGamma -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; - CARD32 pad6 B32; -} xXF86VidModeGetGammaReq; -#define sz_xXF86VidModeGetGammaReq 32 - -typedef struct -{ - BYTE type; - BOOL pad; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD32 red B32; - CARD32 green B32; - CARD32 blue B32; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; -} xXF86VidModeGetGammaReply; -#define sz_xXF86VidModeGetGammaReply 32 - -typedef struct _XF86VidModeSetGamma -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; - CARD32 red B32; - CARD32 green B32; - CARD32 blue B32; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; -} xXF86VidModeSetGammaReq; -#define sz_xXF86VidModeSetGammaReq 32 - - -typedef struct _XF86VidModeSetGammaRamp -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD16 screen B16; - CARD16 size B16; -} xXF86VidModeSetGammaRampReq; -#define sz_xXF86VidModeSetGammaRampReq 8 - -typedef struct _XF86VidModeGetGammaRamp -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD16 screen B16; - CARD16 size B16; -} xXF86VidModeGetGammaRampReq; -#define sz_xXF86VidModeGetGammaRampReq 8 - -typedef struct -{ - BYTE type; - BOOL pad; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 size B16; - CARD16 pad0 B16; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXF86VidModeGetGammaRampReply; -#define sz_xXF86VidModeGetGammaRampReply 32 - -typedef struct _XF86VidModeGetGammaRampSize -{ - CARD8 reqType; /* always XF86VidModeReqCode */ - CARD8 xf86vidmodeReqType; - CARD16 length B16; - CARD16 screen B16; - CARD16 pad B16; -} xXF86VidModeGetGammaRampSizeReq; -#define sz_xXF86VidModeGetGammaRampSizeReq 8 - -typedef struct -{ - BYTE type; - BOOL pad; - CARD16 sequenceNumber B16; - CARD32 length B32; - CARD16 size B16; - CARD16 pad0 B16; - CARD32 pad1 B32; - CARD32 pad2 B32; - CARD32 pad3 B32; - CARD32 pad4 B32; - CARD32 pad5 B32; -} xXF86VidModeGetGammaRampSizeReply; -#define sz_xXF86VidModeGetGammaRampSizeReply 32 - - -#endif /* _XF86VIDMODESTR_H_ */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c index 5dd71941d..0de7bf115 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.c @@ -1277,6 +1277,7 @@ static SDL_mutex * BufferedEventsMutex = NULL; #if SDL_VERSION_ATLEAST(1,3,0) #define SDL_SendKeyboardKey(state, keysym) SDL_SendKeyboardKey(state, (keysym)->sym) +extern SDL_Window * ANDROID_CurrentWindow; #else @@ -1308,13 +1309,13 @@ extern void SDL_ANDROID_PumpEvents() switch( ev.type ) { case SDL_MOUSEMOTION: - SDL_SendMouseMotion(NULL, 0, ev.motion.x, ev.motion.y); + SDL_SendMouseMotion(ANDROID_CurrentWindow, 0, ev.motion.x, ev.motion.y); break; case SDL_MOUSEBUTTONDOWN: if( ((oldMouseButtons & SDL_BUTTON(ev.button.button)) != 0) != ev.button.state ) { oldMouseButtons = (oldMouseButtons & ~SDL_BUTTON(ev.button.button)) | (ev.button.state ? SDL_BUTTON(ev.button.button) : 0); - SDL_SendMouseButton( NULL, ev.button.state, ev.button.button ); + SDL_SendMouseButton( ANDROID_CurrentWindow, ev.button.state, ev.button.button ); } break; case SDL_KEYDOWN: diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h index 9bfe60677..4ac477d49 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidinput.h @@ -36,6 +36,7 @@ #include "../../events/SDL_events_c.h" #include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_mouse_c.h" +#include "SDL_keycode.h" #include "SDL_scancode.h" #include "SDL_compat.h" #else diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo-1.3.c b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo-1.3.c index 698d4c9a8..a6808bf8b 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo-1.3.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo-1.3.c @@ -29,6 +29,7 @@ #include #include #include // for memset() +#include #include "SDL_config.h" @@ -43,9 +44,10 @@ #include "../../events/SDL_touch_c.h" #include "SDL_androidvideo.h" +#include "SDL_screenkeyboard.h" +#include "../../render/SDL_sysrender.h" -/* Initialization/Query functions */ static int ANDROID_VideoInit(_THIS); static int ANDROID_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); static void ANDROID_GetDisplayModes(_THIS, SDL_VideoDisplay * display); @@ -57,10 +59,21 @@ static void ANDROID_GL_SwapBuffers(_THIS, SDL_Window * window); static SDL_GLContext ANDROID_GL_CreateContext(_THIS, SDL_Window * window); static int ANDROID_GL_MakeCurrent (_THIS, SDL_Window * window, SDL_GLContext context); static void ANDROID_GL_DeleteContext (_THIS, SDL_GLContext context); +static void* ANDROID_GL_GetProcAddress(_THIS, const char *proc); +static int Android_GL_LoadLibrary(_THIS, const char *path); +static void Android_GL_UnloadLibrary(_THIS); static void ANDROID_PumpEvents(_THIS); static int ANDROID_CreateWindow(_THIS, SDL_Window * window); static void ANDROID_DestroyWindow(_THIS, SDL_Window * window); + +static void ANDROID_StartTextInput(_THIS); +static void ANDROID_StopTextInput(_THIS); +static void ANDROID_SetTextInputRect(_THIS, SDL_Rect *rect); + +void * glLibraryHandle = NULL; +void * gl2LibraryHandle = NULL; + static Uint32 SDL_VideoThreadID = 0; int SDL_ANDROID_InsideVideoThread() { @@ -98,15 +111,30 @@ static SDL_VideoDevice *ANDROID_CreateDevice(int devindex) device->SetDisplayMode = ANDROID_SetDisplayMode; device->PumpEvents = ANDROID_PumpEvents; device->VideoQuit = ANDROID_VideoQuit; - device->free = ANDROID_DeleteDevice; device->GL_SwapWindow = ANDROID_GL_SwapBuffers; device->GL_CreateContext = ANDROID_GL_CreateContext; device->GL_MakeCurrent = ANDROID_GL_MakeCurrent; device->GL_DeleteContext = ANDROID_GL_DeleteContext; + device->GL_LoadLibrary = Android_GL_LoadLibrary; + device->GL_GetProcAddress = ANDROID_GL_GetProcAddress; + device->GL_UnloadLibrary = Android_GL_UnloadLibrary; device->CreateWindow = ANDROID_CreateWindow; device->DestroyWindow = ANDROID_DestroyWindow; + + device->StartTextInput = ANDROID_StartTextInput; + device->StopTextInput = ANDROID_StopTextInput; + device->SetTextInputRect = ANDROID_SetTextInputRect; + + device->free = ANDROID_DeleteDevice; + + glLibraryHandle = dlopen("libGLESv1_CM.so", RTLD_NOW | RTLD_GLOBAL); + if(SDL_ANDROID_UseGles2) + { + gl2LibraryHandle = dlopen("libGLESv2.so", RTLD_NOW | RTLD_GLOBAL); + __android_log_print(ANDROID_LOG_INFO, "libSDL", "Loading libGLESv2.so: %p", gl2LibraryHandle); + } return device; } @@ -117,7 +145,7 @@ ANDROID_Available(void) return 1; } -VideoBootStrap ANDROID_bootstrap = { +VideoBootStrap Android_bootstrap = { "android", "SDL Android video driver", ANDROID_Available, ANDROID_CreateDevice }; @@ -127,18 +155,18 @@ int ANDROID_VideoInit(_THIS) { SDL_VideoDisplay display; SDL_DisplayMode mode; - mode.w = SDL_ANDROID_sWindowWidth; mode.h = SDL_ANDROID_sWindowHeight; mode.refresh_rate = 0; - mode.format = SDL_PIXELFORMAT_RGB565; + mode.format = SDL_ANDROID_BITSPERPIXEL == 16 ? SDL_PIXELFORMAT_RGB565 : SDL_ANDROID_BITSPERPIXEL == 32 ? SDL_PIXELFORMAT_ABGR8888 : SDL_PIXELFORMAT_RGB24; mode.driverdata = NULL; - SDL_zero(display); - display.desktop_mode = mode; - display.current_mode = mode; - display.driverdata = NULL; - SDL_AddVideoDisplay(&display); + if (SDL_AddBasicVideoDisplay(&mode) < 0) { + return -1; + } + + SDL_zero(mode); + SDL_AddDisplayMode(&_this->displays[0], &mode); SDL_VideoThreadID = SDL_ThreadID(); @@ -152,9 +180,12 @@ void ANDROID_GetDisplayModes(_THIS, SDL_VideoDisplay * display) mode.w = SDL_ANDROID_sWindowWidth; mode.h = SDL_ANDROID_sWindowHeight; mode.refresh_rate = 0; - mode.format = SDL_PIXELFORMAT_RGB565; + mode.format = SDL_ANDROID_BITSPERPIXEL == 16 ? SDL_PIXELFORMAT_RGB565 : SDL_ANDROID_BITSPERPIXEL == 32 ? SDL_PIXELFORMAT_ABGR8888 : SDL_PIXELFORMAT_RGB24; mode.driverdata = NULL; SDL_AddDisplayMode(display, &mode); + mode.w = 640; + mode.h = 480; + SDL_AddDisplayMode(display, &mode); } int ANDROID_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) @@ -186,6 +217,7 @@ void ANDROID_GL_SwapBuffers(_THIS, SDL_Window * window) { if( SDL_ANDROID_InsideVideoThread() ) SDL_ANDROID_CallJavaSwapBuffers(); + // SDL: 1.3 does not clear framebuffer before drawing }; SDL_GLContext ANDROID_GL_CreateContext(_THIS, SDL_Window * window) @@ -200,13 +232,109 @@ void ANDROID_GL_DeleteContext (_THIS, SDL_GLContext context) { }; +extern SDL_Window * ANDROID_CurrentWindow; SDL_Window * ANDROID_CurrentWindow = NULL; int ANDROID_CreateWindow(_THIS, SDL_Window * window) { ANDROID_CurrentWindow = window; - SDL_SetTouchFocus(0, window); + + window->x = 0; + window->y = 0; + window->w = SDL_ANDROID_sWindowWidth; + window->h = SDL_ANDROID_sWindowHeight; + + window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */ + window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */ + window->flags |= SDL_WINDOW_SHOWN; /* only one window on Android */ + window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ + + __android_log_print(ANDROID_LOG_INFO, "libSDL", "ANDROID_CreateWindow(): ANDROID_CurrentWindow %p", ANDROID_CurrentWindow); + + //SDL_SetTouchFocus(0, window); }; void ANDROID_DestroyWindow(_THIS, SDL_Window * window) { ANDROID_CurrentWindow = NULL; }; + +static void ANDROID_StartTextInput(_THIS) +{ + SDL_ANDROID_ToggleScreenKeyboardTextInput(NULL); +}; +static void ANDROID_StopTextInput(_THIS) +{ +}; +static void ANDROID_SetTextInputRect(_THIS, SDL_Rect *rect) +{ +}; + +static void* ANDROID_GL_GetProcAddress(_THIS, const char *proc) +{ + void * func = dlsym(glLibraryHandle, proc); + if(!func && gl2LibraryHandle) + func = dlsym(gl2LibraryHandle, proc); + __android_log_print(ANDROID_LOG_INFO, "libSDL", "ANDROID_GL_GetProcAddress(\"%s\"): %p", proc, func); + return func; +}; +int Android_GL_LoadLibrary(_THIS, const char *path) +{ + return 0; +} +void Android_GL_UnloadLibrary(_THIS) +{ +} + +// TODO: fix that +void SDL_ANDROID_VideoContextLost() +{ + SDL_Renderer * renderer = NULL; + if(ANDROID_CurrentWindow) + renderer = SDL_GetRenderer(ANDROID_CurrentWindow); + + if( ! renderer || ! renderer->textures || SDL_GetWindowFlags(ANDROID_CurrentWindow) & SDL_WINDOW_OPENGL ) + return; + + __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_VideoContextLost()"); + /* + SDL_Texture * tex = renderer->textures; + while( tex ) + { + renderer->DestroyTexture( renderer, tex ); + tex = tex->next; + } + */ +} + +extern void GLES_ResetState(SDL_Renderer *renderer); +extern int GLES_ReinitTextureAndroid(SDL_Renderer * renderer, SDL_Texture * texture, void * data); + +void SDL_ANDROID_VideoContextRecreated() +{ + int numTextures = 0; + SDL_Texture * tex; + __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_VideoContextRecreated(): enter, ANDROID_CurrentWindow %p", ANDROID_CurrentWindow); + SDL_Renderer * renderer = NULL; + if(ANDROID_CurrentWindow) + renderer = SDL_GetRenderer(ANDROID_CurrentWindow); + + if( ! renderer ) + return; + + //if( renderer->UpdateViewport ) // Re-apply glOrtho() and blend modes + // renderer->UpdateViewport(renderer); + SDL_RendererInfo info; + SDL_GetRendererInfo(renderer, &info); + if(strcmp(info.name, "opengles") == 0) { + GLES_ResetState(renderer); + tex = renderer->textures; + while( tex ) + { + GLES_ReinitTextureAndroid( renderer, tex, tex->driverdata ); + tex = tex->next; + numTextures++; + } + } + + //SDL_GetWindowSurface(ANDROID_CurrentWindow); + __android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_ANDROID_VideoContextRecreated(): re-created %d textures", numTextures); +} diff --git a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.c b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.c index ed6cbdb83..dab1d8175 100644 --- a/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.c +++ b/project/jni/sdl-1.3/src/video/android/SDL_androidvideo.c @@ -196,8 +196,8 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextLost) ( JNIEnv* env, jobject thiz glContextLost = 1; appPutToBackgroundCallback(); #if SDL_VERSION_ATLEAST(1,3,0) - if( ANDROID_CurrentWindow ) - SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); + //if( ANDROID_CurrentWindow ) + // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_MINIMIZED, 0, 0); #else SDL_PrivateAppActive(0, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); #endif @@ -210,8 +210,8 @@ JAVA_EXPORT_NAME(DemoRenderer_nativeGlContextRecreated) ( JNIEnv* env, jobject { __android_log_print(ANDROID_LOG_INFO, "libSDL", "OpenGL context recreated, sending SDL_ACTIVEEVENT"); #if SDL_VERSION_ATLEAST(1,3,0) - if( ANDROID_CurrentWindow ) - SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); + //if( ANDROID_CurrentWindow ) + // SDL_SendWindowEvent(ANDROID_CurrentWindow, SDL_WINDOWEVENT_RESTORED, 0, 0); #else SDL_PrivateAppActive(1, SDL_APPACTIVE|SDL_APPINPUTFOCUS|SDL_APPMOUSEFOCUS); #endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_BView.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_BView.h deleted file mode 100644 index 72c101fc8..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_BView.h +++ /dev/null @@ -1,121 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_BView_h -#define _SDL_BView_h - -/* This is the event handling and graphics update portion of SDL_BWin */ - -extern "C" -{ -#include "../../events/SDL_events_c.h" -}; - -class SDL_BView:public BView -{ - public: - SDL_BView(BRect frame):BView(frame, "SDL View", B_FOLLOW_ALL_SIDES, - (B_WILL_DRAW | B_FRAME_EVENTS)) - { - image = NULL; - xoff = yoff = 0; - SetViewColor(0, 0, 0, 0); - SetHighColor(0, 0, 0, 0); - } - virtual ~ SDL_BView() - { - SetBitmap(NULL); - } - /* Set drawing offsets for fullscreen mode */ - virtual void SetXYOffset(int x, int y) - { - xoff = x; - yoff = y; - } - virtual void GetXYOffset(int &x, int &y) - { - x = xoff; - y = yoff; - } - /* The view changed size. If it means we're in fullscreen, we - * draw a nice black box in the entire view to get black borders. - */ - virtual void FrameResized(float width, float height) - { - BRect bounds; - bounds.top = bounds.left = 0; - bounds.right = width; - bounds.bottom = height; - /* Fill the entire view with black */ - FillRect(bounds, B_SOLID_HIGH); - /* And if there's an image, redraw it. */ - if (image) { - bounds = image->Bounds(); - Draw(bounds); - } - } - - /* Drawing portion of this complete breakfast. :) */ - virtual void SetBitmap(BBitmap * bitmap) - { - if (image) { - delete image; - } - image = bitmap; - } - virtual void Draw(BRect updateRect) - { - if (image) { - if (xoff || yoff) { - BRect dest; - dest.top = updateRect.top + yoff; - dest.left = updateRect.left + xoff; - dest.bottom = updateRect.bottom + yoff; - dest.right = updateRect.right + xoff; - DrawBitmap(image, updateRect, dest); - } else { - DrawBitmap(image, updateRect, updateRect); - } - } - } - virtual void DrawAsync(BRect updateRect) - { - if (xoff || yoff) { - BRect dest; - dest.top = updateRect.top + yoff; - dest.left = updateRect.left + xoff; - dest.bottom = updateRect.bottom + yoff; - dest.right = updateRect.right + xoff;; - DrawBitmapAsync(image, updateRect, dest); - } else { - DrawBitmapAsync(image, updateRect, updateRect); - } - } - - private: - BBitmap * image; - int xoff, yoff; -}; - -#endif /* _SDL_BView_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_BWin.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_BWin.h index d0bf1b4ba..9967decd9 100644 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_BWin.h +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_BWin.h @@ -1,29 +1,39 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_BWin_h #define _SDL_BWin_h +#ifdef __cplusplus +extern "C" { +#endif + #include "SDL_config.h" +#include "SDL.h" +#include "SDL_syswm.h" +#include "SDL_bframebuffer.h" + +#ifdef __cplusplus +} +#endif #include #include @@ -32,537 +42,310 @@ #if SDL_VIDEO_OPENGL #include #endif -#include - -#include "../../main/beos/SDL_BeApp.h" #include "SDL_events.h" -#include "SDL_BView.h" +#include "../../main/beos/SDL_BApp.h" -extern "C" -{ -#include "../../events/SDL_events_c.h" + +enum WinCommands { + BWIN_MOVE_WINDOW, + BWIN_RESIZE_WINDOW, + BWIN_SHOW_WINDOW, + BWIN_HIDE_WINDOW, + BWIN_MAXIMIZE_WINDOW, + BWIN_MINIMIZE_WINDOW, + BWIN_RESTORE_WINDOW, + BWIN_SET_TITLE, + BWIN_FULLSCREEN }; + class SDL_BWin:public BDirectWindow { public: - SDL_BWin(BRect bounds):BDirectWindow(bounds, "Untitled", - B_TITLED_WINDOW, 0) + /* Constructor/Destructor */ + SDL_BWin(BRect bounds, uint32 flags):BDirectWindow(bounds, "Untitled", + B_TITLED_WINDOW, flags) { - InitKeyboard(); - last_buttons = 0; + _last_buttons = 0; - the_view = NULL; #if SDL_VIDEO_OPENGL - SDL_GLView = NULL; + _SDL_GLView = NULL; +#endif + _shown = false; + _inhibit_resize = false; + _mouse_focused = false; + _prev_frame = NULL; + + /* Handle framebuffer stuff */ + _connected = _connection_disabled = false; + _buffer_created = _buffer_dirty = false; + _trash_window_buffer = false; + _buffer_locker = new BLocker(); + _bitmap = NULL; +#ifdef DRAWTHREAD + _draw_thread_id = spawn_thread(BE_DrawThread, "drawing_thread", + B_NORMAL_PRIORITY, (void*) this); + resume_thread(_draw_thread_id); #endif - SDL_View = NULL; - Unlock(); - shown = false; - inhibit_resize = false; } virtual ~ SDL_BWin() { Lock(); - if (the_view) { + _connection_disabled = true; + int32 result; + #if SDL_VIDEO_OPENGL - if (the_view == SDL_GLView) { - SDL_GLView->UnlockGL(); - } -#endif - RemoveChild(the_view); - the_view = NULL; + if (_SDL_GLView) { + _SDL_GLView->UnlockGL(); + RemoveChild(_SDL_GLView); /* Why was this outside the if + statement before? */ } + +#endif Unlock(); #if SDL_VIDEO_OPENGL - if (SDL_GLView) { - delete SDL_GLView; + if (_SDL_GLView) { + delete _SDL_GLView; } #endif - if (SDL_View) { - delete SDL_View; - } + + /* Clean up framebuffer stuff */ + _buffer_locker->Lock(); +#ifdef DRAWTHREAD + wait_for_thread(_draw_thread_id, &result); +#endif + free(_clips); + delete _buffer_locker; } + - virtual void InitKeyboard(void) - { - for (uint i = 0; i < SDL_TABLESIZE(keymap); ++i) - keymap[i] = SDLK_UNKNOWN; - - keymap[0x01] = SDLK_ESCAPE; - keymap[B_F1_KEY] = SDLK_F1; - keymap[B_F2_KEY] = SDLK_F2; - keymap[B_F3_KEY] = SDLK_F3; - keymap[B_F4_KEY] = SDLK_F4; - keymap[B_F5_KEY] = SDLK_F5; - keymap[B_F6_KEY] = SDLK_F6; - keymap[B_F7_KEY] = SDLK_F7; - keymap[B_F8_KEY] = SDLK_F8; - keymap[B_F9_KEY] = SDLK_F9; - keymap[B_F10_KEY] = SDLK_F10; - keymap[B_F11_KEY] = SDLK_F11; - keymap[B_F12_KEY] = SDLK_F12; - keymap[B_PRINT_KEY] = SDLK_PRINTSCREEN; - keymap[B_SCROLL_KEY] = SDLK_SCROLLLOCK; - keymap[B_PAUSE_KEY] = SDLK_PAUSE; - keymap[0x11] = SDLK_BACKQUOTE; - keymap[0x12] = SDLK_1; - keymap[0x13] = SDLK_2; - keymap[0x14] = SDLK_3; - keymap[0x15] = SDLK_4; - keymap[0x16] = SDLK_5; - keymap[0x17] = SDLK_6; - keymap[0x18] = SDLK_7; - keymap[0x19] = SDLK_8; - keymap[0x1a] = SDLK_9; - keymap[0x1b] = SDLK_0; - keymap[0x1c] = SDLK_MINUS; - keymap[0x1d] = SDLK_EQUALS; - keymap[0x1e] = SDLK_BACKSPACE; - keymap[0x1f] = SDLK_INSERT; - keymap[0x20] = SDLK_HOME; - keymap[0x21] = SDLK_PAGEUP; - keymap[0x22] = SDLK_NUMLOCKCLEAR; - keymap[0x23] = SDLK_KP_DIVIDE; - keymap[0x24] = SDLK_KP_MULTIPLY; - keymap[0x25] = SDLK_KP_MINUS; - keymap[0x26] = SDLK_TAB; - keymap[0x27] = SDLK_q; - keymap[0x28] = SDLK_w; - keymap[0x29] = SDLK_e; - keymap[0x2a] = SDLK_r; - keymap[0x2b] = SDLK_t; - keymap[0x2c] = SDLK_y; - keymap[0x2d] = SDLK_u; - keymap[0x2e] = SDLK_i; - keymap[0x2f] = SDLK_o; - keymap[0x30] = SDLK_p; - keymap[0x31] = SDLK_LEFTBRACKET; - keymap[0x32] = SDLK_RIGHTBRACKET; - keymap[0x33] = SDLK_BACKSLASH; - keymap[0x34] = SDLK_DELETE; - keymap[0x35] = SDLK_END; - keymap[0x36] = SDLK_PAGEDOWN; - keymap[0x37] = SDLK_KP_7; - keymap[0x38] = SDLK_KP_8; - keymap[0x39] = SDLK_KP_9; - keymap[0x3a] = SDLK_KP_PLUS; - keymap[0x3b] = SDLK_CAPSLOCK; - keymap[0x3c] = SDLK_a; - keymap[0x3d] = SDLK_s; - keymap[0x3e] = SDLK_d; - keymap[0x3f] = SDLK_f; - keymap[0x40] = SDLK_g; - keymap[0x41] = SDLK_h; - keymap[0x42] = SDLK_j; - keymap[0x43] = SDLK_k; - keymap[0x44] = SDLK_l; - keymap[0x45] = SDLK_SEMICOLON; - keymap[0x46] = SDLK_QUOTE; - keymap[0x47] = SDLK_RETURN; - keymap[0x48] = SDLK_KP_4; - keymap[0x49] = SDLK_KP_5; - keymap[0x4a] = SDLK_KP_6; - keymap[0x4b] = SDLK_LSHIFT; - keymap[0x4c] = SDLK_z; - keymap[0x4d] = SDLK_x; - keymap[0x4e] = SDLK_c; - keymap[0x4f] = SDLK_v; - keymap[0x50] = SDLK_b; - keymap[0x51] = SDLK_n; - keymap[0x52] = SDLK_m; - keymap[0x53] = SDLK_COMMA; - keymap[0x54] = SDLK_PERIOD; - keymap[0x55] = SDLK_SLASH; - keymap[0x56] = SDLK_RSHIFT; - keymap[0x57] = SDLK_UP; - keymap[0x58] = SDLK_KP_1; - keymap[0x59] = SDLK_KP_2; - keymap[0x5a] = SDLK_KP_3; - keymap[0x5b] = SDLK_KP_ENTER; - keymap[0x5c] = SDLK_LCTRL; - keymap[0x5d] = SDLK_LALT; - keymap[0x5e] = SDLK_SPACE; - keymap[0x5f] = SDLK_RALT; - keymap[0x60] = SDLK_RCTRL; - keymap[0x61] = SDLK_LEFT; - keymap[0x62] = SDLK_DOWN; - keymap[0x63] = SDLK_RIGHT; - keymap[0x64] = SDLK_KP_0; - keymap[0x65] = SDLK_KP_PERIOD; - keymap[0x66] = SDLK_LGUI; - keymap[0x67] = SDLK_RGUI; - keymap[0x68] = SDLK_MENU; - keymap[0x69] = SDLK_2; //SDLK_EURO; - keymap[0x6a] = SDLK_KP_EQUALS; - keymap[0x6b] = SDLK_POWER; - } - - /* Override the Show() method so we can tell when we've been shown */ - virtual void Show(void) - { - BWindow::Show(); - shown = true; - } - virtual bool Shown(void) - { - return (shown); - } - /* If called, the next resize event will not be forwarded to SDL. */ - virtual void InhibitResize(void) - { - inhibit_resize = true; - } - /* Handle resizing of the window */ - virtual void FrameResized(float width, float height) - { - if (inhibit_resize) - inhibit_resize = false; - else - SDL_PrivateResize((int) width, (int) height); - } - virtual int CreateView(Uint32 flags, Uint32 gl_flags) - { - int retval; - - retval = 0; + /* * * * * OpenGL functionality * * * * */ +#if SDL_VIDEO_OPENGL + virtual BGLView *CreateGLView(Uint32 gl_flags) { Lock(); - if (flags & SDL_INTERNALOPENGL) { -#if SDL_VIDEO_OPENGL - if (SDL_GLView == NULL) { - SDL_GLView = new BGLView(Bounds(), "SDL GLView", - B_FOLLOW_ALL_SIDES, - (B_WILL_DRAW | B_FRAME_EVENTS), - gl_flags); - } - if (the_view != SDL_GLView) { - if (the_view) { - RemoveChild(the_view); - } - AddChild(SDL_GLView); - SDL_GLView->LockGL(); - the_view = SDL_GLView; - } -#else - SDL_SetError("OpenGL support not enabled"); - retval = -1; -#endif - } else { - if (SDL_View == NULL) { - SDL_View = new SDL_BView(Bounds()); - } - if (the_view != SDL_View) { - if (the_view) { -#if SDL_VIDEO_OPENGL - if (the_view == SDL_GLView) { - SDL_GLView->UnlockGL(); - } -#endif - RemoveChild(the_view); - } - AddChild(SDL_View); - the_view = SDL_View; - } + if (_SDL_GLView == NULL) { + _SDL_GLView = new BGLView(Bounds(), "SDL GLView", + B_FOLLOW_ALL_SIDES, + (B_WILL_DRAW | B_FRAME_EVENTS), + gl_flags); } + AddChild(_SDL_GLView); + _SDL_GLView->EnableDirectMode(true); + _SDL_GLView->LockGL(); /* "New" GLViews are created */ Unlock(); - return (retval); + return (_SDL_GLView); } - virtual void SetBitmap(BBitmap * bitmap) - { - SDL_View->SetBitmap(bitmap); + + virtual void RemoveGLView() { + Lock(); + if(_SDL_GLView) { + _SDL_GLView->UnlockGL(); + RemoveChild(_SDL_GLView); + } + Unlock(); } - virtual void SetXYOffset(int x, int y) - { -#if SDL_VIDEO_OPENGL - if (the_view == SDL_GLView) { - return; - } + + virtual void SwapBuffers(void) { + _SDL_GLView->UnlockGL(); + _SDL_GLView->LockGL(); + _SDL_GLView->SwapBuffers(); + } #endif - SDL_View->SetXYOffset(x, y); - } - virtual void GetXYOffset(int &x, int &y) - { + + /* * * * * Framebuffering* * * * */ + virtual void DirectConnected(direct_buffer_info *info) { + if(!_connected && _connection_disabled) { + return; + } + + /* Determine if the pixel buffer is usable after this update */ + _trash_window_buffer = _trash_window_buffer + || ((info->buffer_state & B_BUFFER_RESIZED) + || (info->buffer_state & B_BUFFER_RESET) + || (info->driver_state == B_MODE_CHANGED)); + LockBuffer(); + + switch(info->buffer_state & B_DIRECT_MODE_MASK) { + case B_DIRECT_START: + _connected = true; + + case B_DIRECT_MODIFY: + if(_clips) { + free(_clips); + _clips = NULL; + } + + _num_clips = info->clip_list_count; + _clips = (clipping_rect *)malloc(_num_clips*sizeof(clipping_rect)); + if(_clips) { + memcpy(_clips, info->clip_list, + _num_clips*sizeof(clipping_rect)); + + _bits = (uint8*) info->bits; + _row_bytes = info->bytes_per_row; + _bounds = info->window_bounds; + _bytes_per_px = info->bits_per_pixel / 8; + _buffer_dirty = true; + } + break; + + case B_DIRECT_STOP: + _connected = false; + break; + } #if SDL_VIDEO_OPENGL - if (the_view == SDL_GLView) { - x = 0; - y = 0; - return; - } + if(_SDL_GLView) { + _SDL_GLView->DirectConnected(info); + } #endif - SDL_View->GetXYOffset(x, y); + + + /* Call the base object directconnected */ + BDirectWindow::DirectConnected(info); + + UnlockBuffer(); + } - virtual bool BeginDraw(void) - { - return (Lock()); + + + + + /* * * * * Event sending * * * * */ + /* Hook functions */ + virtual void FrameMoved(BPoint origin) { + /* Post a message to the BApp so that it can handle the window event */ + BMessage msg(BAPP_WINDOW_MOVED); + msg.AddInt32("window-x", (int)origin.x); + msg.AddInt32("window-y", (int)origin.y); + _PostWindowEvent(msg); + + /* Perform normal hook operations */ + BDirectWindow::FrameMoved(origin); } - virtual void DrawAsync(BRect updateRect) - { - SDL_View->DrawAsync(updateRect); - } - virtual void EndDraw(void) - { - SDL_View->Sync(); - Unlock(); - } -#if SDL_VIDEO_OPENGL - virtual void SwapBuffers(void) - { - SDL_GLView->UnlockGL(); - SDL_GLView->LockGL(); - SDL_GLView->SwapBuffers(); - } -#endif - virtual BView *View(void) - { - return (the_view); + + virtual void FrameResized(float width, float height) { + /* Post a message to the BApp so that it can handle the window event */ + BMessage msg(BAPP_WINDOW_RESIZED); + + msg.AddInt32("window-w", (int)width + 1); + msg.AddInt32("window-h", (int)height + 1); + _PostWindowEvent(msg); + + /* Perform normal hook operations */ + BDirectWindow::FrameResized(width, height); } - /* Hook functions -- overridden */ - virtual void Minimize(bool minimize) - { - /* This is only called when mimimized, not when restored */ - //SDL_PrivateAppActive(minimize, SDL_APPACTIVE); - BWindow::Minimize(minimize); + virtual bool QuitRequested() { + BMessage msg(BAPP_WINDOW_CLOSE_REQUESTED); + _PostWindowEvent(msg); + + /* We won't allow a quit unless asked by DestroyWindow() */ + return false; } - virtual void WindowActivated(bool active) - { - SDL_PrivateAppActive(active, SDL_APPINPUTFOCUS); + + virtual void WindowActivated(bool active) { + BMessage msg(BAPP_KEYBOARD_FOCUS); /* Mouse focus sold separately */ + _PostWindowEvent(msg); } - virtual bool QuitRequested(void) - { - if (SDL_BeAppActive > 0) { - SDL_PrivateQuit(); - /* We don't ever actually close the window here because - the application should respond to the quit request, - or ignore it as desired. - */ - return (false); - } - return (true); /* Close the app window */ + + virtual void Zoom(BPoint origin, + float width, + float height) { + BMessage msg(BAPP_MAXIMIZE); /* Closest thing to maximization Haiku has */ + _PostWindowEvent(msg); + + /* Before the window zooms, record its size */ + if( !_prev_frame ) + _prev_frame = new BRect(Frame()); + + /* Perform normal hook operations */ + BDirectWindow::Zoom(origin, width, height); } - virtual void Quit() - { - if (!IsLocked()) - Lock(); - BDirectWindow::Quit(); + + /* Member functions */ + virtual void Show() { + while(IsHidden()) { + BDirectWindow::Show(); + } + _shown = true; + + BMessage msg(BAPP_SHOW); + _PostWindowEvent(msg); + } + + virtual void Hide() { + BDirectWindow::Hide(); + _shown = false; + + BMessage msg(BAPP_HIDE); + _PostWindowEvent(msg); } - virtual int16 Translate2Unicode(const char *buf) - { - int32 state, srclen, dstlen; - unsigned char destbuf[2]; - Uint16 unicode = 0; - - if ((uchar) buf[0] > 127) { - state = 0; - srclen = SDL_strlen(buf); - dstlen = sizeof(destbuf); - convert_from_utf8(B_UNICODE_CONVERSION, buf, &srclen, - (char *) destbuf, &dstlen, &state); - unicode = destbuf[0]; - unicode <<= 8; - unicode |= destbuf[1]; - } else - unicode = buf[0]; - - /* For some reason function keys map to control characters */ -# define CTRL(X) ((X)-'@') - switch (unicode) { - case CTRL('A'): - case CTRL('B'): - case CTRL('C'): - case CTRL('D'): - case CTRL('E'): - case CTRL('K'): - case CTRL('L'): - case CTRL('P'): - if (!(SDL_GetModState() & KMOD_CTRL)) - unicode = 0; - break; - /* Keyboard input maps newline to carriage return */ - case '\n': - unicode = '\r'; - break; - default: - break; - } - - return unicode; + virtual void Minimize(bool minimize) { + BDirectWindow::Minimize(minimize); + int32 minState = (minimize ? BAPP_MINIMIZE : BAPP_RESTORE); + + BMessage msg(minState); + _PostWindowEvent(msg); } - + + + /* BView message interruption */ virtual void DispatchMessage(BMessage * msg, BHandler * target) { + BPoint where; /* Used by mouse moved */ + int32 buttons; /* Used for mouse button events */ + int32 key; /* Used for key events */ + switch (msg->what) { case B_MOUSE_MOVED: - { - BPoint where; - int32 transit; - if (msg->FindPoint("where", &where) == B_OK - && msg->FindInt32("be:transit", &transit) == B_OK) { - if (transit == B_EXITED_VIEW) { - if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) { - SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); - be_app->SetCursor(B_HAND_CURSOR); - } - } else { - int x, y; - if (!(SDL_GetAppState() & SDL_APPMOUSEFOCUS)) { - SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); - SDL_SetCursor(NULL); - } - GetXYOffset(x, y); - x = (int) where.x - x; - y = (int) where.y - y; - SDL_PrivateMouseMotion(0, 0, x, y); - } - } - break; + int32 transit; + if (msg->FindPoint("where", &where) == B_OK + && msg->FindInt32("be:transit", &transit) == B_OK) { + _MouseMotionEvent(where, transit); } + + /* FIXME: Apparently a button press/release event might be dropped + if made before before a different button is released. Does + B_MOUSE_MOVED have the data needed to check if a mouse button + state has changed? */ + if (msg->FindInt32("buttons", &buttons) == B_OK) { + _MouseButtonEvent(buttons); + } + break; case B_MOUSE_DOWN: - { - /* it looks like mouse down is send only for first clicked - button, each next is not send while last one is holded */ - int32 buttons; - int sdl_buttons = 0; - if (msg->FindInt32("buttons", &buttons) == B_OK) { - /* Add any mouse button events */ - if (buttons & B_PRIMARY_MOUSE_BUTTON) { - sdl_buttons |= SDL_BUTTON_LEFT; - } - if (buttons & B_SECONDARY_MOUSE_BUTTON) { - sdl_buttons |= SDL_BUTTON_RIGHT; - } - if (buttons & B_TERTIARY_MOUSE_BUTTON) { - sdl_buttons |= SDL_BUTTON_MIDDLE; - } - SDL_PrivateMouseButton(SDL_PRESSED, sdl_buttons, 0, 0); - - last_buttons = buttons; - } - break; - } - case B_MOUSE_UP: - { - /* mouse up doesn't give which button was released, - only state of buttons (after release, so it's always = 0), - which is not what we need ;] - So we need to store button in mouse down, and restore - in mouse up :( - mouse up is (similarly to mouse down) send only for - first button down (ie. it's no send if we click another button - without releasing previous one first) - but that's probably - because of how drivers are written?, not BeOS itself. */ - int32 buttons; - int sdl_buttons = 0; - if (msg->FindInt32("buttons", &buttons) == B_OK) { - /* Add any mouse button events */ - if ((buttons ^ B_PRIMARY_MOUSE_BUTTON) & last_buttons) { - sdl_buttons |= SDL_BUTTON_LEFT; - } - if ((buttons ^ B_SECONDARY_MOUSE_BUTTON) & last_buttons) { - sdl_buttons |= SDL_BUTTON_RIGHT; - } - if ((buttons ^ B_TERTIARY_MOUSE_BUTTON) & last_buttons) { - sdl_buttons |= SDL_BUTTON_MIDDLE; - } - SDL_PrivateMouseButton(SDL_RELEASED, sdl_buttons, 0, 0); - - last_buttons = buttons; - } - break; + /* _MouseButtonEvent() detects any and all buttons that may have + changed state, as well as that button's new state */ + if (msg->FindInt32("buttons", &buttons) == B_OK) { + _MouseButtonEvent(buttons); } + break; case B_MOUSE_WHEEL_CHANGED: - { - float x, y; - x = y = 0; - if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK - && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { - if (x < 0 || y < 0) { - SDL_PrivateMouseButton(SDL_PRESSED, - SDL_BUTTON_WHEELDOWN, 0, 0); - SDL_PrivateMouseButton(SDL_RELEASED, - SDL_BUTTON_WHEELDOWN, 0, 0); - } else if (x > 0 || y > 0) { - SDL_PrivateMouseButton(SDL_PRESSED, - SDL_BUTTON_WHEELUP, 0, 0); - SDL_PrivateMouseButton(SDL_RELEASED, - SDL_BUTTON_WHEELUP, 0, 0); - } - } - break; - } + float x, y; + if (msg->FindFloat("be:wheel_delta_x", &x) == B_OK + && msg->FindFloat("be:wheel_delta_y", &y) == B_OK) { + _MouseWheelEvent((int)x, (int)y); + } + break; case B_KEY_DOWN: case B_UNMAPPED_KEY_DOWN: /* modifier keys are unmapped */ - { - int32 key; - int32 modifiers; - int32 key_repeat; - /* Workaround for SDL message queue being filled too fast because of BeOS own key-repeat mechanism */ - if (msg->FindInt32("be:key_repeat", &key_repeat) == B_OK - && key_repeat > 0) - break; - - if (msg->FindInt32("key", &key) == B_OK - && msg->FindInt32("modifiers", &modifiers) == B_OK) { - SDL_keysym keysym; - keysym.scancode = key; - if ((key > 0) && (key < 128)) { - keysym.sym = keymap[key]; - } else { - keysym.sym = SDLK_UNKNOWN; - } - /* FIX THIS? - it seems SDL_PrivateKeyboard() changes mod value - anyway, and doesn't care about what we setup here */ - keysym.mod = KMOD_NONE; - keysym.unicode = 0; - if (SDL_TranslateUNICODE) { - const char *bytes; - if (msg->FindString("bytes", &bytes) == B_OK) { - /* FIX THIS? - this cares only about first "letter", - so if someone maps some key to print - "BeOS rulez!" only "B" will be used. */ - keysym.unicode = Translate2Unicode(bytes); - } - } - SDL_PrivateKeyboard(SDL_PRESSED, &keysym); - } - break; - } + if (msg->FindInt32("key", &key) == B_OK) { + _KeyEvent((SDL_Scancode)key, SDL_PRESSED); + } + break; case B_KEY_UP: case B_UNMAPPED_KEY_UP: /* modifier keys are unmapped */ - { - int32 key; - int32 modifiers; - if (msg->FindInt32("key", &key) == B_OK - && msg->FindInt32("modifiers", &modifiers) == B_OK) { - SDL_keysym keysym; - keysym.scancode = key; - if ((key > 0) && (key < 128)) { - keysym.sym = keymap[key]; - } else { - keysym.sym = SDLK_UNKNOWN; - } - keysym.mod = KMOD_NONE; /* FIX THIS? */ - keysym.unicode = 0; - if (SDL_TranslateUNICODE) { - const char *bytes; - if (msg->FindString("bytes", &bytes) == B_OK) { - keysym.unicode = Translate2Unicode(bytes); - } - } - SDL_PrivateKeyboard(SDL_RELEASED, &keysym); - } - break; + if (msg->FindInt32("key", &key) == B_OK) { + _KeyEvent(key, SDL_RELEASED); } - + break; + default: /* move it after switch{} so it's always handled that way we keep BeOS feautures like: @@ -572,22 +355,270 @@ class SDL_BWin:public BDirectWindow //BDirectWindow::DispatchMessage(msg, target); break; } + BDirectWindow::DispatchMessage(msg, target); } + + /* Handle command messages */ + virtual void MessageReceived(BMessage* message) { + switch (message->what) { + /* Handle commands from SDL */ + case BWIN_SET_TITLE: + _SetTitle(message); + break; + case BWIN_MOVE_WINDOW: + _MoveTo(message); + break; + case BWIN_RESIZE_WINDOW: + _ResizeTo(message); + break; + case BWIN_SHOW_WINDOW: + Show(); + break; + case BWIN_HIDE_WINDOW: + Hide(); + break; + case BWIN_MAXIMIZE_WINDOW: + BWindow::Zoom(); + break; + case BWIN_MINIMIZE_WINDOW: + Minimize(true); + break; + case BWIN_RESTORE_WINDOW: + _Restore(); + break; + case BWIN_FULLSCREEN: + _SetFullScreen(message); + break; + default: + /* Perform normal message handling */ + BDirectWindow::MessageReceived(message); + break; + } - private: + } + + + + /* Accessor methods */ + bool IsShown() { return _shown; } + int32 GetID() { return _id; } + uint32 GetRowBytes() { return _row_bytes; } + int32 GetFbX() { return _bounds.left; } + int32 GetFbY() { return _bounds.top; } + bool ConnectionEnabled() { return !_connection_disabled; } + bool Connected() { return _connected; } + clipping_rect *GetClips() { return _clips; } + int32 GetNumClips() { return _num_clips; } + uint8* GetBufferPx() { return _bits; } + int32 GetBytesPerPx() { return _bytes_per_px; } + bool CanTrashWindowBuffer() { return _trash_window_buffer; } + bool BufferExists() { return _buffer_created; } + bool BufferIsDirty() { return _buffer_dirty; } + BBitmap *GetBitmap() { return _bitmap; } #if SDL_VIDEO_OPENGL - BGLView * SDL_GLView; + BGLView *GetGLView() { return _SDL_GLView; } #endif - SDL_BView *SDL_View; - BView *the_view; + + /* Setter methods */ + void SetID(int32 id) { _id = id; } + void SetBufferExists(bool bufferExists) { _buffer_created = bufferExists; } + void LockBuffer() { _buffer_locker->Lock(); } + void UnlockBuffer() { _buffer_locker->Unlock(); } + void SetBufferDirty(bool bufferDirty) { _buffer_dirty = bufferDirty; } + void SetTrashBuffer(bool trash) { _trash_window_buffer = trash; } + void SetBitmap(BBitmap *bitmap) { _bitmap = bitmap; } + + +private: + /* Event redirection */ + void _MouseMotionEvent(BPoint &where, int32 transit) { + if(transit == B_EXITED_VIEW) { + /* Change mouse focus */ + if(_mouse_focused) { + _MouseFocusEvent(false); + } + } else { + /* Change mouse focus */ + if (!_mouse_focused) { + _MouseFocusEvent(true); + } + BMessage msg(BAPP_MOUSE_MOVED); + msg.AddInt32("x", (int)where.x); + msg.AddInt32("y", (int)where.y); + + _PostWindowEvent(msg); + } + } + + void _MouseFocusEvent(bool focusGained) { + _mouse_focused = focusGained; + BMessage msg(BAPP_MOUSE_FOCUS); + msg.AddBool("focusGained", focusGained); + _PostWindowEvent(msg); + +//FIXME: Why were these here? +// if false: be_app->SetCursor(B_HAND_CURSOR); +// if true: SDL_SetCursor(NULL); + } + + void _MouseButtonEvent(int32 buttons) { + int32 buttonStateChange = buttons ^ _last_buttons; + + /* Make sure at least one button has changed state */ + if( !(buttonStateChange) ) { + return; + } + + /* Add any mouse button events */ + if(buttonStateChange & B_PRIMARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_LEFT, buttons & + B_PRIMARY_MOUSE_BUTTON); + } + if(buttonStateChange & B_SECONDARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_RIGHT, buttons & + B_PRIMARY_MOUSE_BUTTON); + } + if(buttonStateChange & B_TERTIARY_MOUSE_BUTTON) { + _SendMouseButton(SDL_BUTTON_MIDDLE, buttons & + B_PRIMARY_MOUSE_BUTTON); + } + + _last_buttons = buttons; + } + + void _SendMouseButton(int32 button, int32 state) { + BMessage msg(BAPP_MOUSE_BUTTON); + msg.AddInt32("button-id", button); + msg.AddInt32("button-state", state); + _PostWindowEvent(msg); + } + + void _MouseWheelEvent(int32 x, int32 y) { + /* Create a message to pass along to the BeApp thread */ + BMessage msg(BAPP_MOUSE_WHEEL); + msg.AddInt32("xticks", x); + msg.AddInt32("yticks", y); + _PostWindowEvent(msg); + } + + void _KeyEvent(int32 keyCode, int32 keyState) { + /* Create a message to pass along to the BeApp thread */ + BMessage msg(BAPP_KEY); + msg.AddInt32("key-state", keyState); + msg.AddInt32("key-scancode", keyCode); + be_app->PostMessage(&msg); + /* Apparently SDL only uses the scancode */ + } + + void _RepaintEvent() { + /* Force a repaint: Call the SDL exposed event */ + BMessage msg(BAPP_REPAINT); + _PostWindowEvent(msg); + } + void _PostWindowEvent(BMessage &msg) { + msg.AddInt32("window-id", _id); + be_app->PostMessage(&msg); + } + + /* Command methods (functions called upon by SDL) */ + void _SetTitle(BMessage *msg) { + const char *title; + if( + msg->FindString("window-title", &title) != B_OK + ) { + return; + } + SetTitle(title); + } + + void _MoveTo(BMessage *msg) { + int32 x, y; + if( + msg->FindInt32("window-x", &x) != B_OK || + msg->FindInt32("window-y", &y) != B_OK + ) { + return; + } + MoveTo(x, y); + } + + void _ResizeTo(BMessage *msg) { + int32 w, h; + if( + msg->FindInt32("window-w", &w) != B_OK || + msg->FindInt32("window-h", &h) != B_OK + ) { + return; + } + ResizeTo(w, h); + } + + void _Restore() { + if(IsMinimized()) { + Minimize(false); + } else if(IsHidden()) { + Show(); + } else if(_prev_frame != NULL) { /* Zoomed */ + MoveTo(_prev_frame->left, _prev_frame->top); + ResizeTo(_prev_frame->Width(), _prev_frame->Height()); + } + } - bool shown; - bool inhibit_resize; - - int32 last_buttons; - SDLKey keymap[128]; + void _SetFullScreen(BMessage *msg) { + bool fullscreen; + if( + msg->FindBool("fullscreen", &fullscreen) != B_OK + ) { + return; + } + SetFullScreen(fullscreen); + } + + /* Members */ +#if SDL_VIDEO_OPENGL + BGLView * _SDL_GLView; +#endif + + int32 _last_buttons; + int32 _id; /* Window id used by SDL_BApp */ + bool _mouse_focused; /* Does this window have mouse focus? */ + bool _shown; + bool _inhibit_resize; + + BRect *_prev_frame; /* Previous position and size of the window */ + + /* Framebuffer members */ + bool _connected, + _connection_disabled, + _buffer_created, + _buffer_dirty, + _trash_window_buffer; + uint8 *_bits; + uint32 _row_bytes; + clipping_rect _bounds; + BLocker *_buffer_locker; + clipping_rect *_clips; + int32 _num_clips; + int32 _bytes_per_px; + thread_id _draw_thread_id; + + BBitmap *_bitmap; }; -#endif /* _SDL_BWin_h */ -/* vi: set ts=4 sw=4 expandtab: */ + +/* FIXME: + * An explanation of framebuffer flags. + * + * _connected - Original variable used to let the drawing thread know + * when changes are being made to the other framebuffer + * members. + * _connection_disabled - Used to signal to the drawing thread that the window + * is closing, and the thread should exit. + * _buffer_created - True if the current buffer is valid + * _buffer_dirty - True if the window should be redrawn. + * _trash_window_buffer - True if the window buffer needs to be trashed partway + * through a draw cycle. Occurs when the previous + * buffer provided by DirectConnected() is invalidated. + */ +#endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bclipboard.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_bclipboard.cc new file mode 100644 index 000000000..41ebfb453 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bclipboard.cc @@ -0,0 +1,95 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW + +/* BWindow based framebuffer implementation */ + +#include +#include + +#include "SDL_BWin.h" +#include "SDL_timer.h" +#include "../SDL_sysvideo.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int BE_SetClipboardText(_THIS, const char *text) { + BMessage *clip = NULL; + if(be_clipboard->Lock()) { + be_clipboard->Clear(); + if((clip = be_clipboard->Data())) { + /* Presumably the string of characters is ascii-format */ + ssize_t asciiLength = 0; + for(; text[asciiLength] != 0; ++asciiLength) {} + clip->AddData("text/plain", B_MIME_TYPE, &text, asciiLength); + be_clipboard->Commit(); + } + be_clipboard->Unlock(); + } + return 0; +} + +char *BE_GetClipboardText(_THIS) { + BMessage *clip = NULL; + const char *text = NULL; + ssize_t length; + char *result; + if(be_clipboard->Lock()) { + if((clip = be_clipboard->Data())) { + /* Presumably the string of characters is ascii-format */ + clip->FindData("text/plain", B_MIME_TYPE, (const void**)&text, + &length); + } else { + be_clipboard->Unlock(); + } + be_clipboard->Unlock(); + } + + if (!text) { + result = SDL_strdup(""); + } else { + /* Copy the data and pass on to SDL */ + result = (char*)SDL_calloc(1, sizeof(char*)*length); + SDL_strlcpy(result, text, length); + } + + return result; +} + +SDL_bool BE_HasClipboardText(_THIS) { + SDL_bool result = SDL_FALSE; + char *text = BE_GetClipboardText(_this); + if (text) { + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); + } + return result; +} + +#ifdef __cplusplus +} /* Extern C */ +#endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bclipboard.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_bclipboard.h new file mode 100644 index 000000000..bfb806cd0 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bclipboard.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#ifndef SDL_BCLIPBOARD_H +#define SDL_BCLIPBOARD_H + +extern int BE_SetClipboardText(_THIS, const char *text); +extern char *BE_GetClipboardText(_THIS); +extern SDL_bool BE_HasClipboardText(_THIS); + +#endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bevents.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_bevents.cc new file mode 100644 index 000000000..bc5c6eb67 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bevents.cc @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW + +#include "SDL_bevents.h" + +#ifdef __cplusplus +extern "C" { +#endif + +void BE_PumpEvents(_THIS) { + /* Since the event thread is its own thread, this isn't really necessary */ +} + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bevents.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_bevents.h new file mode 100644 index 000000000..a930324c8 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bevents.h @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BEVENTS_H +#define SDL_BEVENTS_H + +#include "../SDL_sysvideo.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern void BE_PumpEvents(_THIS); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bframebuffer.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_bframebuffer.cc new file mode 100644 index 000000000..f24a136d4 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bframebuffer.cc @@ -0,0 +1,255 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW + +#include "SDL_bframebuffer.h" + +#include +#include +#include "SDL_bmodes.h" +#include "SDL_BWin.h" + +#include "../../main/beos/SDL_BApp.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int32 BE_UpdateOnce(SDL_Window *window); + +static inline SDL_BWin *_ToBeWin(SDL_Window *window) { + return ((SDL_BWin*)(window->driverdata)); +} + +static inline SDL_BApp *_GetBeApp() { + return ((SDL_BApp*)be_app); +} + +int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window, + Uint32 * format, + void ** pixels, int *pitch) { + SDL_BWin *bwin = _ToBeWin(window); + BScreen bscreen; + if(!bscreen.IsValid()) { + return -1; + } + + while(!bwin->Connected()) { snooze(100); } + + /* Make sure we have exclusive access to frame buffer data */ + bwin->LockBuffer(); + + /* format */ + display_mode bmode; + bscreen.GetMode(&bmode); + int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode.space); + *format = BE_BPPToSDLPxFormat(bpp); + + /* Create the new bitmap object */ + BBitmap *bitmap = bwin->GetBitmap(); + + if(bitmap) { + delete bitmap; + } + bitmap = new BBitmap(bwin->Bounds(), (color_space)bmode.space, + false, /* Views not accepted */ + true); /* Contiguous memory required */ + + if(bitmap->InitCheck() != B_OK) { + SDL_SetError("Could not initialize back buffer!\n"); + return -1; + } + + + bwin->SetBitmap(bitmap); + + /* Set the pixel pointer */ + *pixels = bitmap->Bits(); + + /* pitch = width of window, in bytes */ + *pitch = bitmap->BytesPerRow(); + + bwin->SetBufferExists(true); + bwin->SetTrashBuffer(false); + bwin->UnlockBuffer(); + return 0; +} + + + +int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, + SDL_Rect * rects, int numrects) { + if(!window) + return 0; + + SDL_BWin *bwin = _ToBeWin(window); + +#ifdef DRAWTHREAD + bwin->LockBuffer(); + bwin->SetBufferDirty(true); + bwin->UnlockBuffer(); +#else + bwin->SetBufferDirty(true); + BE_UpdateOnce(window); +#endif + + return 0; +} + +int32 BE_DrawThread(void *data) { + SDL_BWin *bwin = (SDL_BWin*)data; + + BScreen bscreen; + if(!bscreen.IsValid()) { + return -1; + } + + while(bwin->ConnectionEnabled()) { + if( bwin->Connected() && bwin->BufferExists() && bwin->BufferIsDirty() ) { + bwin->LockBuffer(); + BBitmap *bitmap = NULL; + bitmap = bwin->GetBitmap(); + int32 windowPitch = bitmap->BytesPerRow(); + int32 bufferPitch = bwin->GetRowBytes(); + uint8 *windowpx; + uint8 *bufferpx; + + int32 BPP = bwin->GetBytesPerPx(); + int32 windowSub = bwin->GetFbX() * BPP + + bwin->GetFbY() * windowPitch; + clipping_rect *clips = bwin->GetClips(); + int32 numClips = bwin->GetNumClips(); + int i, y; + + /* Blit each clipping rectangle */ + bscreen.WaitForRetrace(); + for(i = 0; i < numClips; ++i) { + clipping_rect rc = clips[i]; + /* Get addresses of the start of each clipping rectangle */ + int32 width = clips[i].right - clips[i].left + 1; + int32 height = clips[i].bottom - clips[i].top + 1; + bufferpx = bwin->GetBufferPx() + + clips[i].top * bufferPitch + clips[i].left * BPP; + windowpx = (uint8*)bitmap->Bits() + + clips[i].top * windowPitch + clips[i].left * BPP - + windowSub; + + /* Copy each row of pixels from the window buffer into the frame + buffer */ + for(y = 0; y < height; ++y) + { + + if(bwin->CanTrashWindowBuffer()) { + goto escape; /* Break out before the buffer is killed */ + } + + memcpy(bufferpx, windowpx, width * BPP); + bufferpx += bufferPitch; + windowpx += windowPitch; + } + } + + bwin->SetBufferDirty(false); +escape: + bwin->UnlockBuffer(); + } else { + snooze(16000); + } + } + + return B_OK; +} + +void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window) { + SDL_BWin *bwin = _ToBeWin(window); + + bwin->LockBuffer(); + + /* Free and clear the window buffer */ + BBitmap *bitmap = bwin->GetBitmap(); + delete bitmap; + bwin->SetBitmap(NULL); + bwin->SetBufferExists(false); + bwin->UnlockBuffer(); +} + + +/* + * TODO: + * This was written to test if certain errors were caused by threading issues. + * The specific issues have since become rare enough that they may have been + * solved, but I doubt it- they were pretty sporadic before now. + */ +int32 BE_UpdateOnce(SDL_Window *window) { + SDL_BWin *bwin = _ToBeWin(window); + BScreen bscreen; + if(!bscreen.IsValid()) { + return -1; + } + + if(bwin->ConnectionEnabled() && bwin->Connected()) { + bwin->LockBuffer(); + int32 windowPitch = window->surface->pitch; + int32 bufferPitch = bwin->GetRowBytes(); + uint8 *windowpx; + uint8 *bufferpx; + + int32 BPP = bwin->GetBytesPerPx(); + uint8 *windowBaseAddress = (uint8*)window->surface->pixels; + int32 windowSub = bwin->GetFbX() * BPP + + bwin->GetFbY() * windowPitch; + clipping_rect *clips = bwin->GetClips(); + int32 numClips = bwin->GetNumClips(); + int i, y; + + /* Blit each clipping rectangle */ + bscreen.WaitForRetrace(); + for(i = 0; i < numClips; ++i) { + clipping_rect rc = clips[i]; + /* Get addresses of the start of each clipping rectangle */ + int32 width = clips[i].right - clips[i].left + 1; + int32 height = clips[i].bottom - clips[i].top + 1; + bufferpx = bwin->GetBufferPx() + + clips[i].top * bufferPitch + clips[i].left * BPP; + windowpx = windowBaseAddress + + clips[i].top * windowPitch + clips[i].left * BPP - windowSub; + + /* Copy each row of pixels from the window buffer into the frame + buffer */ + for(y = 0; y < height; ++y) + { + memcpy(bufferpx, windowpx, width * BPP); + bufferpx += bufferPitch; + windowpx += windowPitch; + } + } + bwin->UnlockBuffer(); + } + return 0; +} + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bframebuffer.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_bframebuffer.h new file mode 100644 index 000000000..05efa5b9a --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bframebuffer.h @@ -0,0 +1,45 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BFRAMEBUFFER_H +#define SDL_BFRAMEBUFFER_H +#include +#ifdef __cplusplus +extern "C" { +#endif + +#define DRAWTHREAD + +#include "../SDL_sysvideo.h" + +extern int BE_CreateWindowFramebuffer(_THIS, SDL_Window * window, + Uint32 * format, + void ** pixels, int *pitch); +extern int BE_UpdateWindowFramebuffer(_THIS, SDL_Window * window, + SDL_Rect * rects, int numrects); +extern void BE_DestroyWindowFramebuffer(_THIS, SDL_Window * window); +extern int32 BE_DrawThread(void *data); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bkeyboard.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_bkeyboard.cc new file mode 100644 index 000000000..13dbd0929 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bkeyboard.cc @@ -0,0 +1,189 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2009 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#include "SDL_events.h" +#include "SDL_keycode.h" + +#include "SDL_bkeyboard.h" + + +#define KEYMAP_SIZE 128 + + +static SDL_Scancode keymap[KEYMAP_SIZE]; +static int8 keystate[KEYMAP_SIZE]; + +void BE_InitOSKeymap() { + for( uint i = 0; i < SDL_TABLESIZE(keymap); ++i ) { + keymap[i] = SDL_SCANCODE_UNKNOWN; + } + + for( uint i = 0; i < KEYMAP_SIZE; ++i ) { + keystate[i] = SDL_RELEASED; + } + + keymap[0x01] = SDL_GetScancodeFromKey(SDLK_ESCAPE); + keymap[B_F1_KEY] = SDL_GetScancodeFromKey(SDLK_F1); + keymap[B_F2_KEY] = SDL_GetScancodeFromKey(SDLK_F2); + keymap[B_F3_KEY] = SDL_GetScancodeFromKey(SDLK_F3); + keymap[B_F4_KEY] = SDL_GetScancodeFromKey(SDLK_F4); + keymap[B_F5_KEY] = SDL_GetScancodeFromKey(SDLK_F5); + keymap[B_F6_KEY] = SDL_GetScancodeFromKey(SDLK_F6); + keymap[B_F7_KEY] = SDL_GetScancodeFromKey(SDLK_F7); + keymap[B_F8_KEY] = SDL_GetScancodeFromKey(SDLK_F8); + keymap[B_F9_KEY] = SDL_GetScancodeFromKey(SDLK_F9); + keymap[B_F10_KEY] = SDL_GetScancodeFromKey(SDLK_F10); + keymap[B_F11_KEY] = SDL_GetScancodeFromKey(SDLK_F11); + keymap[B_F12_KEY] = SDL_GetScancodeFromKey(SDLK_F12); + keymap[B_PRINT_KEY] = SDL_GetScancodeFromKey(SDLK_PRINTSCREEN); + keymap[B_SCROLL_KEY] = SDL_GetScancodeFromKey(SDLK_SCROLLLOCK); + keymap[B_PAUSE_KEY] = SDL_GetScancodeFromKey(SDLK_PAUSE); + keymap[0x11] = SDL_GetScancodeFromKey(SDLK_BACKQUOTE); + keymap[0x12] = SDL_GetScancodeFromKey(SDLK_1); + keymap[0x13] = SDL_GetScancodeFromKey(SDLK_2); + keymap[0x14] = SDL_GetScancodeFromKey(SDLK_3); + keymap[0x15] = SDL_GetScancodeFromKey(SDLK_4); + keymap[0x16] = SDL_GetScancodeFromKey(SDLK_5); + keymap[0x17] = SDL_GetScancodeFromKey(SDLK_6); + keymap[0x18] = SDL_GetScancodeFromKey(SDLK_7); + keymap[0x19] = SDL_GetScancodeFromKey(SDLK_8); + keymap[0x1a] = SDL_GetScancodeFromKey(SDLK_9); + keymap[0x1b] = SDL_GetScancodeFromKey(SDLK_0); + keymap[0x1c] = SDL_GetScancodeFromKey(SDLK_MINUS); + keymap[0x1d] = SDL_GetScancodeFromKey(SDLK_EQUALS); + keymap[0x1e] = SDL_GetScancodeFromKey(SDLK_BACKSPACE); + keymap[0x1f] = SDL_GetScancodeFromKey(SDLK_INSERT); + keymap[0x20] = SDL_GetScancodeFromKey(SDLK_HOME); + keymap[0x21] = SDL_GetScancodeFromKey(SDLK_PAGEUP); + keymap[0x22] = SDL_GetScancodeFromKey(SDLK_NUMLOCKCLEAR); + keymap[0x23] = SDL_GetScancodeFromKey(SDLK_KP_DIVIDE); + keymap[0x24] = SDL_GetScancodeFromKey(SDLK_KP_MULTIPLY); + keymap[0x25] = SDL_GetScancodeFromKey(SDLK_KP_MINUS); + keymap[0x26] = SDL_GetScancodeFromKey(SDLK_TAB); + keymap[0x27] = SDL_GetScancodeFromKey(SDLK_q); + keymap[0x28] = SDL_GetScancodeFromKey(SDLK_w); + keymap[0x29] = SDL_GetScancodeFromKey(SDLK_e); + keymap[0x2a] = SDL_GetScancodeFromKey(SDLK_r); + keymap[0x2b] = SDL_GetScancodeFromKey(SDLK_t); + keymap[0x2c] = SDL_GetScancodeFromKey(SDLK_y); + keymap[0x2d] = SDL_GetScancodeFromKey(SDLK_u); + keymap[0x2e] = SDL_GetScancodeFromKey(SDLK_i); + keymap[0x2f] = SDL_GetScancodeFromKey(SDLK_o); + keymap[0x30] = SDL_GetScancodeFromKey(SDLK_p); + keymap[0x31] = SDL_GetScancodeFromKey(SDLK_LEFTBRACKET); + keymap[0x32] = SDL_GetScancodeFromKey(SDLK_RIGHTBRACKET); + keymap[0x33] = SDL_GetScancodeFromKey(SDLK_BACKSLASH); + keymap[0x34] = SDL_GetScancodeFromKey(SDLK_DELETE); + keymap[0x35] = SDL_GetScancodeFromKey(SDLK_END); + keymap[0x36] = SDL_GetScancodeFromKey(SDLK_PAGEDOWN); + keymap[0x37] = SDL_GetScancodeFromKey(SDLK_KP_7); + keymap[0x38] = SDL_GetScancodeFromKey(SDLK_KP_8); + keymap[0x39] = SDL_GetScancodeFromKey(SDLK_KP_9); + keymap[0x3a] = SDL_GetScancodeFromKey(SDLK_KP_PLUS); + keymap[0x3b] = SDL_GetScancodeFromKey(SDLK_CAPSLOCK); + keymap[0x3c] = SDL_GetScancodeFromKey(SDLK_a); + keymap[0x3d] = SDL_GetScancodeFromKey(SDLK_s); + keymap[0x3e] = SDL_GetScancodeFromKey(SDLK_d); + keymap[0x3f] = SDL_GetScancodeFromKey(SDLK_f); + keymap[0x40] = SDL_GetScancodeFromKey(SDLK_g); + keymap[0x41] = SDL_GetScancodeFromKey(SDLK_h); + keymap[0x42] = SDL_GetScancodeFromKey(SDLK_j); + keymap[0x43] = SDL_GetScancodeFromKey(SDLK_k); + keymap[0x44] = SDL_GetScancodeFromKey(SDLK_l); + keymap[0x45] = SDL_GetScancodeFromKey(SDLK_SEMICOLON); + keymap[0x46] = SDL_GetScancodeFromKey(SDLK_QUOTE); + keymap[0x47] = SDL_GetScancodeFromKey(SDLK_RETURN); + keymap[0x48] = SDL_GetScancodeFromKey(SDLK_KP_4); + keymap[0x49] = SDL_GetScancodeFromKey(SDLK_KP_5); + keymap[0x4a] = SDL_GetScancodeFromKey(SDLK_KP_6); + keymap[0x4b] = SDL_GetScancodeFromKey(SDLK_LSHIFT); + keymap[0x4c] = SDL_GetScancodeFromKey(SDLK_z); + keymap[0x4d] = SDL_GetScancodeFromKey(SDLK_x); + keymap[0x4e] = SDL_GetScancodeFromKey(SDLK_c); + keymap[0x4f] = SDL_GetScancodeFromKey(SDLK_v); + keymap[0x50] = SDL_GetScancodeFromKey(SDLK_b); + keymap[0x51] = SDL_GetScancodeFromKey(SDLK_n); + keymap[0x52] = SDL_GetScancodeFromKey(SDLK_m); + keymap[0x53] = SDL_GetScancodeFromKey(SDLK_COMMA); + keymap[0x54] = SDL_GetScancodeFromKey(SDLK_PERIOD); + keymap[0x55] = SDL_GetScancodeFromKey(SDLK_SLASH); + keymap[0x56] = SDL_GetScancodeFromKey(SDLK_RSHIFT); + keymap[0x57] = SDL_GetScancodeFromKey(SDLK_UP); + keymap[0x58] = SDL_GetScancodeFromKey(SDLK_KP_1); + keymap[0x59] = SDL_GetScancodeFromKey(SDLK_KP_2); + keymap[0x5a] = SDL_GetScancodeFromKey(SDLK_KP_3); + keymap[0x5b] = SDL_GetScancodeFromKey(SDLK_KP_ENTER); + keymap[0x5c] = SDL_GetScancodeFromKey(SDLK_LCTRL); + keymap[0x5d] = SDL_GetScancodeFromKey(SDLK_LALT); + keymap[0x5e] = SDL_GetScancodeFromKey(SDLK_SPACE); + keymap[0x5f] = SDL_GetScancodeFromKey(SDLK_RALT); + keymap[0x60] = SDL_GetScancodeFromKey(SDLK_RCTRL); + keymap[0x61] = SDL_GetScancodeFromKey(SDLK_LEFT); + keymap[0x62] = SDL_GetScancodeFromKey(SDLK_DOWN); + keymap[0x63] = SDL_GetScancodeFromKey(SDLK_RIGHT); + keymap[0x64] = SDL_GetScancodeFromKey(SDLK_KP_0); + keymap[0x65] = SDL_GetScancodeFromKey(SDLK_KP_PERIOD); + keymap[0x66] = SDL_GetScancodeFromKey(SDLK_LGUI); + keymap[0x67] = SDL_GetScancodeFromKey(SDLK_RGUI); + keymap[0x68] = SDL_GetScancodeFromKey(SDLK_MENU); + keymap[0x69] = SDL_GetScancodeFromKey(SDLK_2); /* SDLK_EURO */ + keymap[0x6a] = SDL_GetScancodeFromKey(SDLK_KP_EQUALS); + keymap[0x6b] = SDL_GetScancodeFromKey(SDLK_POWER); +} + +SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey) { + if(bkey > 0 && bkey < (int32)SDL_TABLESIZE(keymap)) { + return keymap[bkey]; + } else { + return SDL_SCANCODE_UNKNOWN; + } +} + +int8 BE_GetKeyState(int32 bkey) { + if(bkey > 0 && bkey < KEYMAP_SIZE) { + return keystate[bkey]; + } else { + return SDL_RELEASED; + } +} + +void BE_SetKeyState(int32 bkey, int8 state) { + if(bkey > 0 && bkey < KEYMAP_SIZE) { + keystate[bkey] = state; + } +} + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbriva.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_bkeyboard.h similarity index 67% rename from project/jni/sdl-1.3/src/video/fbcon/SDL_fbriva.h rename to project/jni/sdl-1.3/src/video/bwindow/SDL_bkeyboard.h index 9fbf15c4e..bad9eeaad 100644 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbriva.h +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bkeyboard.h @@ -1,6 +1,6 @@ /* SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Copyright (C) 1997-2009 Sam Lantinga This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -19,19 +19,25 @@ Sam Lantinga slouken@libsdl.org */ -#include "SDL_config.h" -/* Riva hardware acceleration for the SDL framebuffer console driver */ +#ifndef SDL_BKEYBOARD_H +#define SDL_BKEYBOARD_H -#include "SDL_fbvideo.h" +#include -#ifndef FB_ACCEL_NV3 -#define FB_ACCEL_NV3 27 -#endif -#ifndef FB_ACCEL_NV4 -#define FB_ACCEL_NV4 28 +#ifdef __cplusplus +extern "C" { #endif -/* Set up the driver for Riva acceleration */ -extern void FB_RivaAccel(_THIS, __u32 card); -/* vi: set ts=4 sw=4 expandtab: */ +#include "../../../include/SDL_keyboard.h" + +extern void BE_InitOSKeymap(); +extern SDL_Scancode BE_GetScancodeFromBeKey(int32 bkey); +extern int8 BE_GetKeyState(int32 bkey); +extern void BE_SetKeyState(int32 bkey, int8 state); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bmodes.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_bmodes.cc new file mode 100644 index 000000000..a68522be8 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bmodes.cc @@ -0,0 +1,332 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW + +#include +#include +#include "SDL_bmodes.h" +#include "SDL_BWin.h" + +#if SDL_VIDEO_OPENGL +#include "SDL_bopengl.h" +#endif + +#include "../../main/beos/SDL_BApp.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define WRAP_BMODE 1 /* FIXME: Some debate as to whether this is necessary */ + +#if WRAP_BMODE +/* This wrapper is here so that the driverdata can be freed without freeing + the display_mode structure */ +typedef struct SDL_DisplayModeData { + display_mode *bmode; +}; +#endif + +static inline SDL_BWin *_ToBeWin(SDL_Window *window) { + return ((SDL_BWin*)(window->driverdata)); +} + +static inline SDL_BApp *_GetBeApp() { + return ((SDL_BApp*)be_app); +} + +static inline display_mode * _ExtractBMode(SDL_DisplayMode *mode) { +#if WRAP_BMODE + return ((SDL_DisplayModeData*)mode->driverdata)->bmode; +#else + return (display_mode*)(mode->driverdata); +#endif +} + +/* Copied from haiku/trunk/src/preferences/screen/ScreenMode.cpp */ +static float get_refresh_rate(display_mode &mode) { + return float(mode.timing.pixel_clock * 1000) + / float(mode.timing.h_total * mode.timing.v_total); +} + + +#if 0 +/* TODO: + * This is a useful debugging tool. Uncomment and insert into code as needed. + */ +void _SpoutModeData(display_mode *bmode) { + printf("BMode:\n"); + printf("\tw,h = (%i,%i)\n", bmode->virtual_width, bmode->virtual_height); + printf("\th,v = (%i,%i)\n", bmode->h_display_start, + bmode->v_display_start); + if(bmode->flags) { + printf("\tFlags:\n"); + if(bmode->flags & B_SCROLL) { + printf("\t\tB_SCROLL\n"); + } + if(bmode->flags & B_8_BIT_DAC) { + printf("\t\tB_8_BIT_DAC\n"); + } + if(bmode->flags & B_HARDWARE_CURSOR) { + printf("\t\tB_HARDWARE_CURSOR\n"); + } + if(bmode->flags & B_PARALLEL_ACCESS) { + printf("\t\tB_PARALLEL_ACCESS\n"); + } + if(bmode->flags & B_DPMS) { + printf("\t\tB_DPMS\n"); + } + if(bmode->flags & B_IO_FB_NA) { + printf("\t\tB_IO_FB_NA\n"); + } + } + printf("\tTiming:\n"); + printf("\t\tpx clock: %i\n", bmode->timing.pixel_clock); + printf("\t\th - display: %i sync start: %i sync end: %i total: %i\n", + bmode->timing.h_display, bmode->timing.h_sync_start, + bmode->timing.h_sync_end, bmode->timing.h_total); + printf("\t\tv - display: %i sync start: %i sync end: %i total: %i\n", + bmode->timing.v_display, bmode->timing.v_sync_start, + bmode->timing.v_sync_end, bmode->timing.v_total); + if(bmode->timing.flags) { + printf("\t\tFlags:\n"); + if(bmode->timing.flags & B_BLANK_PEDESTAL) { + printf("\t\t\tB_BLANK_PEDESTAL\n"); + } + if(bmode->timing.flags & B_TIMING_INTERLACED) { + printf("\t\t\tB_TIMING_INTERLACED\n"); + } + if(bmode->timing.flags & B_POSITIVE_HSYNC) { + printf("\t\t\tB_POSITIVE_HSYNC\n"); + } + if(bmode->timing.flags & B_POSITIVE_VSYNC) { + printf("\t\t\tB_POSITIVE_VSYNC\n"); + } + if(bmode->timing.flags & B_SYNC_ON_GREEN) { + printf("\t\t\tB_SYNC_ON_GREEN\n"); + } + } +} +#endif + + + +int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace) +{ + int bitsperpixel; + + bitsperpixel = 0; + switch (colorspace) { + case B_CMAP8: + bitsperpixel = 8; + break; + case B_RGB15: + case B_RGBA15: + case B_RGB15_BIG: + case B_RGBA15_BIG: + bitsperpixel = 15; + break; + case B_RGB16: + case B_RGB16_BIG: + bitsperpixel = 16; + break; + case B_RGB32: + case B_RGBA32: + case B_RGB32_BIG: + case B_RGBA32_BIG: + bitsperpixel = 32; + break; + default: + break; + } + return(bitsperpixel); +} + +int32 BE_BPPToSDLPxFormat(int32 bpp) { + /* Translation taken from SDL_windowsmodes.c */ + switch (bpp) { + case 32: + return SDL_PIXELFORMAT_RGB888; + break; + case 24: /* May not be supported by Haiku */ + return SDL_PIXELFORMAT_RGB24; + break; + case 16: + return SDL_PIXELFORMAT_RGB565; + break; + case 15: + return SDL_PIXELFORMAT_RGB555; + break; + case 8: + return SDL_PIXELFORMAT_INDEX8; + break; + case 4: /* May not be supported by Haiku */ + return SDL_PIXELFORMAT_INDEX4LSB; + break; + } + + /* May never get here, but safer and needed to shut up compiler */ + SDL_SetError("Invalid bpp value"); + return 0; +} + +static void _BDisplayModeToSdlDisplayMode(display_mode *bmode, + SDL_DisplayMode *mode) { + mode->w = bmode->virtual_width; + mode->h = bmode->virtual_height; + mode->refresh_rate = (int)get_refresh_rate(*bmode); + +#if WRAP_BMODE + SDL_DisplayModeData *data = (SDL_DisplayModeData*)SDL_calloc(1, + sizeof(SDL_DisplayModeData)); + data->bmode = bmode; + + mode->driverdata = data; + +#else + + mode->driverdata = bmode; +#endif + + /* Set the format */ + int32 bpp = BE_ColorSpaceToBitsPerPixel(bmode->space); + mode->format = BE_BPPToSDLPxFormat(bpp); +} + +/* Later, there may be more than one monitor available */ +static void _AddDisplay(BScreen *screen) { + SDL_VideoDisplay display; + SDL_DisplayMode *mode = (SDL_DisplayMode*)SDL_calloc(1, + sizeof(SDL_DisplayMode)); + display_mode *bmode = (display_mode*)SDL_calloc(1, sizeof(display_mode)); + screen->GetMode(bmode); + + _BDisplayModeToSdlDisplayMode(bmode, mode); + + SDL_zero(display); + display.desktop_mode = *mode; + display.current_mode = *mode; + + SDL_AddVideoDisplay(&display); +} + +/* + * Functions called by SDL + */ + +int BE_InitModes(_THIS) { + BScreen screen; + + /* TODO: When Haiku supports multiple display screens, call + _AddDisplayScreen() for each of them. */ + _AddDisplay(&screen); + return 0; +} + +int BE_QuitModes(_THIS) { + /* FIXME: Nothing really needs to be done here at the moment? */ + return 0; +} + + +int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, SDL_Rect *rect) { + BScreen bscreen; + BRect rc = bscreen.Frame(); + rect->x = (int)rc.left; + rect->y = (int)rc.top; + rect->w = (int)rc.Width() + 1; + rect->h = (int)rc.Height() + 1; + return 0; +} + +void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display) { + /* Get the current screen */ + BScreen bscreen; + + /* Iterate through all of the modes */ + SDL_DisplayMode mode; + display_mode this_bmode; + display_mode *bmodes; + uint32 count, i; + + /* Get graphics-hardware supported modes */ + bscreen.GetModeList(&bmodes, &count); + bscreen.GetMode(&this_bmode); + + for(i = 0; i < count; ++i) { + //FIXME: Apparently there are errors with colorspace changes + if (bmodes[i].space == this_bmode.space) { + _BDisplayModeToSdlDisplayMode(&bmodes[i], &mode); + SDL_AddDisplayMode(display, &mode); + } + } + free(bmodes); +} + + +int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode){ + /* Get the current screen */ + BScreen bscreen; + if(!bscreen.IsValid()) { + printf(__FILE__": %d - ERROR: BAD SCREEN\n", __LINE__); + } + + /* Set the mode using the driver data */ + display_mode *bmode = _ExtractBMode(mode); + + + /* FIXME: Is the first option always going to be the right one? */ + uint32 c = 0, i; + display_mode *bmode_list; + bscreen.GetModeList(&bmode_list, &c); + for(i = 0; i < c; ++i) { + if( bmode_list[i].space == bmode->space && + bmode_list[i].virtual_width == bmode->virtual_width && + bmode_list[i].virtual_height == bmode->virtual_height ) { + bmode = &bmode_list[i]; + break; + } + } + + if(bscreen.SetMode(bmode) != B_OK) { + SDL_SetError("Bad video mode\n"); + return -1; + } + + free(bmode_list); + +#if SDL_VIDEO_OPENGL + /* FIXME: Is there some way to reboot the OpenGL context? This doesn't + help */ +// BE_GL_RebootContexts(_this); +#endif + + return 0; +} + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bmodes.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_bmodes.h new file mode 100644 index 000000000..f958f6632 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bmodes.h @@ -0,0 +1,46 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BMODES_H +#define SDL_BMODES_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../SDL_sysvideo.h" + +extern int32 BE_ColorSpaceToBitsPerPixel(uint32 colorspace); +extern int32 BE_BPPToSDLPxFormat(int32 bpp); + +extern int BE_InitModes(_THIS); +extern int BE_QuitModes(_THIS); +extern int BE_GetDisplayBounds(_THIS, SDL_VideoDisplay *display, + SDL_Rect *rect); +extern void BE_GetDisplayModes(_THIS, SDL_VideoDisplay *display); +extern int BE_SetDisplayMode(_THIS, SDL_VideoDisplay *display, + SDL_DisplayMode *mode); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bopengl.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_bopengl.cc new file mode 100644 index 000000000..d2f4e790c --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bopengl.cc @@ -0,0 +1,219 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW + +#include "SDL_bopengl.h" + +#include +#include +#include +#include "SDL_BWin.h" +#include "../../main/beos/SDL_BApp.h" + +#ifdef __cplusplus +extern "C" { +#endif + + +#define BGL_FLAGS BGL_RGB | BGL_DOUBLE + +static inline SDL_BWin *_ToBeWin(SDL_Window *window) { + return ((SDL_BWin*)(window->driverdata)); +} + +static inline SDL_BApp *_GetBeApp() { + return ((SDL_BApp*)be_app); +} + +/* Passing a NULL path means load pointers from the application */ +int BE_GL_LoadLibrary(_THIS, const char *path) +{ +/* FIXME: Is this working correctly? */ + image_info info; + int32 cookie = 0; + while (get_next_image_info(0, &cookie, &info) == B_OK) { + void *location = NULL; + if( get_image_symbol(info.id, "glBegin", B_SYMBOL_TYPE_ANY, + &location) == B_OK) { + + _this->gl_config.dll_handle = (void *) info.id; + _this->gl_config.driver_loaded = 1; + SDL_strlcpy(_this->gl_config.driver_path, "libGL.so", + SDL_arraysize(_this->gl_config.driver_path)); + } + } + return 0; +} + +void *BE_GL_GetProcAddress(_THIS, const char *proc) +{ + if (_this->gl_config.dll_handle != NULL) { + void *location = NULL; + status_t err; + if ((err = + get_image_symbol((image_id) _this->gl_config.dll_handle, + proc, B_SYMBOL_TYPE_ANY, + &location)) == B_OK) { + return location; + } else { + SDL_SetError("Couldn't find OpenGL symbol"); + return NULL; + } + } else { + SDL_SetError("OpenGL library not loaded"); + return NULL; + } +} + + + + +void BE_GL_SwapWindow(_THIS, SDL_Window * window) { + _ToBeWin(window)->SwapBuffers(); +} + +int BE_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { + _GetBeApp()->SetCurrentContext(((SDL_BWin*)context)->GetGLView()); + return 0; +} + + +SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window) { + /* FIXME: Not sure what flags should be included here; may want to have + most of them */ + SDL_BWin *bwin = _ToBeWin(window); + bwin->CreateGLView(BGL_FLAGS); + return (SDL_GLContext)(bwin); +} + +void BE_GL_DeleteContext(_THIS, SDL_GLContext context) { + /* Currently, automatically unlocks the view */ + ((SDL_BWin*)context)->RemoveGLView(); +} + + +int BE_GL_SetSwapInterval(_THIS, int interval) { + /* TODO: Implement this, if necessary? */ + return 0; +} + +int BE_GL_GetSwapInterval(_THIS) { + /* TODO: Implement this, if necessary? */ + return 0; +} + + +void BE_GL_UnloadLibrary(_THIS) { + /* TODO: Implement this, if necessary? */ +} + + +/* FIXME: This function is meant to clear the OpenGL context when the video + mode changes (see SDL_bmodes.cc), but it doesn't seem to help, and is not + currently in use. */ +void BE_GL_RebootContexts(_THIS) { + SDL_Window *window = _this->windows; + while(window) { + SDL_BWin *bwin = _ToBeWin(window); + if(bwin->GetGLView()) { + bwin->LockLooper(); + bwin->RemoveGLView(); + bwin->CreateGLView(BGL_FLAGS); + bwin->UnlockLooper(); + } + window = window->next; + } +} + + +#if 0 /* Functions from 1.2 that do not appear to be used in 1.3 */ + + int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) + { + /* + FIXME? Right now BE_GL_GetAttribute shouldn't be called between glBegin() and glEnd() - it doesn't use "cached" values + */ + switch (attrib) { + case SDL_GL_RED_SIZE: + glGetIntegerv(GL_RED_BITS, (GLint *) value); + break; + case SDL_GL_GREEN_SIZE: + glGetIntegerv(GL_GREEN_BITS, (GLint *) value); + break; + case SDL_GL_BLUE_SIZE: + glGetIntegerv(GL_BLUE_BITS, (GLint *) value); + break; + case SDL_GL_ALPHA_SIZE: + glGetIntegerv(GL_ALPHA_BITS, (GLint *) value); + break; + case SDL_GL_DOUBLEBUFFER: + glGetBooleanv(GL_DOUBLEBUFFER, (GLboolean *) value); + break; + case SDL_GL_BUFFER_SIZE: + int v; + glGetIntegerv(GL_RED_BITS, (GLint *) & v); + *value = v; + glGetIntegerv(GL_GREEN_BITS, (GLint *) & v); + *value += v; + glGetIntegerv(GL_BLUE_BITS, (GLint *) & v); + *value += v; + glGetIntegerv(GL_ALPHA_BITS, (GLint *) & v); + *value += v; + break; + case SDL_GL_DEPTH_SIZE: + glGetIntegerv(GL_DEPTH_BITS, (GLint *) value); /* Mesa creates 16 only? r5 always 32 */ + break; + case SDL_GL_STENCIL_SIZE: + glGetIntegerv(GL_STENCIL_BITS, (GLint *) value); + break; + case SDL_GL_ACCUM_RED_SIZE: + glGetIntegerv(GL_ACCUM_RED_BITS, (GLint *) value); + break; + case SDL_GL_ACCUM_GREEN_SIZE: + glGetIntegerv(GL_ACCUM_GREEN_BITS, (GLint *) value); + break; + case SDL_GL_ACCUM_BLUE_SIZE: + glGetIntegerv(GL_ACCUM_BLUE_BITS, (GLint *) value); + break; + case SDL_GL_ACCUM_ALPHA_SIZE: + glGetIntegerv(GL_ACCUM_ALPHA_BITS, (GLint *) value); + break; + case SDL_GL_STEREO: + case SDL_GL_MULTISAMPLEBUFFERS: + case SDL_GL_MULTISAMPLESAMPLES: + default: + *value = 0; + return (-1); + } + return 0; + } + +#endif + + + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bopengl.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_bopengl.h new file mode 100644 index 000000000..1f718e92c --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bopengl.h @@ -0,0 +1,49 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BOPENGL_H +#define SDL_BOPENGL_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../SDL_sysvideo.h" + + +extern int BE_GL_LoadLibrary(_THIS, const char *path); //FIXME +extern void *BE_GL_GetProcAddress(_THIS, const char *proc); //FIXME +extern void BE_GL_UnloadLibrary(_THIS); //TODO +extern int BE_GL_MakeCurrent(_THIS, SDL_Window * window, + SDL_GLContext context); +extern int BE_GL_SetSwapInterval(_THIS, int interval); //TODO +extern int BE_GL_GetSwapInterval(_THIS); //TODO +extern void BE_GL_SwapWindow(_THIS, SDL_Window * window); +extern SDL_GLContext BE_GL_CreateContext(_THIS, SDL_Window * window); +extern void BE_GL_DeleteContext(_THIS, SDL_GLContext context); + +extern void BE_GL_RebootContexts(_THIS); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bvideo.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_bvideo.cc new file mode 100644 index 000000000..0ff99aff6 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bvideo.cc @@ -0,0 +1,173 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "SDL_bkeyboard.h" +#include "SDL_bwindow.h" +#include "SDL_bclipboard.h" +#include "SDL_bvideo.h" +#include "SDL_bopengl.h" +#include "SDL_bmodes.h" +#include "SDL_bframebuffer.h" +#include "SDL_bevents.h" + +/* FIXME: Undefined functions */ +// #define BE_PumpEvents NULL + #define BE_StartTextInput NULL + #define BE_StopTextInput NULL + #define BE_SetTextInputRect NULL + +// #define BE_DeleteDevice NULL + +/* End undefined functions */ + +static SDL_VideoDevice * +BE_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + /*SDL_VideoData *data;*/ + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + + device->driverdata = NULL; /* FIXME: Is this the cause of some of the + SDL_Quit() errors? */ + +/* TODO: Figure out if any initialization needs to go here */ + + /* Set the function pointers */ + device->VideoInit = BE_VideoInit; + device->VideoQuit = BE_VideoQuit; + device->GetDisplayBounds = BE_GetDisplayBounds; + device->GetDisplayModes = BE_GetDisplayModes; + device->SetDisplayMode = BE_SetDisplayMode; + device->PumpEvents = BE_PumpEvents; + + device->CreateWindow = BE_CreateWindow; + device->CreateWindowFrom = BE_CreateWindowFrom; + device->SetWindowTitle = BE_SetWindowTitle; + device->SetWindowIcon = BE_SetWindowIcon; + device->SetWindowPosition = BE_SetWindowPosition; + device->SetWindowSize = BE_SetWindowSize; + device->ShowWindow = BE_ShowWindow; + device->HideWindow = BE_HideWindow; + device->RaiseWindow = BE_RaiseWindow; + device->MaximizeWindow = BE_MaximizeWindow; + device->MinimizeWindow = BE_MinimizeWindow; + device->RestoreWindow = BE_RestoreWindow; + device->SetWindowFullscreen = BE_SetWindowFullscreen; + device->SetWindowGammaRamp = BE_SetWindowGammaRamp; + device->GetWindowGammaRamp = BE_GetWindowGammaRamp; + device->SetWindowGrab = BE_SetWindowGrab; + device->DestroyWindow = BE_DestroyWindow; + device->GetWindowWMInfo = BE_GetWindowWMInfo; + device->CreateWindowFramebuffer = BE_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = BE_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = BE_DestroyWindowFramebuffer; + + device->shape_driver.CreateShaper = NULL; + device->shape_driver.SetWindowShape = NULL; + device->shape_driver.ResizeWindowShape = NULL; + + + device->GL_LoadLibrary = BE_GL_LoadLibrary; + device->GL_GetProcAddress = BE_GL_GetProcAddress; + device->GL_UnloadLibrary = BE_GL_UnloadLibrary; + device->GL_CreateContext = BE_GL_CreateContext; + device->GL_MakeCurrent = BE_GL_MakeCurrent; + device->GL_SetSwapInterval = BE_GL_SetSwapInterval; + device->GL_GetSwapInterval = BE_GL_GetSwapInterval; + device->GL_SwapWindow = BE_GL_SwapWindow; + device->GL_DeleteContext = BE_GL_DeleteContext; + + device->StartTextInput = BE_StartTextInput; + device->StopTextInput = BE_StopTextInput; + device->SetTextInputRect = BE_SetTextInputRect; + + device->SetClipboardText = BE_SetClipboardText; + device->GetClipboardText = BE_GetClipboardText; + device->HasClipboardText = BE_HasClipboardText; + + device->free = BE_DeleteDevice; + + return device; +} + +VideoBootStrap BWINDOW_bootstrap = { + "bwindow", "BDirectWindow graphics", + BE_Available, BE_CreateDevice +}; + +void BE_DeleteDevice(SDL_VideoDevice * device) +{ + SDL_free(device->driverdata); + SDL_free(device); +} + +int BE_VideoInit(_THIS) +{ + /* Initialize the Be Application for appserver interaction */ + if (SDL_InitBeApp() < 0) { + return -1; + } + + /* Initialize video modes */ + BE_InitModes(_this); + + /* Init the keymap */ + BE_InitOSKeymap(); + + +#if SDL_VIDEO_OPENGL + /* testgl application doesn't load library, just tries to load symbols */ + /* is it correct? if so we have to load library here */ + BE_GL_LoadLibrary(_this, NULL); +#endif + + /* We're done! */ + return (0); +} + +int BE_Available(void) +{ + return (1); +} + +void BE_VideoQuit(_THIS) +{ + + BE_QuitModes(_this); + + SDL_QuitBeApp(); +} + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bvideo.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_bvideo.h new file mode 100644 index 000000000..50fe62c21 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bvideo.h @@ -0,0 +1,42 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef BVIDEO_H +#define BVIDEO_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "../../main/beos/SDL_BeApp.h" +#include "../SDL_sysvideo.h" + + +extern void BE_VideoQuit(_THIS); +extern int BE_VideoInit(_THIS); +extern void BE_DeleteDevice(_THIS); +extern int BE_Available(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bwindow.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_bwindow.cc new file mode 100644 index 000000000..1c97211e7 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bwindow.cc @@ -0,0 +1,215 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_BWINDOW +#include "../SDL_sysvideo.h" + +#include "SDL_BWin.h" +#include + +/* Define a path to window's BWIN data */ +#ifdef __cplusplus +extern "C" { +#endif + +static inline SDL_BWin *_ToBeWin(SDL_Window *window) { + return ((SDL_BWin*)(window->driverdata)); +} + +static inline SDL_BApp *_GetBeApp() { + return ((SDL_BApp*)be_app); +} + +static int _InitWindow(_THIS, SDL_Window *window) { + uint32 flags = 0; + BRect bounds( + window->x, + window->y, + window->x + window->w - 1, //BeWindows have an off-by-one px w/h thing + window->y + window->h - 1 + ); + + if(window->flags & SDL_WINDOW_FULLSCREEN) { + /* TODO: Add support for this flag */ + printf(__FILE__": %d!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n",__LINE__); + } + if(window->flags & SDL_WINDOW_OPENGL) { + /* TODO: Add support for this flag */ + } + if(!(window->flags & SDL_WINDOW_RESIZABLE)) { + flags |= B_NOT_RESIZABLE | B_NOT_ZOOMABLE; + } + if(window->flags & SDL_WINDOW_BORDERLESS) { + /* TODO: Add support for this flag */ + } + + SDL_BWin *bwin = new(std::nothrow) SDL_BWin(bounds, flags); + if(bwin == NULL) + return ENOMEM; + + window->driverdata = bwin; + int32 winID = _GetBeApp()->GetID(window); + bwin->SetID(winID); + + return 0; +} + +int BE_CreateWindow(_THIS, SDL_Window *window) { + if(_InitWindow(_this, window) == ENOMEM) + return ENOMEM; + + /* Start window loop */ + _ToBeWin(window)->Show(); + return 0; +} + +int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data) { + + SDL_BWin *otherBWin = (SDL_BWin*)data; + if(!otherBWin->LockLooper()) + return -1; + + /* Create the new window and initialize its members */ + window->x = (int)otherBWin->Frame().left; + window->y = (int)otherBWin->Frame().top; + window->w = (int)otherBWin->Frame().Width(); + window->h = (int)otherBWin->Frame().Height(); + + /* Set SDL flags */ + if(!(otherBWin->Flags() & B_NOT_RESIZABLE)) { + window->flags |= SDL_WINDOW_RESIZABLE; + } + + /* If we are out of memory, return the error code */ + if(_InitWindow(_this, window) == ENOMEM) + return ENOMEM; + + /* TODO: Add any other SDL-supported window attributes here */ + _ToBeWin(window)->SetTitle(otherBWin->Title()); + + /* Start window loop and unlock the other window */ + _ToBeWin(window)->Show(); + + otherBWin->UnlockLooper(); + return 0; +} + +void BE_SetWindowTitle(_THIS, SDL_Window * window) { + BMessage msg(BWIN_SET_TITLE); + msg.AddString("window-title", window->title); + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) { + /* FIXME: Icons not supported by BeOs/Haiku */ +} + +void BE_SetWindowPosition(_THIS, SDL_Window * window) { + BMessage msg(BWIN_MOVE_WINDOW); + msg.AddInt32("window-x", window->x); + msg.AddInt32("window-y", window->y); + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_SetWindowSize(_THIS, SDL_Window * window) { + BMessage msg(BWIN_RESIZE_WINDOW); + msg.AddInt32("window-w", window->w - 1); + msg.AddInt32("window-h", window->h - 1); + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_ShowWindow(_THIS, SDL_Window * window) { + BMessage msg(BWIN_SHOW_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_HideWindow(_THIS, SDL_Window * window) { + BMessage msg(BWIN_HIDE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_RaiseWindow(_THIS, SDL_Window * window) { + BMessage msg(BWIN_SHOW_WINDOW); /* Activate this window and move to front */ + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_MaximizeWindow(_THIS, SDL_Window * window) { + BMessage msg(BWIN_MAXIMIZE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_MinimizeWindow(_THIS, SDL_Window * window) { + BMessage msg(BWIN_MINIMIZE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_RestoreWindow(_THIS, SDL_Window * window) { + BMessage msg(BWIN_RESTORE_WINDOW); + _ToBeWin(window)->PostMessage(&msg); +} + +void BE_SetWindowFullscreen(_THIS, SDL_Window * window, + SDL_VideoDisplay * display, SDL_bool fullscreen) { + /* Haiku tracks all video display information */ + BMessage msg(BWIN_FULLSCREEN); + msg.AddBool("fullscreen", fullscreen); + _ToBeWin(window)->PostMessage(&msg); + +} + +int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) { + /* FIXME: Not BeOs/Haiku supported */ + return -1; +} + +int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) { + /* FIXME: Not BeOs/Haiku supported */ + return -1; +} + + +void BE_SetWindowGrab(_THIS, SDL_Window * window) { + /* TODO: Implement this! */ +} + +void BE_DestroyWindow(_THIS, SDL_Window * window) { + _ToBeWin(window)->LockLooper(); /* This MUST be locked */ + _GetBeApp()->ClearID(_ToBeWin(window)); + _ToBeWin(window)->Quit(); + window->driverdata = NULL; +} + +SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window, + struct SDL_SysWMinfo *info) { + /* FIXME: What is the point of this? What information should be included? */ + return SDL_FALSE; +} + + + + + +#ifdef __cplusplus +} +#endif + +#endif /* SDL_VIDEO_DRIVER_BWINDOW */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_bwindow.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_bwindow.h new file mode 100644 index 000000000..a274fc753 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/bwindow/SDL_bwindow.h @@ -0,0 +1,52 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef SDL_BWINDOW_H +#define SDL_BWINDOW_H + + +#include "../SDL_sysvideo.h" + + +extern int BE_CreateWindow(_THIS, SDL_Window *window); +extern int BE_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); +extern void BE_SetWindowTitle(_THIS, SDL_Window * window); +extern void BE_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); +extern void BE_SetWindowPosition(_THIS, SDL_Window * window); +extern void BE_SetWindowSize(_THIS, SDL_Window * window); +extern void BE_ShowWindow(_THIS, SDL_Window * window); +extern void BE_HideWindow(_THIS, SDL_Window * window); +extern void BE_RaiseWindow(_THIS, SDL_Window * window); +extern void BE_MaximizeWindow(_THIS, SDL_Window * window); +extern void BE_MinimizeWindow(_THIS, SDL_Window * window); +extern void BE_RestoreWindow(_THIS, SDL_Window * window); +extern void BE_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); +extern int BE_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); +extern int BE_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); +extern void BE_SetWindowGrab(_THIS, SDL_Window * window); +extern void BE_DestroyWindow(_THIS, SDL_Window * window); +extern SDL_bool BE_GetWindowWMInfo(_THIS, SDL_Window * window, + struct SDL_SysWMinfo *info); + + + +#endif + diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_lowvideo.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_lowvideo.h deleted file mode 100644 index ee3c9d8bb..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_lowvideo.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_lowvideo_h -#define _SDL_lowvideo_h - -#include "SDL_BWin.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *_this - -/* Private display data */ -struct SDL_PrivateVideoData -{ - /* The main window */ - SDL_BWin *SDL_Win; - - /* The fullscreen mode list */ - display_mode saved_mode; -#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ - int SDL_nummodes[NUM_MODELISTS]; - SDL_Rect **SDL_modelist[NUM_MODELISTS]; - - /* A completely clear cursor */ - WMcursor *BlankCursor; - - SDL_Overlay *overlay; -}; -/* Old variable names */ -#define SDL_Win (_this->hidden->SDL_Win) -#define saved_mode (_this->hidden->saved_mode) -#define SDL_nummodes (_this->hidden->SDL_nummodes) -#define SDL_modelist (_this->hidden->SDL_modelist) -#define SDL_BlankCursor (_this->hidden->BlankCursor) -#define current_overlay (_this->hidden->overlay) - -#endif /* _SDL_lowvideo_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysevents.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_sysevents.cc deleted file mode 100644 index 36d2b5a0c..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysevents.cc +++ /dev/null @@ -1,49 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include -#include -#include -#include "SDL_error.h" -#include "SDL_events.h" -#include "SDL_BWin.h" -#include "SDL_lowvideo.h" - -extern "C" -{ - -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" -#include "SDL_sysevents_c.h" - - void BE_PumpEvents(_THIS) - { - } - - void BE_InitOSKeymap(_THIS) - { - } - -}; /* Extern C */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysevents_c.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_sysevents_c.h deleted file mode 100644 index 1c1079615..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysevents_c.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_lowvideo.h" - -/* Variables and functions exported by SDL_sysevents.c to other parts - of the native video subsystem (SDL_sysvideo.c) -*/ - -extern void BE_InitOSKeymap(_THIS); -extern void BE_PumpEvents(_THIS); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysmouse.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_sysmouse.cc deleted file mode 100644 index 2dd34e322..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysmouse.cc +++ /dev/null @@ -1,145 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include -#include - -#include "SDL_BWin.h" - -extern "C" -{ - -#include "SDL_sysmouse_c.h" - -/* Convert bits to padded bytes */ -#define PADDED_BITS(bits) ((bits+7)/8) - -/* The implementation dependent data for the window manager cursor */ - struct WMcursor - { - char *bits; - }; - -/* Can this be done in the BeOS? */ - WMcursor *BE_CreateWMCursor(_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y) - { - WMcursor *cursor; - int allowed_x; - int allowed_y; - int run, pad, i; - char *cptr; - - allowed_x = 16; /* BeOS limitation */ - allowed_y = 16; /* BeOS limitation */ - if ((w > allowed_x) || (h > allowed_y)) - { - SDL_SetError("Only cursors of dimension (%dx%d) are allowed", - allowed_x, allowed_y); - return (NULL); - } - - /* Allocate the cursor */ - cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor)); - if (cursor == NULL) { - SDL_OutOfMemory(); - return (NULL); - } - cursor->bits = - (char *) SDL_malloc(4 + 2 * ((allowed_x / 8) * allowed_y)); - if (cursor->bits == NULL) { - SDL_free(cursor); - SDL_OutOfMemory(); - return (NULL); - } - cursor->bits[0] = allowed_y; /* Size of the cursor */ - cursor->bits[1] = 1; /* Bit depth of cursor */ - cursor->bits[2] = hot_y; - cursor->bits[3] = hot_x; - cptr = &cursor->bits[4]; - - /* Pad out to the normal cursor size */ - run = PADDED_BITS(w); - pad = PADDED_BITS(allowed_x) - run; - for (i = 0; i < h; ++i) { - SDL_memcpy(cptr, data, run); - SDL_memset(cptr + run, 0, pad); - data += run; - cptr += (run + pad); - } - for (; i < allowed_y; ++i) { - SDL_memset(cptr, 0, run + pad); - cptr += (run + pad); - } - for (i = 0; i < h; ++i) { - /* FIXME: The mask should be OR'd with the data to turn - inverted color pixels black, since inverted color pixels - aren't supported under BeOS. - */ - SDL_memcpy(cptr, mask, run); - SDL_memset(cptr + run, 0, pad); - mask += run; - cptr += (run + pad); - } - for (; i < allowed_y; ++i) { - SDL_memset(cptr, 0, run + pad); - cptr += (run + pad); - } - return (cursor); - } - - int BE_ShowWMCursor(_THIS, WMcursor * cursor) - { - if (be_app->Lock()) { - if (cursor == NULL) { - if (SDL_BlankCursor != NULL) { - be_app->SetCursor(SDL_BlankCursor->bits); - } - } else { - be_app->SetCursor(cursor->bits); - } - be_app->Unlock(); - } - return (1); - } - - void BE_FreeWMCursor(_THIS, WMcursor * cursor) - { - SDL_free(cursor->bits); - SDL_free(cursor); - } - -/* Implementation by Christian Bauer */ - void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y) - { - BPoint pt(x, y); - SDL_Win->Lock(); - SDL_Win->ConvertToScreen(&pt); - SDL_Win->Unlock(); - set_mouse_position((int32) pt.x, (int32) pt.y); - } - -}; /* Extern C */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysmouse_c.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_sysmouse_c.h deleted file mode 100644 index 7e9fe49a0..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysmouse_c.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_lowvideo.h" - -/* Functions to be exported */ -extern void BE_FreeWMCursor(_THIS, WMcursor * cursor); -extern WMcursor *BE_CreateWMCursor(_THIS, - Uint8 * data, Uint8 * mask, int w, int h, - int hot_x, int hot_y); -extern int BE_ShowWMCursor(_THIS, WMcursor * cursor); -extern void BE_WarpWMCursor(_THIS, Uint16 x, Uint16 y); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysvideo.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_sysvideo.cc deleted file mode 100644 index 8ebe44a40..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysvideo.cc +++ /dev/null @@ -1,863 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* BWindow based framebuffer implementation */ - -#include - -#include "SDL_BWin.h" -#include "SDL_timer.h" - -extern "C" -{ - -#include "../SDL_sysvideo.h" -#include "../../events/SDL_events_c.h" -#include "SDL_sysevents_c.h" -#include "SDL_sysmouse_c.h" -#include "SDL_syswm_c.h" -#include "SDL_lowvideo.h" -#include "../SDL_yuvfuncs.h" -#include "SDL_sysyuv.h" -#include "../blank_cursor.h" - -#define BEOS_HIDDEN_SIZE 32 /* starting hidden window size */ - -/* Initialization/Query functions */ - static int BE_VideoInit(_THIS, SDL_PixelFormat * vformat); - static SDL_Rect **BE_ListModes(_THIS, SDL_PixelFormat * format, - Uint32 flags); - static SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); - static void BE_UpdateMouse(_THIS); - static int BE_SetColors(_THIS, int firstcolor, int ncolors, - SDL_Color * colors); - static void BE_VideoQuit(_THIS); - -/* Hardware surface functions */ - static int BE_AllocHWSurface(_THIS, SDL_Surface * surface); - static int BE_LockHWSurface(_THIS, SDL_Surface * surface); - static void BE_UnlockHWSurface(_THIS, SDL_Surface * surface); - static void BE_FreeHWSurface(_THIS, SDL_Surface * surface); - - static int BE_ToggleFullScreen(_THIS, int fullscreen); - static SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); - -/* OpenGL functions */ -#if SDL_VIDEO_OPENGL - static int BE_GL_LoadLibrary(_THIS, const char *path); - static void *BE_GL_GetProcAddress(_THIS, const char *proc); - static int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value); - static int BE_GL_MakeCurrent(_THIS); - static void BE_GL_SwapBuffers(_THIS); -#endif - -/* FB driver bootstrap functions */ - - static int BE_Available(void) - { - return (1); - } - - static void BE_DeleteDevice(SDL_VideoDevice * device) - { - SDL_free(device->hidden); - SDL_free(device); - } - - static SDL_VideoDevice *BE_CreateDevice(int devindex) - { - SDL_VideoDevice *device; - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); - if (device) { - SDL_memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *device->hidden)); - } - if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } - return (0); - } - SDL_memset(device->hidden, 0, (sizeof *device->hidden)); - - /* Set the function pointers */ - /* Initialization/Query functions */ - device->VideoInit = BE_VideoInit; - device->ListModes = BE_ListModes; - device->SetVideoMode = BE_SetVideoMode; - device->ToggleFullScreen = BE_ToggleFullScreen; - device->UpdateMouse = BE_UpdateMouse; - device->CreateYUVOverlay = BE_CreateYUVOverlay; - device->SetColors = BE_SetColors; - device->UpdateRects = NULL; - device->VideoQuit = BE_VideoQuit; - /* Hardware acceleration functions */ - device->AllocHWSurface = BE_AllocHWSurface; - device->CheckHWBlit = NULL; - device->FillHWRect = NULL; - device->SetHWColorKey = NULL; - device->SetHWAlpha = NULL; - device->LockHWSurface = BE_LockHWSurface; - device->UnlockHWSurface = BE_UnlockHWSurface; - device->FlipHWSurface = NULL; - device->FreeHWSurface = BE_FreeHWSurface; - /* Gamma support */ -#if SDL_VIDEO_OPENGL - /* OpenGL support */ - device->GL_LoadLibrary = BE_GL_LoadLibrary; - device->GL_GetProcAddress = BE_GL_GetProcAddress; - device->GL_GetAttribute = BE_GL_GetAttribute; - device->GL_MakeCurrent = BE_GL_MakeCurrent; - device->GL_SwapBuffers = BE_GL_SwapBuffers; -#endif - /* Window manager functions */ - device->SetCaption = BE_SetWMCaption; - device->SetIcon = NULL; - device->IconifyWindow = BE_IconifyWindow; - device->GrabInput = NULL; - device->GetWMInfo = BE_GetWMInfo; - /* Cursor manager functions */ - device->FreeWMCursor = BE_FreeWMCursor; - device->CreateWMCursor = BE_CreateWMCursor; - device->ShowWMCursor = BE_ShowWMCursor; - device->WarpWMCursor = BE_WarpWMCursor; - device->MoveWMCursor = NULL; - device->CheckMouseMode = NULL; - /* Event manager functions */ - device->InitOSKeymap = BE_InitOSKeymap; - device->PumpEvents = BE_PumpEvents; - - device->free = BE_DeleteDevice; - - /* Set the driver flags */ - device->handles_any_size = 1; - - return device; - } - - VideoBootStrap BWINDOW_bootstrap = { - "bwindow", "BDirectWindow graphics", - BE_Available, BE_CreateDevice - }; - - static inline int ColorSpaceToBitsPerPixel(uint32 colorspace) - { - int bitsperpixel; - - bitsperpixel = 0; - switch (colorspace) { - case B_CMAP8: - bitsperpixel = 8; - break; - case B_RGB15: - case B_RGBA15: - case B_RGB15_BIG: - case B_RGBA15_BIG: - bitsperpixel = 15; - break; - case B_RGB16: - case B_RGB16_BIG: - bitsperpixel = 16; - break; - case B_RGB32: - case B_RGBA32: - case B_RGB32_BIG: - case B_RGBA32_BIG: - bitsperpixel = 32; - break; - default: - break; - } - return (bitsperpixel); - } - -/* Function to sort the display_list in bscreen */ - static int CompareModes(const void *A, const void *B) - { - const display_mode *a = (display_mode *) A; - const display_mode *b = (display_mode *) B; - - if (a->space == b->space) { - return ((b->virtual_width * b->virtual_height) - - (a->virtual_width * a->virtual_height)); - } else { - return (ColorSpaceToBitsPerPixel(b->space) - - ColorSpaceToBitsPerPixel(a->space)); - } - } - -/* Yes, this isn't the fastest it could be, but it works nicely */ - static int BE_AddMode(_THIS, int index, unsigned int w, unsigned int h) - { - SDL_Rect *mode; - int i; - int next_mode; - - /* Check to see if we already have this mode */ - if (SDL_nummodes[index] > 0) { - for (i = SDL_nummodes[index] - 1; i >= 0; --i) { - mode = SDL_modelist[index][i]; - if ((mode->w == w) && (mode->h == h)) { -#ifdef BWINDOW_DEBUG - fprintf(stderr, - "We already have mode %dx%d at %d bytes per pixel\n", - w, h, index + 1); -#endif - return (0); - } - } - } - - /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc(sizeof *mode); - if (mode == NULL) { - SDL_OutOfMemory(); - return (-1); - } - mode->x = 0; - mode->y = 0; - mode->w = w; - mode->h = h; -#ifdef BWINDOW_DEBUG - fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, - index + 1); -#endif - - /* Allocate the new list of modes, and fill in the new mode */ - next_mode = SDL_nummodes[index]; - SDL_modelist[index] = (SDL_Rect **) - SDL_realloc(SDL_modelist[index], - (1 + next_mode + 1) * sizeof(SDL_Rect *)); - if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory(); - SDL_nummodes[index] = 0; - SDL_free(mode); - return (-1); - } - SDL_modelist[index][next_mode] = mode; - SDL_modelist[index][next_mode + 1] = NULL; - SDL_nummodes[index]++; - - return (0); - } - - int BE_VideoInit(_THIS, SDL_PixelFormat * vformat) - { - display_mode *modes; - uint32 i, nmodes; - int bpp; - BRect bounds; - - /* Initialize the Be Application for appserver interaction */ - if (SDL_InitBeApp() < 0) { - return (-1); - } - - /* It is important that this be created after SDL_InitBeApp() */ - BScreen bscreen; - - /* Save the current display mode */ - bscreen.GetMode(&saved_mode); - _this->info.current_w = saved_mode.virtual_width; - _this->info.current_h = saved_mode.virtual_height; - - /* Determine the screen depth */ - vformat->BitsPerPixel = - ColorSpaceToBitsPerPixel(bscreen.ColorSpace()); - if (vformat->BitsPerPixel == 0) { - SDL_SetError("Unknown BScreen colorspace: 0x%x", - bscreen.ColorSpace()); - return (-1); - } - - /* Get the video modes we can switch to in fullscreen mode */ - bscreen.GetModeList(&modes, &nmodes); - SDL_qsort(modes, nmodes, sizeof *modes, CompareModes); - for (i = 0; i < nmodes; ++i) { - bpp = ColorSpaceToBitsPerPixel(modes[i].space); - //if ( bpp != 0 ) { // There are bugs in changing colorspace - if (modes[i].space == saved_mode.space) { - BE_AddMode(_this, ((bpp + 7) / 8) - 1, - modes[i].virtual_width, modes[i].virtual_height); - } - } - - /* Create the window and view */ - bounds.top = 0; - bounds.left = 0; - bounds.right = BEOS_HIDDEN_SIZE; - bounds.bottom = BEOS_HIDDEN_SIZE; - SDL_Win = new SDL_BWin(bounds); - -#if SDL_VIDEO_OPENGL - /* testgl application doesn't load library, just tries to load symbols */ - /* is it correct? if so we have to load library here */ - BE_GL_LoadLibrary(_this, NULL); -#endif - - /* Create the clear cursor */ - SDL_BlankCursor = BE_CreateWMCursor(_this, blank_cdata, blank_cmask, - BLANK_CWIDTH, BLANK_CHEIGHT, - BLANK_CHOTX, BLANK_CHOTY); - - /* Fill in some window manager capabilities */ - _this->info.wm_available = 1; - - /* We're done! */ - return (0); - } - -/* We support any dimension at our bit-depth */ - SDL_Rect **BE_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) - { - SDL_Rect **modes; - - modes = ((SDL_Rect **) 0); - if ((flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { - modes = SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]; - } else { - if (format->BitsPerPixel == _this->screen->format->BitsPerPixel) { - modes = ((SDL_Rect **) - 1); - } - } - return (modes); - } - -/* Various screen update functions available */ - static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect * rects); - - -/* Find the closest display mode for fullscreen */ - static bool BE_FindClosestFSMode(_THIS, int width, int height, int bpp, - display_mode * mode) - { - BScreen bscreen; - uint32 i, nmodes; - SDL_Rect **modes; - display_mode *dmodes; - display_mode current; - float current_refresh; - bscreen.GetMode(¤t); - current_refresh = (1000 * current.timing.pixel_clock) / - (current.timing.h_total * current.timing.v_total); - - modes = SDL_modelist[((bpp + 7) / 8) - 1]; - - bool exactmatch = false; - for (uint32 x = 0; modes[x]; x++) { - if (modes[x]->w == width && modes[x]->h == height) { - exactmatch = true; - i = x; - break; - } - } - if (!exactmatch) { - for (i = 0; modes[i] && (modes[i]->w > width) && - (modes[i]->h > height); ++i) { - /* still looking */ - } - if (!modes[i] || (modes[i]->w < width) || (modes[i]->h < height)) { - /* We went too far */ - --i; - } - } - width = modes[i]->w; - height = modes[i]->h; - bscreen.GetModeList(&dmodes, &nmodes); - for (i = 0; i < nmodes; ++i) { - if ((bpp == ColorSpaceToBitsPerPixel(dmodes[i].space)) && - (width == dmodes[i].virtual_width) && - (height == dmodes[i].virtual_height)) { - break; - } - } - if (i != nmodes) { - *mode = dmodes[i]; - if ((mode->virtual_width <= current.virtual_width) && - (mode->virtual_height <= current.virtual_height)) { - float new_refresh = (1000 * mode->timing.pixel_clock) / - (mode->timing.h_total * mode->timing.v_total); - if (new_refresh < current_refresh) { - mode->timing.pixel_clock = - (uint32) ((mode->timing.h_total * - mode->timing.v_total) * - current_refresh / 1000); - } - } - return true; - } else { - return false; - } - } - - static int BE_SetFullScreen(_THIS, SDL_Surface * screen, int fullscreen) - { - int was_fullscreen; - bool needs_unlock; - BScreen bscreen; - BRect bounds; - display_mode mode; - int width, height, bpp; - - /* Set the fullscreen mode */ - was_fullscreen = SDL_Win->IsFullScreen(); - SDL_Win->SetFullScreen(fullscreen); - fullscreen = SDL_Win->IsFullScreen(); - - width = screen->w; - height = screen->h; - - /* Set the appropriate video mode */ - if (fullscreen) { - bpp = screen->format->BitsPerPixel; - bscreen.GetMode(&mode); - if ((bpp != ColorSpaceToBitsPerPixel(mode.space)) || - (width != mode.virtual_width) || - (height != mode.virtual_height)) { - if (BE_FindClosestFSMode(_this, width, height, bpp, &mode)) { - bscreen.SetMode(&mode); - /* This simply stops the next resize event from being - * sent to the SDL handler. - */ - SDL_Win->InhibitResize(); - } else { - fullscreen = 0; - SDL_Win->SetFullScreen(fullscreen); - } - } - } - if (was_fullscreen && !fullscreen) { - bscreen.SetMode(&saved_mode); - } - - if (SDL_Win->Lock()) { - int xoff, yoff; - if (SDL_Win->Shown()) { - needs_unlock = 1; - SDL_Win->Hide(); - } else { - needs_unlock = 0; - } - /* This resizes the window and view area, but inhibits resizing - * of the BBitmap due to the InhibitResize call above. Thus the - * bitmap (pixel data) never changes. - */ - SDL_Win->ResizeTo(width, height); - bounds = bscreen.Frame(); - /* Calculate offsets - used either to center window - * (windowed mode) or to set drawing offsets (fullscreen mode) - */ - xoff = (bounds.IntegerWidth() - width) / 2; - yoff = (bounds.IntegerHeight() - height) / 2; - if (fullscreen) { - /* Set offset for drawing */ - SDL_Win->SetXYOffset(xoff, yoff); - } else { - /* Center window and reset the drawing offset */ - SDL_Win->SetXYOffset(0, 0); - } - if (!needs_unlock || was_fullscreen) { - /* Center the window the first time */ - SDL_Win->MoveTo(xoff > 0 ? (float) xoff : 0.0f, - yoff > 0 ? (float) yoff : 0.0f); - } - SDL_Win->Show(); - - /* Unlock the window manually after the first Show() */ - if (needs_unlock) { - SDL_Win->Unlock(); - } - } - - /* Set the fullscreen flag in the screen surface */ - if (fullscreen) { - screen->flags |= SDL_FULLSCREEN; - } else { - screen->flags &= ~SDL_FULLSCREEN; - } - return (1); - } - - static int BE_ToggleFullScreen(_THIS, int fullscreen) - { - return BE_SetFullScreen(_this, _this->screen, fullscreen); - } - -/* FIXME: check return values and cleanup here */ - SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) - { - BScreen bscreen; - BBitmap *bbitmap; - BRect bounds; - Uint32 gl_flags = 0; - - /* Only RGB works on r5 currently */ - gl_flags = BGL_RGB; - if (_this->gl_config.double_buffer) - gl_flags |= BGL_DOUBLE; - else - gl_flags |= BGL_SINGLE; - if (_this->gl_config.alpha_size > 0 || bpp == 32) - gl_flags |= BGL_ALPHA; - if (_this->gl_config.depth_size > 0) - gl_flags |= BGL_DEPTH; - if (_this->gl_config.stencil_size > 0) - gl_flags |= BGL_STENCIL; - if (_this->gl_config.accum_red_size > 0 - || _this->gl_config.accum_green_size > 0 - || _this->gl_config.accum_blue_size > 0 - || _this->gl_config.accum_alpha_size > 0) - gl_flags |= BGL_ACCUM; - - /* Create the view for this window, using found flags */ - if (SDL_Win->CreateView(flags, gl_flags) < 0) { - return (NULL); - } - - current->flags = 0; /* Clear flags */ - current->w = width; - current->h = height; - SDL_Win->SetType(B_TITLED_WINDOW); - if (flags & SDL_NOFRAME) { - current->flags |= SDL_NOFRAME; - SDL_Win->SetLook(B_NO_BORDER_WINDOW_LOOK); - } else { - if ((flags & SDL_RESIZABLE) && !(flags & SDL_INTERNALOPENGL)) { - current->flags |= SDL_RESIZABLE; - /* We don't want opaque resizing (TM). :-) */ - SDL_Win->SetFlags(B_OUTLINE_RESIZE); - } else { - SDL_Win->SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE); - } - } - - if (flags & SDL_INTERNALOPENGL) { - current->flags |= SDL_INTERNALOPENGL; - current->pitch = 0; - current->pixels = NULL; - _this->UpdateRects = NULL; - } else { - /* Create the BBitmap framebuffer */ - bounds.top = 0; - bounds.left = 0; - bounds.right = width - 1; - bounds.bottom = height - 1; - bbitmap = new BBitmap(bounds, bscreen.ColorSpace()); - if (!bbitmap->IsValid()) { - SDL_SetError("Couldn't create screen bitmap"); - delete bbitmap; - return (NULL); - } - current->pitch = bbitmap->BytesPerRow(); - current->pixels = (void *) bbitmap->Bits(); - SDL_Win->SetBitmap(bbitmap); - _this->UpdateRects = BE_NormalUpdate; - } - - /* Set the correct fullscreen mode */ - BE_SetFullScreen(_this, current, flags & SDL_FULLSCREEN ? 1 : 0); - - /* We're done */ - return (current); - } - -/* Update the current mouse state and position */ - void BE_UpdateMouse(_THIS) - { - BPoint point; - uint32 buttons; - - if (SDL_Win->Lock()) { - /* Get new input state, if still active */ - if (SDL_Win->IsActive()) { - (SDL_Win->View())->GetMouse(&point, &buttons, true); - } else { - point.x = -1; - point.y = -1; - } - SDL_Win->Unlock(); - - if ((point.x >= 0) && (point.x < SDL_VideoSurface->w) && - (point.y >= 0) && (point.y < SDL_VideoSurface->h)) { - SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); - SDL_PrivateMouseMotion(0, 0, - (Sint16) point.x, (Sint16) point.y); - } else { - SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); - } - } - } - -/* We don't actually allow hardware surfaces other than the main one */ - static int BE_AllocHWSurface(_THIS, SDL_Surface * surface) - { - return (-1); - } - static void BE_FreeHWSurface(_THIS, SDL_Surface * surface) - { - return; - } - static int BE_LockHWSurface(_THIS, SDL_Surface * surface) - { - return (0); - } - static void BE_UnlockHWSurface(_THIS, SDL_Surface * surface) - { - return; - } - - static void BE_NormalUpdate(_THIS, int numrects, SDL_Rect * rects) - { - if (SDL_Win->BeginDraw()) { - int i; - - for (i = 0; i < numrects; ++i) { - BRect rect; - - rect.top = rects[i].y; - rect.left = rects[i].x; - rect.bottom = rect.top + rects[i].h - 1; - rect.right = rect.left + rects[i].w - 1; - SDL_Win->DrawAsync(rect); - } - SDL_Win->EndDraw(); - } - } - -#if SDL_VIDEO_OPENGL -/* Passing a NULL path means load pointers from the application */ - int BE_GL_LoadLibrary(_THIS, const char *path) - { - if (path == NULL) { - if (_this->gl_config.dll_handle == NULL) { - image_info info; - int32 cookie = 0; - while (get_next_image_info(0, &cookie, &info) == B_OK) { - void *location = NULL; - if (get_image_symbol - ((image_id) cookie, "glBegin", - B_SYMBOL_TYPE_ANY, &location) == B_OK) { - _this->gl_config.dll_handle = (void *) cookie; - _this->gl_config.driver_loaded = 1; - SDL_strlcpy(_this->gl_config.driver_path, - "libGL.so", - SDL_arraysize(_this-> - gl_config.driver_path)); - } - } - } - } else { - /* - FIXME None of BeOS libGL.so implementations have exported functions - to load BGLView, which should be reloaded from new lib. - So for now just "load" linked libGL.so :( - */ - if (_this->gl_config.dll_handle == NULL) { - return BE_GL_LoadLibrary(_this, NULL); - } - - /* Unload old first */ - /*if (_this->gl_config.dll_handle != NULL) { */ - /* Do not try to unload application itself (if LoadLibrary was called before with NULL ;) */ - /* image_info info; - if (get_image_info((image_id)_this->gl_config.dll_handle, &info) == B_OK) { - if (info.type != B_APP_IMAGE) { - unload_add_on((image_id)_this->gl_config.dll_handle); - } - } - - } - - if ((_this->gl_config.dll_handle = (void*)load_add_on(path)) != (void*)B_ERROR) { - _this->gl_config.driver_loaded = 1; - SDL_strlcpy(_this->gl_config.driver_path, path, SDL_arraysize(_this->gl_config.driver_path)); - } */ - } - - if (_this->gl_config.dll_handle != NULL) { - return 0; - } else { - _this->gl_config.dll_handle = NULL; - _this->gl_config.driver_loaded = 0; - *_this->gl_config.driver_path = '\0'; - return -1; - } - } - - void *BE_GL_GetProcAddress(_THIS, const char *proc) - { - if (_this->gl_config.dll_handle != NULL) { - void *location = NULL; - status_t err; - if ((err = - get_image_symbol((image_id) _this->gl_config.dll_handle, - proc, B_SYMBOL_TYPE_ANY, - &location)) == B_OK) { - return location; - } else { - SDL_SetError("Couldn't find OpenGL symbol"); - return NULL; - } - } else { - SDL_SetError("OpenGL library not loaded"); - return NULL; - } - } - - int BE_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) - { - /* - FIXME? Right now BE_GL_GetAttribute shouldn't be called between glBegin() and glEnd() - it doesn't use "cached" values - */ - switch (attrib) { - case SDL_GL_RED_SIZE: - glGetIntegerv(GL_RED_BITS, (GLint *) value); - break; - case SDL_GL_GREEN_SIZE: - glGetIntegerv(GL_GREEN_BITS, (GLint *) value); - break; - case SDL_GL_BLUE_SIZE: - glGetIntegerv(GL_BLUE_BITS, (GLint *) value); - break; - case SDL_GL_ALPHA_SIZE: - glGetIntegerv(GL_ALPHA_BITS, (GLint *) value); - break; - case SDL_GL_DOUBLEBUFFER: - glGetBooleanv(GL_DOUBLEBUFFER, (GLboolean *) value); - break; - case SDL_GL_BUFFER_SIZE: - int v; - glGetIntegerv(GL_RED_BITS, (GLint *) & v); - *value = v; - glGetIntegerv(GL_GREEN_BITS, (GLint *) & v); - *value += v; - glGetIntegerv(GL_BLUE_BITS, (GLint *) & v); - *value += v; - glGetIntegerv(GL_ALPHA_BITS, (GLint *) & v); - *value += v; - break; - case SDL_GL_DEPTH_SIZE: - glGetIntegerv(GL_DEPTH_BITS, (GLint *) value); /* Mesa creates 16 only? r5 always 32 */ - break; - case SDL_GL_STENCIL_SIZE: - glGetIntegerv(GL_STENCIL_BITS, (GLint *) value); - break; - case SDL_GL_ACCUM_RED_SIZE: - glGetIntegerv(GL_ACCUM_RED_BITS, (GLint *) value); - break; - case SDL_GL_ACCUM_GREEN_SIZE: - glGetIntegerv(GL_ACCUM_GREEN_BITS, (GLint *) value); - break; - case SDL_GL_ACCUM_BLUE_SIZE: - glGetIntegerv(GL_ACCUM_BLUE_BITS, (GLint *) value); - break; - case SDL_GL_ACCUM_ALPHA_SIZE: - glGetIntegerv(GL_ACCUM_ALPHA_BITS, (GLint *) value); - break; - case SDL_GL_STEREO: - case SDL_GL_MULTISAMPLEBUFFERS: - case SDL_GL_MULTISAMPLESAMPLES: - default: - *value = 0; - return (-1); - } - return 0; - } - - int BE_GL_MakeCurrent(_THIS) - { - /* FIXME: should we glview->unlock and then glview->lock()? */ - return 0; - } - - void BE_GL_SwapBuffers(_THIS) - { - SDL_Win->SwapBuffers(); - } -#endif - -/* Is the system palette settable? */ - int BE_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) - { - int i; - SDL_Palette *palette; - const color_map *cmap = BScreen().ColorMap(); - - /* Get the screen colormap */ - palette = _this->screen->format->palette; - for (i = 0; i < 256; ++i) { - palette->colors[i].r = cmap->color_list[i].red; - palette->colors[i].g = cmap->color_list[i].green; - palette->colors[i].b = cmap->color_list[i].blue; - } - return (0); - } - - void BE_VideoQuit(_THIS) - { - int i, j; - - SDL_Win->Quit(); - SDL_Win = NULL; - - if (SDL_BlankCursor != NULL) { - BE_FreeWMCursor(_this, SDL_BlankCursor); - SDL_BlankCursor = NULL; - } - for (i = 0; i < NUM_MODELISTS; ++i) { - if (SDL_modelist[i]) { - for (j = 0; SDL_modelist[i][j]; ++j) { - SDL_free(SDL_modelist[i][j]); - } - SDL_free(SDL_modelist[i]); - SDL_modelist[i] = NULL; - } - } - /* Restore the original video mode */ - if (_this->screen) { - if ((_this->screen->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN) { - BScreen bscreen; - bscreen.SetMode(&saved_mode); - } - _this->screen->pixels = NULL; - } -#if SDL_VIDEO_OPENGL - if (_this->gl_config.dll_handle != NULL) - unload_add_on((image_id) _this->gl_config.dll_handle); -#endif - - SDL_QuitBeApp(); - } - -}; /* Extern C */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_syswm.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_syswm.cc deleted file mode 100644 index d28e09c9f..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_syswm.cc +++ /dev/null @@ -1,55 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_BWin.h" - -extern "C" -{ - -#include "SDL_syswm_c.h" -#include "SDL_error.h" - - void BE_SetWMCaption(_THIS, const char *title, const char *icon) - { - SDL_Win->SetTitle(title); - } - - int BE_IconifyWindow(_THIS) - { - SDL_Win->Minimize(true); - } - - int BE_GetWMInfo(_THIS, SDL_SysWMinfo * info) - { - if (info->version.major <= SDL_MAJOR_VERSION) { - return 1; - } else { - SDL_SetError("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); - return -1; - } - } - -}; /* Extern C */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_syswm_c.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_syswm_c.h deleted file mode 100644 index 63def6c73..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_syswm_c.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_syswm.h" -#include "SDL_lowvideo.h" - - -/* Functions to be exported */ -extern void BE_SetWMCaption(_THIS, const char *title, const char *icon); -extern int BE_IconifyWindow(_THIS); -extern int BE_GetWMInfo(_THIS, SDL_SysWMinfo * info); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysyuv.cc b/project/jni/sdl-1.3/src/video/bwindow/SDL_sysyuv.cc deleted file mode 100644 index 37686b443..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysyuv.cc +++ /dev/null @@ -1,322 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* This is the BeOS version of SDL YUV video overlays */ - -#include "SDL_video.h" -#include "SDL_sysyuv.h" -#include "../SDL_yuvfuncs.h" - -extern "C" -{ - -/* The functions used to manipulate software video overlays */ - static struct private_yuvhwfuncs be_yuvfuncs = { - BE_LockYUVOverlay, - BE_UnlockYUVOverlay, - BE_DisplayYUVOverlay, - BE_FreeYUVOverlay - }; - - BBitmap *BE_GetOverlayBitmap(BRect bounds, color_space cs) - { - BBitmap *bbitmap; - bbitmap = new BBitmap(bounds, B_BITMAP_WILL_OVERLAY, cs); - if (!bbitmap || bbitmap->InitCheck() != B_OK) { - delete bbitmap; - return 0; - } - overlay_restrictions r; - bbitmap->GetOverlayRestrictions(&r); - uint32 width = bounds.IntegerWidth() + 1; - uint32 height = bounds.IntegerHeight() + 1; - uint32 width_padding = 0; - uint32 height_padding = 0; - if ((r.source.horizontal_alignment != 0) || - (r.source.vertical_alignment != 0)) { - delete bbitmap; - return 0; - } - if (r.source.width_alignment != 0) { - uint32 aligned_width = r.source.width_alignment + 1; - if (width % aligned_width > 0) { - width_padding = aligned_width - width % aligned_width; - } - } - if (r.source.height_alignment != 0) { - uint32 aligned_height = r.source.height_alignment + 1; - if (height % aligned_height > 0) { - fprintf(stderr, "GetOverlayBitmap failed height alignment\n"); - fprintf(stderr, "- height = %lu, aligned_height = %lu\n", - height, aligned_height); - delete bbitmap; - return 0; - } - } - if ((r.source.min_width > width) || - (r.source.min_height > height) || - (r.source.max_width < width) || (r.source.max_height < height)) { - fprintf(stderr, "GetOverlayBitmap failed bounds tests\n"); - delete bbitmap; - return 0; - } - if ((width_padding != 0) || (height_padding != 0)) { - delete bbitmap; - bounds.Set(bounds.left, bounds.top, - bounds.right + width_padding, - bounds.bottom + height_padding); - bbitmap = new BBitmap(bounds, B_BITMAP_WILL_OVERLAY, cs); - if (!bbitmap || bbitmap->InitCheck() != B_OK) { - fprintf(stderr, "GetOverlayBitmap failed late\n"); - delete bbitmap; - return 0; - } - } - return bbitmap; - } - -// See [btw: Cb=U, Cr=V] -// See also http://www.fourcc.org/indexyuv.htm - enum color_space convert_color_space(Uint32 format) - { - switch (format) { - case SDL_YV12_OVERLAY: - return B_YUV9; - case SDL_IYUV_OVERLAY: - return B_YUV12; - case SDL_YUY2_OVERLAY: - return B_YCbCr422; - case SDL_UYVY_OVERLAY: - return B_YUV422; - case SDL_YVYU_OVERLAY: // not supported on beos? - return B_NO_COLOR_SPACE; - default: - return B_NO_COLOR_SPACE; - } - } - -// See SDL_video.h - int count_planes(Uint32 format) - { - switch (format) { - case SDL_YV12_OVERLAY: - case SDL_IYUV_OVERLAY: - return 3; - case SDL_YUY2_OVERLAY: - case SDL_UYVY_OVERLAY: - case SDL_YVYU_OVERLAY: - return 1; - default: - return 0; - } - } - - SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, - Uint32 format, SDL_Surface * display) - { - SDL_Overlay *overlay; - struct private_yuvhwdata *hwdata; - BBitmap *bbitmap; - int planes; - BRect bounds; - color_space cs; - - /* find the appropriate BeOS colorspace descriptor */ - cs = convert_color_space(format); - if (cs == B_NO_COLOR_SPACE) { - return NULL; - } - - /* count planes */ - planes = count_planes(format); - if (planes == 0) { - return NULL; - } - /* TODO: figure out planar modes, if anyone cares */ - if (planes == 3) { - return NULL; - } - - /* Create the overlay structure */ - overlay = (SDL_Overlay *) SDL_calloc(1, sizeof(SDL_Overlay)); - - if (overlay == NULL) { - SDL_OutOfMemory(); - return NULL; - } - - /* Fill in the basic members */ - overlay->format = format; - overlay->w = width; - overlay->h = height; - overlay->hwdata = NULL; - - /* Set up the YUV surface function structure */ - overlay->hwfuncs = &be_yuvfuncs; - - /* Create the pixel data and lookup tables */ - hwdata = - (struct private_yuvhwdata *) SDL_calloc(1, - sizeof(struct - private_yuvhwdata)); - - if (hwdata == NULL) { - SDL_OutOfMemory(); - SDL_FreeYUVOverlay(overlay); - return NULL; - } - - overlay->hwdata = hwdata; - overlay->hwdata->display = display; - overlay->hwdata->bview = NULL; - overlay->hwdata->bbitmap = NULL; - overlay->hwdata->locked = 0; - - /* Create the BBitmap framebuffer */ - bounds.top = 0; - bounds.left = 0; - bounds.right = width - 1; - bounds.bottom = height - 1; - - BView *bview = - new BView(bounds, "overlay", B_FOLLOW_NONE, B_WILL_DRAW); - if (!bview) { - SDL_OutOfMemory(); - SDL_FreeYUVOverlay(overlay); - return NULL; - } - overlay->hwdata->bview = bview; - overlay->hwdata->first_display = true; - bview->Hide(); - - bbitmap = BE_GetOverlayBitmap(bounds, cs); - if (!bbitmap) { - overlay->hwdata->bbitmap = NULL; - SDL_FreeYUVOverlay(overlay); - return NULL; - } - overlay->hwdata->bbitmap = bbitmap; - - overlay->planes = planes; - overlay->pitches = - (Uint16 *) SDL_calloc(overlay->planes, sizeof(Uint16)); - overlay->pixels = - (Uint8 **) SDL_calloc(overlay->planes, sizeof(Uint8 *)); - if (!overlay->pitches || !overlay->pixels) { - SDL_OutOfMemory(); - SDL_FreeYUVOverlay(overlay); - return (NULL); - } - - overlay->pitches[0] = bbitmap->BytesPerRow(); - overlay->pixels[0] = (Uint8 *) bbitmap->Bits(); - overlay->hw_overlay = 1; - - if (SDL_Win->LockWithTimeout(1000000) != B_OK) { - SDL_FreeYUVOverlay(overlay); - return (NULL); - } - BView *view = SDL_Win->View(); - view->AddChild(bview); - rgb_color key; - bview->SetViewOverlay(bbitmap, bounds, bview->Bounds(), &key, - B_FOLLOW_ALL, - B_OVERLAY_FILTER_HORIZONTAL | - B_OVERLAY_FILTER_VERTICAL); - bview->SetViewColor(key); - bview->Flush(); - SDL_Win->Unlock(); - - current_overlay = overlay; - - return overlay; - } - - int BE_LockYUVOverlay(_THIS, SDL_Overlay * overlay) - { - if (overlay == NULL) { - return 0; - } - - overlay->hwdata->locked = 1; - return 0; - } - - void BE_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay) - { - if (overlay == NULL) { - return; - } - - overlay->hwdata->locked = 0; - } - - int BE_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, SDL_Rect * src, - SDL_Rect * dst) - { - if ((overlay == NULL) || (overlay->hwdata == NULL) - || (overlay->hwdata->bview == NULL) || (SDL_Win->View() == NULL)) { - return -1; - } - if (SDL_Win->LockWithTimeout(50000) != B_OK) { - return 0; - } - BView *bview = overlay->hwdata->bview; - if (SDL_Win->IsFullScreen()) { - int left, top; - SDL_Win->GetXYOffset(left, top); - bview->MoveTo(left + dst->x, top + dst->y); - } else { - bview->MoveTo(dst->x, dst->y); - } - bview->ResizeTo(dst->w, dst->h); - bview->Flush(); - if (overlay->hwdata->first_display) { - bview->Show(); - overlay->hwdata->first_display = false; - } - SDL_Win->Unlock(); - - return 0; - } - - void BE_FreeYUVOverlay(_THIS, SDL_Overlay * overlay) - { - if (overlay == NULL) { - return; - } - - if (overlay->hwdata == NULL) { - return; - } - - current_overlay = NULL; - - delete overlay->hwdata->bbitmap; - - SDL_free(overlay->hwdata); - } - -}; // extern "C" - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysyuv.h b/project/jni/sdl-1.3/src/video/bwindow/SDL_sysyuv.h deleted file mode 100644 index 8a7a61ee2..000000000 --- a/project/jni/sdl-1.3/src/video/bwindow/SDL_sysyuv.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - - -#ifndef __SDL_SYS_YUV_H__ -#define __SDL_SYS_YUV_H__ - -/* This is the BeOS implementation of YUV video overlays */ - -#include "SDL_video.h" -#include "SDL_lowvideo.h" - -extern "C" -{ - - struct private_yuvhwdata - { -/* FRAMEDATA* CurrentFrameData; - FRAMEDATA* FrameData0; - FRAMEDATA* FrameData1; - PgScalerProps_t props; - PgScalerCaps_t caps; - PgVideoChannel_t* channel; - PhArea_t CurrentViewPort; - PhPoint_t CurrentWindowPos; - long format; - int scaler_on; - int current; - long YStride; - long VStride; - long UStride; - int ischromakey; - long chromakey; - int forcedredraw; - unsigned long State; - long flags; -*/ - SDL_Surface *display; - BView *bview; - bool first_display; - BBitmap *bbitmap; - int locked; - }; - - extern BBitmap *BE_GetOverlayBitmap(BRect bounds, color_space cs); - extern SDL_Overlay *BE_CreateYUVOverlay(_THIS, int width, int height, - Uint32 format, - SDL_Surface * display); - extern int BE_LockYUVOverlay(_THIS, SDL_Overlay * overlay); - extern void BE_UnlockYUVOverlay(_THIS, SDL_Overlay * overlay); - extern int BE_DisplayYUVOverlay(_THIS, SDL_Overlay * overlay, - SDL_Rect * src, SDL_Rect * dst); - extern void BE_FreeYUVOverlay(_THIS, SDL_Overlay * overlay); - -}; - -#endif /* __SDL_PH_YUV_H__ */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaclipboard.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaclipboard.h index 9746e7eb5..f8e119aee 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaclipboard.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaclipboard.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaclipboard.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaclipboard.m index f70e002f1..2b1b231e0 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaclipboard.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaclipboard.m @@ -1,33 +1,34 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_cocoavideo.h" #include "../../events/SDL_clipboardevents_c.h" static NSString * GetTextFormat(_THIS) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; if (data->osversion >= 0x1060) { @@ -95,24 +96,12 @@ Cocoa_GetClipboardText(_THIS) SDL_bool Cocoa_HasClipboardText(_THIS) { - NSAutoreleasePool *pool; - NSPasteboard *pasteboard; - NSString *format = GetTextFormat(_this); - NSString *available; - SDL_bool result; - - pool = [[NSAutoreleasePool alloc] init]; - - pasteboard = [NSPasteboard generalPasteboard]; - available = [pasteboard availableTypeFromArray: [NSArray arrayWithObject:format]]; - if ([available isEqualToString:format]) { - result = SDL_TRUE; - } else { - result = SDL_FALSE; + SDL_bool result = SDL_FALSE; + char *text = Cocoa_GetClipboardText(_this); + if (text) { + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); } - - [pool release]; - return result; } @@ -137,4 +126,6 @@ Cocoa_CheckClipboardUpdate(struct SDL_VideoData * data) [pool release]; } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaevents.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaevents.h index 8950fa96e..4d7798701 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaevents.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaevents.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaevents.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaevents.m index 3c1055101..8098f5464 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaevents.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaevents.m @@ -1,25 +1,26 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_COCOA #include "SDL_timer.h" #include "SDL_cocoavideo.h" @@ -40,13 +41,6 @@ - (void)setAppleMenu:(NSMenu *)menu; @end -@implementation NSApplication(SDL) -- (void)setRunning -{ - _running = 1; -} -@end - @interface SDLAppDelegate : NSObject - (NSApplicationTerminateReply)applicationShouldTerminate:(NSApplication *)sender; @end @@ -57,6 +51,11 @@ SDL_SendQuit(); return NSTerminateCancel; } + +- (BOOL)application:(NSApplication *)theApplication openFile:(NSString *)filename +{ + return (BOOL)SDL_SendDropFile([filename UTF8String]); +} @end static NSString * @@ -98,6 +97,10 @@ CreateApplicationMenus(void) [appleMenu addItem:[NSMenuItem separatorItem]]; + [appleMenu addItemWithTitle:@"Preferences" action:nil keyEquivalent:@""]; + + [appleMenu addItem:[NSMenuItem separatorItem]]; + title = [@"Hide " stringByAppendingString:appName]; [appleMenu addItemWithTitle:title action:@selector(hide:) keyEquivalent:@/*"h"*/""]; @@ -164,7 +167,6 @@ Cocoa_RegisterApp(void) if ([NSApp delegate] == nil) { [NSApp setDelegate:[[SDLAppDelegate alloc] init]]; } - [NSApp setRunning]; [pool release]; } @@ -185,7 +187,7 @@ Cocoa_PumpEvents(_THIS) } pool = [[NSAutoreleasePool alloc] init]; - while ([NSApp isRunning]) { + for ( ; ; ) { NSEvent *event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES ]; if ( event == nil ) { break; @@ -202,6 +204,7 @@ Cocoa_PumpEvents(_THIS) case NSRightMouseDragged: case NSOtherMouseDragged: /* usually middle mouse dragged */ case NSMouseMoved: + case NSScrollWheel: Cocoa_HandleMouseEvent(_this, event); /* Pass through to NSApp to make sure everything stays in sync */ [NSApp sendEvent:event]; @@ -224,4 +227,6 @@ Cocoa_PumpEvents(_THIS) [pool release]; } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoakeyboard.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoakeyboard.h index 8adae67e5..f8f404c66 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoakeyboard.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoakeyboard.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoakeyboard.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoakeyboard.m index 0d7c400ad..c2da570db 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoakeyboard.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoakeyboard.m @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_cocoavideo.h" #include "../../events/SDL_keyboard_c.h" @@ -29,7 +30,7 @@ #include //#define DEBUG_IME NSLog -#define DEBUG_IME +#define DEBUG_IME(...) #ifndef NX_DEVICERCTLKEYMASK #define NX_DEVICELCTLKEYMASK 0x00000001 @@ -171,7 +172,7 @@ } /* Needs long instead of NSInteger for compilation on Mac OS X 10.4 */ -#if MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5 +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1050 - (long) conversationIdentifier #else - (NSInteger) conversationIdentifier @@ -246,7 +247,7 @@ static void HandleNonDeviceModifier(unsigned int device_independent_mask, unsigned int oldMods, unsigned int newMods, - SDL_scancode scancode) + SDL_Scancode scancode) { unsigned int oldMask, newMask; @@ -268,7 +269,7 @@ HandleNonDeviceModifier(unsigned int device_independent_mask, */ static void HandleModifierOneSide(unsigned int oldMods, unsigned int newMods, - SDL_scancode scancode, + SDL_Scancode scancode, unsigned int sided_device_dependent_mask) { unsigned int old_dep_mask, new_dep_mask; @@ -297,8 +298,8 @@ HandleModifierOneSide(unsigned int oldMods, unsigned int newMods, static void HandleModifierSide(int device_independent_mask, unsigned int oldMods, unsigned int newMods, - SDL_scancode left_scancode, - SDL_scancode right_scancode, + SDL_Scancode left_scancode, + SDL_Scancode right_scancode, unsigned int left_device_dependent_mask, unsigned int right_device_dependent_mask) { @@ -341,8 +342,8 @@ HandleModifierSide(int device_independent_mask, static void ReleaseModifierSide(unsigned int device_independent_mask, unsigned int oldMods, unsigned int newMods, - SDL_scancode left_scancode, - SDL_scancode right_scancode, + SDL_Scancode left_scancode, + SDL_Scancode right_scancode, unsigned int left_device_dependent_mask, unsigned int right_device_dependent_mask) { @@ -409,13 +410,13 @@ DoSidedModifiers(unsigned short scancode, unsigned int oldMods, unsigned int newMods) { /* Set up arrays for the key syms for the left and right side. */ - const SDL_scancode left_mapping[] = { + const SDL_Scancode left_mapping[] = { SDL_SCANCODE_LSHIFT, SDL_SCANCODE_LCTRL, SDL_SCANCODE_LALT, SDL_SCANCODE_LGUI }; - const SDL_scancode right_mapping[] = { + const SDL_Scancode right_mapping[] = { SDL_SCANCODE_RSHIFT, SDL_SCANCODE_RCTRL, SDL_SCANCODE_RALT, @@ -482,18 +483,18 @@ HandleModifiers(_THIS, unsigned short scancode, unsigned int modifierFlags) static void UpdateKeymap(SDL_VideoData *data) { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 TISInputSourceRef key_layout; #else KeyboardLayoutRef key_layout; #endif const void *chr_data; int i; - SDL_scancode scancode; - SDLKey keymap[SDL_NUM_SCANCODES]; + SDL_Scancode scancode; + SDL_Keycode keymap[SDL_NUM_SCANCODES]; /* See if the keymap needs to be updated */ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 key_layout = TISCopyCurrentKeyboardLayoutInputSource(); #else KLGetCurrentKeyboardLayout(&key_layout); @@ -506,7 +507,7 @@ UpdateKeymap(SDL_VideoData *data) SDL_GetDefaultKeymap(keymap); /* Try Unicode data first (preferred as of Mac OS X 10.5) */ -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 CFDataRef uchrDataRef = TISGetInputSourceProperty(key_layout, kTISPropertyUnicodeKeyLayoutData); if (uchrDataRef) chr_data = CFDataGetBytePtr(uchrDataRef); @@ -548,7 +549,7 @@ UpdateKeymap(SDL_VideoData *data) return; } -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050 cleanup: CFRelease(key_layout); #else @@ -675,7 +676,7 @@ Cocoa_HandleKeyEvent(_THIS, NSEvent *event) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; unsigned short scancode = [event keyCode]; - SDL_scancode code; + SDL_Scancode code; #if 0 const char *text; #endif @@ -734,4 +735,6 @@ Cocoa_QuitKeyboard(_THIS) { } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamodes.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamodes.h index ae6922707..b60a36ba1 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamodes.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamodes.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -31,7 +30,7 @@ typedef struct typedef struct { - CFDictionaryRef moderef; + const void *moderef; } SDL_DisplayModeData; extern void Cocoa_InitModes(_THIS); diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamodes.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamodes.m index be9a8bbc6..76e6d2d63 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamodes.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamodes.m @@ -1,29 +1,38 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_cocoavideo.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 +/* !!! FIXME: clean out the pre-10.6 code when it makes sense to do so. */ +#define FORCE_OLD_API 0 || (MAC_OS_X_VERSION_MAX_ALLOWED < 1060) + +#if FORCE_OLD_API +#undef MAC_OS_X_VERSION_MIN_REQUIRED +#define MAC_OS_X_VERSION_MIN_REQUIRED 1050 +#endif + +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 /* Add methods to get at private members of NSScreen. Since there is a bug in Apple's screen switching code @@ -43,6 +52,16 @@ @end #endif +static inline BOOL +IS_SNOW_LEOPARD_OR_LATER(_THIS) +{ +#if FORCE_OLD_API + return NO; +#else + return ((((SDL_VideoData *) _this->driverdata))->osversion >= 0x1060); +#endif +} + static void CG_SetError(const char *prefix, CGDisplayErr result) { @@ -93,11 +112,13 @@ CG_SetError(const char *prefix, CGDisplayErr result) } static SDL_bool -GetDisplayMode(CFDictionaryRef moderef, SDL_DisplayMode *mode) +GetDisplayMode(_THIS, const void *moderef, SDL_DisplayMode *mode) { SDL_DisplayModeData *data; - CFNumberRef number; - long width, height, bpp, refreshRate; + long width = 0; + long height = 0; + long bpp = 0; + long refreshRate = 0; data = (SDL_DisplayModeData *) SDL_malloc(sizeof(*data)); if (!data) { @@ -105,26 +126,54 @@ GetDisplayMode(CFDictionaryRef moderef, SDL_DisplayMode *mode) } data->moderef = moderef; - number = CFDictionaryGetValue(moderef, kCGDisplayWidth); - CFNumberGetValue(number, kCFNumberLongType, &width); - number = CFDictionaryGetValue(moderef, kCGDisplayHeight); - CFNumberGetValue(number, kCFNumberLongType, &height); - number = CFDictionaryGetValue(moderef, kCGDisplayBitsPerPixel); - CFNumberGetValue(number, kCFNumberLongType, &bpp); - number = CFDictionaryGetValue(moderef, kCGDisplayRefreshRate); - CFNumberGetValue(number, kCFNumberLongType, &refreshRate); + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + if (IS_SNOW_LEOPARD_OR_LATER(_this)) { + CGDisplayModeRef vidmode = (CGDisplayModeRef) moderef; + CFStringRef fmt = CGDisplayModeCopyPixelEncoding(vidmode); + width = (long) CGDisplayModeGetWidth(vidmode); + height = (long) CGDisplayModeGetHeight(vidmode); + refreshRate = (long) CGDisplayModeGetRefreshRate(vidmode); + + if (CFStringCompare(fmt, CFSTR(IO32BitDirectPixels), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + bpp = 32; + } else if (CFStringCompare(fmt, CFSTR(IO16BitDirectPixels), + kCFCompareCaseInsensitive) == kCFCompareEqualTo) { + bpp = 16; + } else { + bpp = 0; /* ignore 8-bit and such for now. */ + } + + CFRelease(fmt); + } + #endif + + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { + CFNumberRef number; + CFDictionaryRef vidmode = (CFDictionaryRef) moderef; + number = CFDictionaryGetValue(vidmode, kCGDisplayWidth); + CFNumberGetValue(number, kCFNumberLongType, &width); + number = CFDictionaryGetValue(vidmode, kCGDisplayHeight); + CFNumberGetValue(number, kCFNumberLongType, &height); + number = CFDictionaryGetValue(vidmode, kCGDisplayBitsPerPixel); + CFNumberGetValue(number, kCFNumberLongType, &bpp); + number = CFDictionaryGetValue(vidmode, kCGDisplayRefreshRate); + CFNumberGetValue(number, kCFNumberLongType, &refreshRate); + } + #endif mode->format = SDL_PIXELFORMAT_UNKNOWN; switch (bpp) { - case 8: - mode->format = SDL_PIXELFORMAT_INDEX8; - break; case 16: mode->format = SDL_PIXELFORMAT_ARGB1555; break; case 32: mode->format = SDL_PIXELFORMAT_ARGB8888; break; + case 8: /* We don't support palettized modes now */ + default: /* Totally unrecognizable bit depth. */ + return SDL_FALSE; } mode->w = width; mode->h = height; @@ -133,6 +182,28 @@ GetDisplayMode(CFDictionaryRef moderef, SDL_DisplayMode *mode) return SDL_TRUE; } +static inline void +Cocoa_ReleaseDisplayMode(_THIS, const void *moderef) +{ + /* We don't own moderef unless we use the 10.6+ APIs. */ + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + if (IS_SNOW_LEOPARD_OR_LATER(_this)) { + CGDisplayModeRelease((CGDisplayModeRef) moderef); /* NULL is ok */ + } + #endif +} + +static inline void +Cocoa_ReleaseDisplayModeList(_THIS, CFArrayRef modelist) +{ + /* We don't own modelis unless we use the 10.6+ APIs. */ + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + if (IS_SNOW_LEOPARD_OR_LATER(_this)) { + CFRelease(modelist); /* NULL is ok */ + } + #endif +} + void Cocoa_InitModes(_THIS) { @@ -160,7 +231,7 @@ Cocoa_InitModes(_THIS) SDL_VideoDisplay display; SDL_DisplayData *displaydata; SDL_DisplayMode mode; - CFDictionaryRef moderef; + const void *moderef = NULL; if (pass == 0) { if (!CGDisplayIsMain(displays[i])) { @@ -175,22 +246,37 @@ Cocoa_InitModes(_THIS) if (CGDisplayMirrorsDisplay(displays[i]) != kCGNullDirectDisplay) { continue; } - moderef = CGDisplayCurrentMode(displays[i]); + + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + if (IS_SNOW_LEOPARD_OR_LATER(_this)) { + moderef = CGDisplayCopyDisplayMode(displays[i]); + } + #endif + + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { + moderef = CGDisplayCurrentMode(displays[i]); + } + #endif + if (!moderef) { continue; } displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata)); if (!displaydata) { + Cocoa_ReleaseDisplayMode(_this, moderef); continue; } displaydata->display = displays[i]; SDL_zero(display); - if (!GetDisplayMode (moderef, &mode)) { + if (!GetDisplayMode (_this, moderef, &mode)) { + Cocoa_ReleaseDisplayMode(_this, moderef); SDL_free(displaydata); continue; } + display.desktop_mode = mode; display.current_mode = mode; display.driverdata = displaydata; @@ -214,31 +300,61 @@ Cocoa_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) return 0; } -static void -AddDisplayMode(const void *moderef, void *context) -{ - SDL_VideoDisplay *display = (SDL_VideoDisplay *) context; - SDL_DisplayMode mode; - - if (GetDisplayMode(moderef, &mode)) { - SDL_AddDisplayMode(display, &mode); - } -} - void Cocoa_GetDisplayModes(_THIS, SDL_VideoDisplay * display) { SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; - CFArrayRef modes; - CFRange range; + CFArrayRef modes = NULL; - modes = CGDisplayAvailableModes(data->display); - if (!modes) { - return; + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + if (IS_SNOW_LEOPARD_OR_LATER(_this)) { + modes = CGDisplayCopyAllDisplayModes(data->display, NULL); } - range.location = 0; - range.length = CFArrayGetCount(modes); - CFArrayApplyFunction(modes, range, AddDisplayMode, display); + #endif + + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { + modes = CGDisplayAvailableModes(data->display); + } + #endif + + if (modes) { + const CFIndex count = CFArrayGetCount(modes); + CFIndex i; + + for (i = 0; i < count; i++) { + const void *moderef = CFArrayGetValueAtIndex(modes, i); + SDL_DisplayMode mode; + if (GetDisplayMode(_this, moderef, &mode)) { + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + if (IS_SNOW_LEOPARD_OR_LATER(_this)) { + CGDisplayModeRetain((CGDisplayModeRef) moderef); + } + #endif + SDL_AddDisplayMode(display, &mode); + } + } + + Cocoa_ReleaseDisplayModeList(_this, modes); + } +} + +static CGError +Cocoa_SwitchMode(_THIS, CGDirectDisplayID display, const void *mode) +{ + #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + if (IS_SNOW_LEOPARD_OR_LATER(_this)) { + return CGDisplaySetDisplayMode(display, (CGDisplayModeRef) mode, NULL); + } + #endif + + #if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + if (!IS_SNOW_LEOPARD_OR_LATER(_this)) { + return CGDisplaySwitchToMode(display, (CFDictionaryRef) mode); + } + #endif + + return kCGErrorFailure; } int @@ -256,23 +372,32 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) if (data == display->desktop_mode.driverdata) { /* Restoring desktop mode */ - CGDisplaySwitchToMode(displaydata->display, data->moderef); + Cocoa_SwitchMode(_this, displaydata->display, data->moderef); - CGDisplayRelease(displaydata->display); + if (CGDisplayIsMain(displaydata->display)) { + CGReleaseAllDisplays(); + } else { + CGDisplayRelease(displaydata->display); + } if (CGDisplayIsMain(displaydata->display)) { ShowMenuBar(); } } else { /* Put up the blanking window (a window above all other windows) */ - result = CGDisplayCapture(displaydata->display); + if (CGDisplayIsMain(displaydata->display)) { + /* If we don't capture all displays, Cocoa tries to rearrange windows... *sigh* */ + result = CGCaptureAllDisplays(); + } else { + result = CGDisplayCapture(displaydata->display); + } if (result != kCGErrorSuccess) { CG_SetError("CGDisplayCapture()", result); goto ERR_NO_CAPTURE; } /* Do the physical switch */ - result = CGDisplaySwitchToMode(displaydata->display, data->moderef); + result = Cocoa_SwitchMode(_this, displaydata->display, data->moderef); if (result != kCGErrorSuccess) { CG_SetError("CGDisplaySwitchToMode()", result); goto ERR_NO_SWITCH; @@ -290,19 +415,6 @@ Cocoa_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) CGReleaseDisplayFadeReservation(fade_token); } - [[NSApp mainWindow] makeKeyAndOrderFront: nil]; - -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 - /* - There is a bug in Cocoa where NSScreen doesn't synchronize - with CGDirectDisplay, so the main screen's frame is wrong. - As a result, coordinate translation produces incorrect results. - We can hack around this bug by setting the screen rect - ourselves. This hack should be removed if/when the bug is fixed. - */ - [[NSScreen mainScreen] setFrame:NSMakeRect(0,0,mode->w,mode->h)]; -#endif - return 0; /* Since the blanking window covers *all* windows (even force quit) correct recovery is crucial */ @@ -319,16 +431,28 @@ ERR_NO_CAPTURE: void Cocoa_QuitModes(_THIS) { - int i; + int i, j; for (i = 0; i < _this->num_displays; ++i) { SDL_VideoDisplay *display = &_this->displays[i]; + SDL_DisplayModeData *mode; if (display->current_mode.driverdata != display->desktop_mode.driverdata) { Cocoa_SetDisplayMode(_this, display, &display->desktop_mode); } + + mode = (SDL_DisplayModeData *) display->desktop_mode.driverdata; + Cocoa_ReleaseDisplayMode(_this, mode->moderef); + + for (j = 0; j < display->num_display_modes; j++) { + mode = (SDL_DisplayModeData*) display->display_modes[j].driverdata; + Cocoa_ReleaseDisplayMode(_this, mode->moderef); + } + } ShowMenuBar(); } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamouse.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamouse.h index 41675323e..4d6c17b9f 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamouse.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamouse.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -26,6 +25,7 @@ extern void Cocoa_InitMouse(_THIS); extern void Cocoa_HandleMouseEvent(_THIS, NSEvent * event); +extern void Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent * event); extern void Cocoa_QuitMouse(_THIS); #endif /* _SDL_cocoamouse_h */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamouse.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamouse.m index c0ac2feaf..024639c71 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamouse.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoamouse.m @@ -1,107 +1,187 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_events.h" #include "SDL_cocoavideo.h" #include "../../events/SDL_mouse_c.h" -void -Cocoa_InitMouse(_THIS) + +static SDL_Cursor * +Cocoa_CreateDefaultCursor() { + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSCursor *nscursor; + SDL_Cursor *cursor = NULL; + + nscursor = [NSCursor arrowCursor]; + + if (nscursor) { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + cursor->driverdata = nscursor; + [nscursor retain]; + } + } + + [pool release]; + + return cursor; +} + +static SDL_Cursor * +Cocoa_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSImage *nsimage; + NSCursor *nscursor = NULL; + SDL_Cursor *cursor = NULL; + + nsimage = Cocoa_CreateImage(surface); + if (nsimage) { + nscursor = [[NSCursor alloc] initWithImage: nsimage hotSpot: NSMakePoint(hot_x, hot_y)]; + } + + if (nscursor) { + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + cursor->driverdata = nscursor; + } + } + + [pool release]; + + return cursor; +} + +static void +Cocoa_FreeCursor(SDL_Cursor * cursor) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSCursor *nscursor = (NSCursor *)cursor->driverdata; + + [nscursor release]; + SDL_free(cursor); + + [pool release]; } static int -ConvertMouseButtonToSDL(int button) +Cocoa_ShowCursor(SDL_Cursor * cursor) { - switch (button) - { - case 0: - return(SDL_BUTTON_LEFT); /* 1 */ - case 1: - return(SDL_BUTTON_RIGHT); /* 3 */ - case 2: - return(SDL_BUTTON_MIDDLE); /* 2 */ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + if (SDL_GetMouseFocus()) { + if (cursor) { + NSCursor *nscursor = (NSCursor *)cursor->driverdata; + + [nscursor set]; + [NSCursor unhide]; + } else { + [NSCursor hide]; + } } - return button; + + [pool release]; + + return 0; +} + +static void +Cocoa_WarpMouse(SDL_Window * window, int x, int y) +{ + CGPoint point; + + point.x = (float)window->x + x; + point.y = (float)window->y + y; + CGWarpMouseCursorPosition(point); +} + +static int +Cocoa_SetRelativeMouseMode(SDL_bool enabled) +{ + CGError result; + + if (enabled) { + result = CGAssociateMouseAndMouseCursorPosition(NO); + } else { + result = CGAssociateMouseAndMouseCursorPosition(YES); + } + if (result != kCGErrorSuccess) { + SDL_SetError("CGAssociateMouseAndMouseCursorPosition() failed"); + return -1; + } + return 0; +} + +void +Cocoa_InitMouse(_THIS) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = Cocoa_CreateCursor; + mouse->ShowCursor = Cocoa_ShowCursor; + mouse->FreeCursor = Cocoa_FreeCursor; + mouse->WarpMouse = Cocoa_WarpMouse; + mouse->SetRelativeMouseMode = Cocoa_SetRelativeMouseMode; + + SDL_SetDefaultCursor(Cocoa_CreateDefaultCursor()); } void Cocoa_HandleMouseEvent(_THIS, NSEvent *event) { - int i; - NSPoint point = { 0, 0 }; - SDL_Window *window; - SDL_Window *focus = SDL_GetMouseFocus(); + SDL_Mouse *mouse = SDL_GetMouse(); - /* See if there are any fullscreen windows that might handle this event */ - window = NULL; - for (i = 0; i < _this->num_displays; ++i) { - SDL_VideoDisplay *display = &_this->displays[i]; - SDL_Window *candidate = display->fullscreen_window; - - if (candidate) { - SDL_Rect bounds; - - Cocoa_GetDisplayBounds(_this, display, &bounds); - point = [NSEvent mouseLocation]; - point.x = point.x - bounds.x; - point.y = CGDisplayPixelsHigh(kCGDirectMainDisplay) - point.y - bounds.y; - if ((point.x >= 0 && point.x < candidate->w) && - (point.y >= 0 && point.y < candidate->h)) { - /* This is it! */ - window = candidate; - break; - } else if (candidate == focus) { - SDL_SetMouseFocus(NULL); - } - } + if (mouse->relative_mode && + ([event type] == NSMouseMoved || + [event type] == NSLeftMouseDragged || + [event type] == NSRightMouseDragged || + [event type] == NSOtherMouseDragged)) { + float x = [event deltaX]; + float y = [event deltaY]; + SDL_SendMouseMotion(mouse->focus, 1, (int)x, (int)y); } +} - if (!window) { - return; - } +void +Cocoa_HandleMouseWheel(SDL_Window *window, NSEvent *event) +{ + float x = [event deltaX]; + float y = [event deltaY]; - switch ([event type]) { - case NSLeftMouseDown: - case NSOtherMouseDown: - case NSRightMouseDown: - SDL_SendMouseButton(window, SDL_PRESSED, ConvertMouseButtonToSDL([event buttonNumber])); - break; - case NSLeftMouseUp: - case NSOtherMouseUp: - case NSRightMouseUp: - SDL_SendMouseButton(window, SDL_RELEASED, ConvertMouseButtonToSDL([event buttonNumber])); - break; - case NSLeftMouseDragged: - case NSRightMouseDragged: - case NSOtherMouseDragged: /* usually middle mouse dragged */ - case NSMouseMoved: - SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y); - break; - default: /* just to avoid compiler warnings */ - break; + if (x > 0) { + x += 0.9f; + } else if (x < 0) { + x -= 0.9f; } + if (y > 0) { + y += 0.9f; + } else if (y < 0) { + y -= 0.9f; + } + SDL_SendMouseWheel(window, (int)x, (int)y); } void @@ -109,4 +189,6 @@ Cocoa_QuitMouse(_THIS) { } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaopengl.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaopengl.h index fc01329fa..bed4a437a 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaopengl.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaopengl.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -26,6 +25,9 @@ #if SDL_VIDEO_OPENGL_CGL +/* Define this if you want to be able to toggle fullscreen mode seamlessly */ +#define FULLSCREEN_TOGGLEABLE + struct SDL_GLDriverData { int initialized; diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaopengl.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaopengl.m index c2f6b44f1..378ab3c9a 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaopengl.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoaopengl.m @@ -1,31 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_cocoavideo.h" - /* NSOpenGL implementation of SDL OpenGL support */ #if SDL_VIDEO_OPENGL_CGL +#include "SDL_cocoavideo.h" + #include #include #include @@ -72,7 +71,7 @@ SDL_GLContext Cocoa_GL_CreateContext(_THIS, SDL_Window * window) { NSAutoreleasePool *pool; - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DisplayData *displaydata = (SDL_DisplayData *)display->driverdata; NSOpenGLPixelFormatAttribute attr[32]; NSOpenGLPixelFormat *fmt; @@ -81,9 +80,11 @@ Cocoa_GL_CreateContext(_THIS, SDL_Window * window) pool = [[NSAutoreleasePool alloc] init]; +#ifndef FULLSCREEN_TOGGLEABLE if (window->flags & SDL_WINDOW_FULLSCREEN) { attr[i++] = NSOpenGLPFAFullScreen; } +#endif attr[i++] = NSOpenGLPFAColorSize; attr[i++] = SDL_BYTESPERPIXEL(display->current_mode.format)*8; @@ -199,9 +200,12 @@ Cocoa_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) SDL_WindowData *windowdata = (SDL_WindowData *)window->driverdata; NSOpenGLContext *nscontext = (NSOpenGLContext *)context; +#ifndef FULLSCREEN_TOGGLEABLE if (window->flags & SDL_WINDOW_FULLSCREEN) { [nscontext setFullScreen]; - } else { + } else +#endif + { [nscontext setView:[windowdata->nswindow contentView]]; [nscontext update]; } diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoashape.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoashape.h index bfc608633..ae9bc35a9 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoashape.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoashape.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoashape.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoashape.m index 4ee560183..542a82899 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoashape.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoashape.m @@ -1,25 +1,28 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_cocoavideo.h" #include "SDL_shape.h" #include "SDL_cocoashape.h" @@ -29,7 +32,7 @@ SDL_WindowShaper* Cocoa_CreateShaper(SDL_Window* window) { SDL_WindowData* windata = (SDL_WindowData*)window->driverdata; [windata->nswindow setOpaque:NO]; -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 [windata->nswindow setStyleMask:NSBorderlessWindowMask]; #endif SDL_WindowShaper* result = result = malloc(sizeof(SDL_WindowShaper)); @@ -90,6 +93,8 @@ Cocoa_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShape closure.window = shaper->window; SDL_TraverseShapeTree(data->shape,&ConvertRects,&closure); [closure.path addClip]; + + return 0; } int @@ -98,3 +103,7 @@ Cocoa_ResizeWindowShape(SDL_Window *window) { assert(data != NULL); return 0; } + +#endif /* SDL_VIDEO_DRIVER_COCOA */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoavideo.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoavideo.h index 6344f8b08..d9389cf41 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoavideo.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoavideo.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -29,7 +28,7 @@ #include #include -#include "SDL_keysym.h" +#include "SDL_keycode.h" #include "../SDL_sysvideo.h" #include "SDL_cocoaclipboard.h" @@ -40,7 +39,7 @@ #include "SDL_cocoaopengl.h" #include "SDL_cocoawindow.h" -#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_5 +#if MAC_OS_X_VERSION_MAX_ALLOWED < 1050 #if __LP64__ typedef long NSInteger; typedef unsigned long NSUInteger; @@ -64,6 +63,9 @@ typedef struct SDL_VideoData Uint32 screensaver_activity; } SDL_VideoData; +/* Utility functions */ +extern NSImage * Cocoa_CreateImage(SDL_Surface * surface); + #endif /* _SDL_cocoavideo_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoavideo.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoavideo.m index f1bb64f2d..886b2bebc 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoavideo.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoavideo.m @@ -1,26 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + +#include "SDL.h" +#include "SDL_endian.h" #include "SDL_cocoavideo.h" #include "SDL_cocoashape.h" #include "SDL_assert.h" @@ -82,6 +85,7 @@ Cocoa_CreateDevice(int devindex) device->CreateWindow = Cocoa_CreateWindow; device->CreateWindowFrom = Cocoa_CreateWindowFrom; device->SetWindowTitle = Cocoa_SetWindowTitle; + device->SetWindowIcon = Cocoa_SetWindowIcon; device->SetWindowPosition = Cocoa_SetWindowPosition; device->SetWindowSize = Cocoa_SetWindowSize; device->ShowWindow = Cocoa_ShowWindow; @@ -90,6 +94,9 @@ Cocoa_CreateDevice(int devindex) device->MaximizeWindow = Cocoa_MaximizeWindow; device->MinimizeWindow = Cocoa_MinimizeWindow; device->RestoreWindow = Cocoa_RestoreWindow; + device->SetWindowFullscreen = Cocoa_SetWindowFullscreen; + device->SetWindowGammaRamp = Cocoa_SetWindowGammaRamp; + device->GetWindowGammaRamp = Cocoa_GetWindowGammaRamp; device->SetWindowGrab = Cocoa_SetWindowGrab; device->DestroyWindow = Cocoa_DestroyWindow; device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; @@ -98,7 +105,7 @@ Cocoa_CreateDevice(int devindex) device->shape_driver.SetWindowShape = Cocoa_SetWindowShape; device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape; -#ifdef SDL_VIDEO_OPENGL_CGL +#if SDL_VIDEO_OPENGL_CGL device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; device->GL_GetProcAddress = Cocoa_GL_GetProcAddress; device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary; @@ -146,6 +153,62 @@ Cocoa_VideoQuit(_THIS) Cocoa_QuitMouse(_this); } +/* This function assumes that it's called from within an autorelease pool */ +NSImage * +Cocoa_CreateImage(SDL_Surface * surface) +{ + SDL_Surface *converted; + NSBitmapImageRep *imgrep; + Uint8 *pixels; + int i; + NSImage *img; + + converted = SDL_ConvertSurfaceFormat(surface, +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + SDL_PIXELFORMAT_RGBA8888, +#else + SDL_PIXELFORMAT_ABGR8888, +#endif + 0); + if (!converted) { + return nil; + } + + imgrep = [[[NSBitmapImageRep alloc] initWithBitmapDataPlanes: NULL + pixelsWide: converted->w + pixelsHigh: converted->h + bitsPerSample: 8 + samplesPerPixel: 4 + hasAlpha: YES + isPlanar: NO + colorSpaceName: NSDeviceRGBColorSpace + bytesPerRow: converted->pitch + bitsPerPixel: converted->format->BitsPerPixel] autorelease]; + if (imgrep == nil) { + SDL_FreeSurface(converted); + return nil; + } + + /* Copy the pixels */ + pixels = [imgrep bitmapData]; + SDL_memcpy(pixels, converted->pixels, converted->h * converted->pitch); + SDL_FreeSurface(converted); + + /* Premultiply the alpha channel */ + for (i = (surface->h * surface->w); i--; ) { + Uint8 alpha = pixels[3]; + pixels[0] = (Uint8)(((Uint16)pixels[0] * alpha) / 255); + pixels[1] = (Uint8)(((Uint16)pixels[1] * alpha) / 255); + pixels[2] = (Uint8)(((Uint16)pixels[2] * alpha) / 255); + pixels += 4; + } + + img = [[[NSImage alloc] initWithSize: NSMakeSize(surface->w, surface->h)] autorelease]; + if (img != nil) { + [img addRepresentation: imgrep]; + } + return img; +} /* * Mac OS X assertion support. @@ -157,6 +220,14 @@ Cocoa_VideoQuit(_THIS) SDL_assert_state SDL_PromptAssertion_cocoa(const SDL_assert_data *data) { + const int initialized = (SDL_WasInit(SDL_INIT_VIDEO) != 0); + if (!initialized) { + if (SDL_InitSubSystem(SDL_INIT_VIDEO) == -1) { + fprintf(stderr, "Assertion failed AND couldn't init video mode!\n"); + return SDL_ASSERTION_BREAK; /* oh well, crash hard. */ + } + } + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSString *msg = [NSString stringWithFormat: @@ -165,7 +236,7 @@ SDL_PromptAssertion_cocoa(const SDL_assert_data *data) data->trigger_count, (data->trigger_count == 1) ? "" : "s", data->condition]; - NSLog(@"%s", msg); + NSLog(@"%@", msg); /* * !!! FIXME: this code needs to deal with fullscreen modes: @@ -182,7 +253,14 @@ SDL_PromptAssertion_cocoa(const SDL_assert_data *data) [alert addButtonWithTitle:@"Always Ignore"]; const NSInteger clicked = [alert runModal]; [pool release]; + + if (!initialized) { + SDL_QuitSubSystem(SDL_INIT_VIDEO); + } + return (SDL_assert_state) (clicked - NSAlertFirstButtonReturn); } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vim: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoawindow.h b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoawindow.h index 0744f983f..d0e634eb2 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoawindow.h +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoawindow.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -29,11 +28,11 @@ typedef struct SDL_WindowData SDL_WindowData; /* *INDENT-OFF* */ -#if MAC_OS_X_VERSION_MIN_REQUIRED >= MAC_OS_X_VERSION_10_6 +#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060 @interface Cocoa_WindowListener : NSResponder { #else @interface Cocoa_WindowListener : NSResponder { -#endif +#endif SDL_WindowData *_data; } @@ -49,8 +48,6 @@ typedef struct SDL_WindowData SDL_WindowData; -(void) windowDidDeminiaturize:(NSNotification *) aNotification; -(void) windowDidBecomeKey:(NSNotification *) aNotification; -(void) windowDidResignKey:(NSNotification *) aNotification; --(void) windowDidHide:(NSNotification *) aNotification; --(void) windowDidUnhide:(NSNotification *) aNotification; /* Window event handling */ -(void) mouseDown:(NSEvent *) theEvent; @@ -59,6 +56,8 @@ typedef struct SDL_WindowData SDL_WindowData; -(void) mouseUp:(NSEvent *) theEvent; -(void) rightMouseUp:(NSEvent *) theEvent; -(void) otherMouseUp:(NSEvent *) theEvent; +-(void) mouseEntered:(NSEvent *)theEvent; +-(void) mouseExited:(NSEvent *)theEvent; -(void) mouseMoved:(NSEvent *) theEvent; -(void) mouseDragged:(NSEvent *) theEvent; -(void) rightMouseDragged:(NSEvent *) theEvent; @@ -86,7 +85,6 @@ struct SDL_WindowData SDL_Window *window; NSWindow *nswindow; SDL_bool created; - CGDirectDisplayID display; Cocoa_WindowListener *listener; struct SDL_VideoData *videodata; }; @@ -95,6 +93,7 @@ extern int Cocoa_CreateWindow(_THIS, SDL_Window * window); extern int Cocoa_CreateWindowFrom(_THIS, SDL_Window * window, const void *data); extern void Cocoa_SetWindowTitle(_THIS, SDL_Window * window); +extern void Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon); extern void Cocoa_SetWindowPosition(_THIS, SDL_Window * window); extern void Cocoa_SetWindowSize(_THIS, SDL_Window * window); extern void Cocoa_ShowWindow(_THIS, SDL_Window * window); @@ -103,6 +102,9 @@ extern void Cocoa_RaiseWindow(_THIS, SDL_Window * window); extern void Cocoa_MaximizeWindow(_THIS, SDL_Window * window); extern void Cocoa_MinimizeWindow(_THIS, SDL_Window * window); extern void Cocoa_RestoreWindow(_THIS, SDL_Window * window); +extern void Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); +extern int Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); +extern int Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); extern void Cocoa_SetWindowGrab(_THIS, SDL_Window * window); extern void Cocoa_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, diff --git a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoawindow.m b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoawindow.m index 68c0cbe48..f8956e087 100644 --- a/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoawindow.m +++ b/project/jni/sdl-1.3/src/video/cocoa/SDL_cocoawindow.m @@ -1,27 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_COCOA + #include "SDL_syswm.h" +#include "SDL_timer.h" /* For SDL_GetTicks() */ #include "../SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_mouse_c.h" @@ -29,6 +31,10 @@ #include "../../events/SDL_windowevents_c.h" #include "SDL_cocoavideo.h" #include "SDL_cocoashape.h" +#include "SDL_cocoamouse.h" + + +static Uint32 s_moveHack; static __inline__ void ConvertNSRect(NSRect *r) { @@ -40,54 +46,60 @@ static __inline__ void ConvertNSRect(NSRect *r) - (void)listen:(SDL_WindowData *)data { NSNotificationCenter *center; + NSWindow *window = data->nswindow; + NSView *view = [window contentView]; _data = data; center = [NSNotificationCenter defaultCenter]; - [_data->nswindow setNextResponder:self]; - if ([_data->nswindow delegate] != nil) { - [center addObserver:self selector:@selector(windowDisExpose:) name:NSWindowDidExposeNotification object:_data->nswindow]; - [center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:_data->nswindow]; - [center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:_data->nswindow]; - [center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:_data->nswindow]; - [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:_data->nswindow]; - [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:_data->nswindow]; - [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:_data->nswindow]; + if ([window delegate] != nil) { + [center addObserver:self selector:@selector(windowDidExpose:) name:NSWindowDidExposeNotification object:window]; + [center addObserver:self selector:@selector(windowDidMove:) name:NSWindowDidMoveNotification object:window]; + [center addObserver:self selector:@selector(windowDidResize:) name:NSWindowDidResizeNotification object:window]; + [center addObserver:self selector:@selector(windowDidMiniaturize:) name:NSWindowDidMiniaturizeNotification object:window]; + [center addObserver:self selector:@selector(windowDidDeminiaturize:) name:NSWindowDidDeminiaturizeNotification object:window]; + [center addObserver:self selector:@selector(windowDidBecomeKey:) name:NSWindowDidBecomeKeyNotification object:window]; + [center addObserver:self selector:@selector(windowDidResignKey:) name:NSWindowDidResignKeyNotification object:window]; } else { - [_data->nswindow setDelegate:self]; + [window setDelegate:self]; } -// FIXME: Why doesn't this work? -// [center addObserver:self selector:@selector(rightMouseDown:) name:[NSString stringWithCString:"rightMouseDown" encoding:NSUTF8StringEncoding] object:[_data->nswindow contentView]]; - [center addObserver:self selector:@selector(windowDidHide:) name:NSApplicationDidHideNotification object:NSApp]; - [center addObserver:self selector:@selector(windowDidUnhide:) name:NSApplicationDidUnhideNotification object:NSApp]; - [_data->nswindow setAcceptsMouseMovedEvents:YES]; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 - [[_data->nswindow contentView] setAcceptsTouchEvents:YES]; + [window setNextResponder:self]; + [window setAcceptsMouseMovedEvents:YES]; + + [view setNextResponder:self]; +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 + [view setAcceptsTouchEvents:YES]; #endif } - (void)close { NSNotificationCenter *center; + NSWindow *window = _data->nswindow; + NSView *view = [window contentView]; center = [NSNotificationCenter defaultCenter]; - [_data->nswindow setNextResponder:nil]; - if ([_data->nswindow delegate] != self) { - [center removeObserver:self name:NSWindowDidExposeNotification object:_data->nswindow]; - [center removeObserver:self name:NSWindowDidMoveNotification object:_data->nswindow]; - [center removeObserver:self name:NSWindowDidResizeNotification object:_data->nswindow]; - [center removeObserver:self name:NSWindowDidMiniaturizeNotification object:_data->nswindow]; - [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:_data->nswindow]; - [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:_data->nswindow]; - [center removeObserver:self name:NSWindowDidResignKeyNotification object:_data->nswindow]; + if ([window delegate] != self) { + [center removeObserver:self name:NSWindowDidExposeNotification object:window]; + [center removeObserver:self name:NSWindowDidMoveNotification object:window]; + [center removeObserver:self name:NSWindowDidResizeNotification object:window]; + [center removeObserver:self name:NSWindowDidMiniaturizeNotification object:window]; + [center removeObserver:self name:NSWindowDidDeminiaturizeNotification object:window]; + [center removeObserver:self name:NSWindowDidBecomeKeyNotification object:window]; + [center removeObserver:self name:NSWindowDidResignKeyNotification object:window]; } else { - [_data->nswindow setDelegate:nil]; + [window setDelegate:nil]; + } + + if ([window nextResponder] == self) { + [window setNextResponder:nil]; + } + if ([view nextResponder] == self) { + [view setNextResponder:nil]; } - [center removeObserver:self name:NSApplicationDidHideNotification object:NSApp]; - [center removeObserver:self name:NSApplicationDidUnhideNotification object:NSApp]; } - (BOOL)windowShouldClose:(id)sender @@ -104,21 +116,51 @@ static __inline__ void ConvertNSRect(NSRect *r) - (void)windowDidMove:(NSNotification *)aNotification { int x, y; - NSRect rect = [_data->nswindow contentRectForFrameRect:[_data->nswindow frame]]; + SDL_VideoDevice *device = SDL_GetVideoDevice(); + SDL_Window *window = _data->window; + NSWindow *nswindow = _data->nswindow; + NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; ConvertNSRect(&rect); + + if (s_moveHack) { + SDL_bool blockMove = ((SDL_GetTicks() - s_moveHack) < 500); + + s_moveHack = 0; + + if (blockMove) { + /* Cocoa is adjusting the window in response to a mode change */ + rect.origin.x = window->x; + rect.origin.y = window->y; + ConvertNSRect(&rect); + [nswindow setFrameOrigin:rect.origin]; + return; + } + } + x = (int)rect.origin.x; y = (int)rect.origin.y; - SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_MOVED, x, y); + + if (window == device->current_glwin) { + [((NSOpenGLContext *) device->current_glctx) update]; + } + + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MOVED, x, y); } - (void)windowDidResize:(NSNotification *)aNotification { + SDL_VideoDevice *device = SDL_GetVideoDevice(); int w, h; NSRect rect = [_data->nswindow contentRectForFrameRect:[_data->nswindow frame]]; w = (int)rect.size.width; h = (int)rect.size.height; if (SDL_IsShapedWindow(_data->window)) Cocoa_ResizeWindowShape(_data->window); + + if (_data->window == device->current_glwin) { + [((NSOpenGLContext *) device->current_glctx) update]; + } + SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_RESIZED, w, h); } @@ -134,8 +176,27 @@ static __inline__ void ConvertNSRect(NSRect *r) - (void)windowDidBecomeKey:(NSNotification *)aNotification { + SDL_Window *window = _data->window; + /* We're going to get keyboard events, since we're key. */ - SDL_SetKeyboardFocus(_data->window); + SDL_SetKeyboardFocus(window); + + /* If we just gained focus we need the updated mouse position */ + { + NSPoint point; + int x, y; + + point = [_data->nswindow mouseLocationOutsideOfEventStream]; + x = (int)point.x; + y = (int)(window->h - point.y); + + if (x >= 0 && x < window->w && y >= 0 && y < window->h) { + if (SDL_GetMouseFocus() != window) { + [self mouseEntered:nil]; + } + SDL_SendMouseMotion(window, 0, x, y); + } + } /* Check to see if someone updated the clipboard */ Cocoa_CheckClipboardUpdate(_data->videodata); @@ -154,16 +215,6 @@ static __inline__ void ConvertNSRect(NSRect *r) } } -- (void)windowDidHide:(NSNotification *)aNotification -{ - SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_HIDDEN, 0, 0); -} - -- (void)windowDidUnhide:(NSNotification *)aNotification -{ - SDL_SendWindowEvent(_data->window, SDL_WINDOWEVENT_SHOWN, 0, 0); -} - - (void)mouseDown:(NSEvent *)theEvent { int button; @@ -179,7 +230,7 @@ static __inline__ void ConvertNSRect(NSRect *r) button = SDL_BUTTON_MIDDLE; break; default: - button = [theEvent buttonNumber]; + button = [theEvent buttonNumber] + 1; break; } SDL_SendMouseButton(_data->window, SDL_PRESSED, button); @@ -210,7 +261,7 @@ static __inline__ void ConvertNSRect(NSRect *r) button = SDL_BUTTON_MIDDLE; break; default: - button = [theEvent buttonNumber]; + button = [theEvent buttonNumber] + 1; break; } SDL_SendMouseButton(_data->window, SDL_RELEASED, button); @@ -226,20 +277,64 @@ static __inline__ void ConvertNSRect(NSRect *r) [self mouseUp:theEvent]; } -- (void)mouseMoved:(NSEvent *)theEvent +- (void)mouseEntered:(NSEvent *)theEvent +{ + SDL_SetMouseFocus(_data->window); + + SDL_SetCursor(NULL); +} + +- (void)mouseExited:(NSEvent *)theEvent { SDL_Window *window = _data->window; + + if (SDL_GetMouseFocus() == window) { + if (window->flags & SDL_WINDOW_INPUT_GRABBED) { + int x, y; + NSPoint point; + CGPoint cgpoint; + + point = [theEvent locationInWindow]; + point.y = window->h - point.y; + + SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y); + SDL_GetMouseState(&x, &y); + cgpoint.x = window->x + x; + cgpoint.y = window->y + y; + CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); + } else { + SDL_SetMouseFocus(NULL); + + [[NSCursor arrowCursor] set]; + [NSCursor unhide]; + } + } +} + +- (void)mouseMoved:(NSEvent *)theEvent +{ + SDL_Mouse *mouse = SDL_GetMouse(); + SDL_Window *window = _data->window; NSPoint point; + int x, y; + + if (mouse->relative_mode) { + return; + } point = [theEvent locationInWindow]; - point.y = window->h - point.y; - if ( point.x < 0 || point.x >= window->w || - point.y < 0 || point.y >= window->h ) { + x = (int)point.x; + y = (int)(window->h - point.y); + + if (x < 0 || x >= window->w || y < 0 || y >= window->h) { if (SDL_GetMouseFocus() == window) { - SDL_SetMouseFocus(NULL); + [self mouseExited:theEvent]; } } else { - SDL_SendMouseMotion(window, 0, (int)point.x, (int)point.y); + if (SDL_GetMouseFocus() != window) { + [self mouseEntered:theEvent]; + } + SDL_SendMouseMotion(window, 0, x, y); } } @@ -260,20 +355,7 @@ static __inline__ void ConvertNSRect(NSRect *r) - (void)scrollWheel:(NSEvent *)theEvent { - float x = [theEvent deltaX]; - float y = [theEvent deltaY]; - - if (x > 0) { - x += 0.9f; - } else if (x < 0) { - x -= 0.9f; - } - if (y > 0) { - y += 0.9f; - } else if (y < 0) { - y -= 0.9f; - } - SDL_SendMouseWheel(_data->window, (int)x, (int)y); + Cocoa_HandleMouseWheel(_data->window, theEvent); } - (void)touchesBeganWithEvent:(NSEvent *) theEvent @@ -298,7 +380,7 @@ static __inline__ void ConvertNSRect(NSRect *r) - (void)handleTouches:(cocoaTouchType)type withEvent:(NSEvent *)event { -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 +#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 NSSet *touches = 0; NSEnumerator *enumerator; NSTouch *touch; @@ -319,7 +401,7 @@ static __inline__ void ConvertNSRect(NSRect *r) enumerator = [touches objectEnumerator]; touch = (NSTouch*)[enumerator nextObject]; while (touch) { - SDL_TouchID touchId = (SDL_TouchID)[touch device]; + const SDL_TouchID touchId = (SDL_TouchID) ((size_t) [touch device]); if (!SDL_GetTouch(touchId)) { SDL_Touch touch; @@ -339,11 +421,11 @@ static __inline__ void ConvertNSRect(NSRect *r) } } - SDL_FingerID fingerId = (SDL_FingerID)[touch identity]; + const SDL_FingerID fingerId = (SDL_FingerID) ((size_t) [touch identity]); float x = [touch normalizedPosition].x; float y = [touch normalizedPosition].y; - /* Make the origin the upper left instead of the lower left */ - y = 1.0f - y; + /* Make the origin the upper left instead of the lower left */ + y = 1.0f - y; switch (type) { case COCOA_TOUCH_DOWN: @@ -360,7 +442,7 @@ static __inline__ void ConvertNSRect(NSRect *r) touch = (NSTouch*)[enumerator nextObject]; } -#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 */ +#endif /* MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 */ } @end @@ -383,41 +465,47 @@ static __inline__ void ConvertNSRect(NSRect *r) } @end -@interface SDLView : NSView { - Cocoa_WindowListener *listener; -} +@interface SDLView : NSView +/* The default implementation doesn't pass rightMouseDown to responder chain */ +- (void)rightMouseDown:(NSEvent *)theEvent; @end @implementation SDLView - -- (id) initWithFrame: (NSRect) rect - listener: (Cocoa_WindowListener *) theListener -{ - if (self = [super initWithFrame:rect]) { - listener = theListener; - } - - return self; -} - - (void)rightMouseDown:(NSEvent *)theEvent { - [listener mouseDown:theEvent]; + [[self nextResponder] rightMouseDown:theEvent]; } - @end +static unsigned int +GetWindowStyle(SDL_Window * window) +{ + unsigned int style; + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + style = NSBorderlessWindowMask; + } else { + if (window->flags & SDL_WINDOW_BORDERLESS) { + style = NSBorderlessWindowMask; + } else { + style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask); + } + if (window->flags & SDL_WINDOW_RESIZABLE) { + style |= NSResizableWindowMask; + } + } + return style; +} + static int SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created) { NSAutoreleasePool *pool; SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; - SDL_VideoDisplay *display = window->display; - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; SDL_WindowData *data; /* Allocate the window data */ - data = (SDL_WindowData *) SDL_malloc(sizeof(*data)); + data = (SDL_WindowData *) SDL_calloc(1, sizeof(*data)); if (!data) { SDL_OutOfMemory(); return -1; @@ -425,34 +513,30 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created data->window = window; data->nswindow = nswindow; data->created = created; - data->display = displaydata->display; data->videodata = videodata; pool = [[NSAutoreleasePool alloc] init]; /* Create an event listener for the window */ data->listener = [[Cocoa_WindowListener alloc] init]; - [data->listener listen:data]; /* Fill in the SDL window with the window data */ { - SDL_Rect bounds; NSRect rect = [nswindow contentRectForFrameRect:[nswindow frame]]; - NSView *contentView = [[SDLView alloc] initWithFrame: rect - listener: data->listener]; -#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_6 - [contentView setAcceptsTouchEvents:YES]; -#endif + NSView *contentView = [[SDLView alloc] initWithFrame:rect]; [nswindow setContentView: contentView]; [contentView release]; ConvertNSRect(&rect); - Cocoa_GetDisplayBounds(_this, display, &bounds); - window->x = (int)rect.origin.x - bounds.x; - window->y = (int)rect.origin.y - bounds.y; + window->x = (int)rect.origin.x; + window->y = (int)rect.origin.y; window->w = (int)rect.size.width; window->h = (int)rect.size.height; } + + /* Set up the listener after we create the view */ + [data->listener listen:data]; + if ([nswindow isVisible]) { window->flags |= SDL_WINDOW_SHOWN; } else { @@ -461,7 +545,7 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created { unsigned int style = [nswindow styleMask]; - if ((style & ~NSResizableWindowMask) == NSBorderlessWindowMask) { + if (style == NSBorderlessWindowMask) { window->flags |= SDL_WINDOW_BORDERLESS; } else { window->flags &= ~SDL_WINDOW_BORDERLESS; @@ -472,7 +556,8 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created window->flags &= ~SDL_WINDOW_RESIZABLE; } } - if ([nswindow isZoomed]) { + /* isZoomed always returns true if the window is not resizable */ + if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) { window->flags |= SDL_WINDOW_MAXIMIZED; } else { window->flags &= ~SDL_WINDOW_MAXIMIZED; @@ -485,10 +570,6 @@ SetupWindowData(_THIS, SDL_Window * window, NSWindow *nswindow, SDL_bool created if ([nswindow isKeyWindow]) { window->flags |= SDL_WINDOW_INPUT_FOCUS; SDL_SetKeyboardFocus(data->window); - - if (window->flags & SDL_WINDOW_INPUT_GRABBED) { - /* FIXME */ - } } /* All done! */ @@ -502,40 +583,19 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSWindow *nswindow; - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); NSRect rect; SDL_Rect bounds; unsigned int style; Cocoa_GetDisplayBounds(_this, display, &bounds); - if ((window->flags & SDL_WINDOW_FULLSCREEN) - || window->x == SDL_WINDOWPOS_CENTERED) { - rect.origin.x = bounds.x + (bounds.w - window->w) / 2; - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { - rect.origin.x = bounds.x; - } else { - rect.origin.x = bounds.x + window->x; - } - if ((window->flags & SDL_WINDOW_FULLSCREEN) - || window->y == SDL_WINDOWPOS_CENTERED) { - rect.origin.y = bounds.y + (bounds.h - window->h) / 2; - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { - rect.origin.y = bounds.y; - } else { - rect.origin.y = bounds.y + window->y; - } + rect.origin.x = window->x; + rect.origin.y = window->y; rect.size.width = window->w; rect.size.height = window->h; ConvertNSRect(&rect); - if (window->flags & SDL_WINDOW_BORDERLESS) { - style = NSBorderlessWindowMask; - } else { - style = (NSTitledWindowMask|NSClosableWindowMask|NSMiniaturizableWindowMask); - } - if (window->flags & SDL_WINDOW_RESIZABLE) { - style |= NSResizableWindowMask; - } + style = GetWindowStyle(window); /* Figure out which screen to place this window */ NSArray *screens = [NSScreen screens]; @@ -554,7 +614,7 @@ Cocoa_CreateWindow(_THIS, SDL_Window * window) rect.origin.y -= screenRect.origin.y; } } - nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:FALSE screen:screen]; + nswindow = [[SDLWindow alloc] initWithContentRect:rect styleMask:style backing:NSBackingStoreBuffered defer:YES screen:screen]; [pool release]; @@ -603,33 +663,42 @@ Cocoa_SetWindowTitle(_THIS, SDL_Window * window) [pool release]; } +void +Cocoa_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + NSImage *nsimage = Cocoa_CreateImage(icon); + + if (nsimage) { + [NSApp setApplicationIconImage:nsimage]; + } + + [pool release]; +} + void Cocoa_SetWindowPosition(_THIS, SDL_Window * window) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; - SDL_VideoDisplay *display = window->display; NSRect rect; - SDL_Rect bounds; + Uint32 moveHack; - Cocoa_GetDisplayBounds(_this, display, &bounds); - if ((window->flags & SDL_WINDOW_FULLSCREEN) - || window->x == SDL_WINDOWPOS_CENTERED) { - rect.origin.x = bounds.x + (bounds.w - window->w) / 2; - } else { - rect.origin.x = bounds.x + window->x; - } - if ((window->flags & SDL_WINDOW_FULLSCREEN) - || window->y == SDL_WINDOWPOS_CENTERED) { - rect.origin.y = bounds.y + (bounds.h - window->h) / 2; - } else { - rect.origin.y = bounds.y + window->y; - } + rect.origin.x = window->x; + rect.origin.y = window->y; rect.size.width = window->w; rect.size.height = window->h; ConvertNSRect(&rect); - rect = [nswindow frameRectForContentRect:rect]; + + moveHack = s_moveHack; + s_moveHack = 0; [nswindow setFrameOrigin:rect.origin]; + s_moveHack = moveHack; + + if (window == _this->current_glwin) { + [((NSOpenGLContext *) _this->current_glctx) update]; + } + [pool release]; } @@ -637,12 +706,18 @@ void Cocoa_SetWindowSize(_THIS, SDL_Window * window) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; + SDL_WindowData *windata = (SDL_WindowData *) window->driverdata; + NSWindow *nswindow = windata->nswindow; NSSize size; size.width = window->w; size.height = window->h; [nswindow setContentSize:size]; + + if (window == _this->current_glwin) { + [((NSOpenGLContext *) _this->current_glctx) update]; + } + [pool release]; } @@ -685,6 +760,11 @@ Cocoa_MaximizeWindow(_THIS, SDL_Window * window) NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow; [nswindow zoom:nil]; + + if (window == _this->current_glwin) { + [((NSOpenGLContext *) _this->current_glctx) update]; + } + [pool release]; } @@ -706,20 +786,175 @@ Cocoa_RestoreWindow(_THIS, SDL_Window * window) if ([nswindow isMiniaturized]) { [nswindow deminiaturize:nil]; - } else if ([nswindow isZoomed]) { + } else if ((window->flags & SDL_WINDOW_RESIZABLE) && [nswindow isZoomed]) { [nswindow zoom:nil]; } [pool release]; } +static NSWindow * +Cocoa_RebuildWindow(SDL_WindowData * data, NSWindow * nswindow, unsigned style) +{ + if (!data->created) { + /* Don't mess with other people's windows... */ + return nswindow; + } + + [data->listener close]; + data->nswindow = [[SDLWindow alloc] initWithContentRect:[[nswindow contentView] frame] styleMask:style backing:NSBackingStoreBuffered defer:YES screen:[nswindow screen]]; + [data->nswindow setContentView:[nswindow contentView]]; + [data->listener listen:data]; + + [nswindow close]; + + return data->nswindow; +} + +void +Cocoa_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + NSWindow *nswindow = data->nswindow; + NSRect rect; + + /* The view responder chain gets messed with during setStyleMask */ + if ([[nswindow contentView] nextResponder] == data->listener) { + [[nswindow contentView] setNextResponder:nil]; + } + + if (fullscreen) { + SDL_Rect bounds; + + Cocoa_GetDisplayBounds(_this, display, &bounds); + rect.origin.x = bounds.x; + rect.origin.y = bounds.y; + rect.size.width = bounds.w; + rect.size.height = bounds.h; + ConvertNSRect(&rect); + + /* Hack to fix origin on Mac OS X 10.4 */ + NSRect screenRect = [[nswindow screen] frame]; + if (screenRect.size.height >= 1.0f) { + rect.origin.y += (screenRect.size.height - rect.size.height); + } + + if ([nswindow respondsToSelector: @selector(setStyleMask:)]) { + [nswindow performSelector: @selector(setStyleMask:) withObject: (id)NSBorderlessWindowMask]; + } else { + nswindow = Cocoa_RebuildWindow(data, nswindow, NSBorderlessWindowMask); + } + } else { + rect.origin.x = window->windowed.x; + rect.origin.y = window->windowed.y; + rect.size.width = window->windowed.w; + rect.size.height = window->windowed.h; + ConvertNSRect(&rect); + + if ([nswindow respondsToSelector: @selector(setStyleMask:)]) { + [nswindow performSelector: @selector(setStyleMask:) withObject: (id)(uintptr_t)GetWindowStyle(window)]; + } else { + nswindow = Cocoa_RebuildWindow(data, nswindow, GetWindowStyle(window)); + } + } + + /* The view responder chain gets messed with during setStyleMask */ + if ([[nswindow contentView] nextResponder] != data->listener) { + [[nswindow contentView] setNextResponder:data->listener]; + } + + s_moveHack = 0; + [nswindow setFrameOrigin:rect.origin]; + [nswindow setContentSize:rect.size]; + s_moveHack = SDL_GetTicks(); + + /* When the window style changes the title is cleared */ + if (!fullscreen) { + Cocoa_SetWindowTitle(_this, window); + } + +#ifdef FULLSCREEN_TOGGLEABLE + if (fullscreen) { + /* OpenGL is rendering to the window, so make it visible! */ + [nswindow setLevel:CGShieldingWindowLevel()]; + } else { + [nswindow setLevel:kCGNormalWindowLevel]; + } +#endif + [nswindow makeKeyAndOrderFront:nil]; + + if (window == _this->current_glwin) { + [((NSOpenGLContext *) _this->current_glctx) update]; + } + + [pool release]; +} + +int +Cocoa_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) +{ + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + CGDirectDisplayID display_id = ((SDL_DisplayData *)display->driverdata)->display; + const uint32_t tableSize = 256; + CGGammaValue redTable[tableSize]; + CGGammaValue greenTable[tableSize]; + CGGammaValue blueTable[tableSize]; + uint32_t i; + float inv65535 = 1.0f / 65535.0f; + + /* Extract gamma values into separate tables, convert to floats between 0.0 and 1.0 */ + for (i = 0; i < 256; i++) { + redTable[i] = ramp[0*256+i] * inv65535; + greenTable[i] = ramp[1*256+i] * inv65535; + blueTable[i] = ramp[2*256+i] * inv65535; + } + + if (CGSetDisplayTransferByTable(display_id, tableSize, + redTable, greenTable, blueTable) != CGDisplayNoErr) { + SDL_SetError("CGSetDisplayTransferByTable()"); + return -1; + } + return 0; +} + +int +Cocoa_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) +{ + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + CGDirectDisplayID display_id = ((SDL_DisplayData *)display->driverdata)->display; + const uint32_t tableSize = 256; + CGGammaValue redTable[tableSize]; + CGGammaValue greenTable[tableSize]; + CGGammaValue blueTable[tableSize]; + uint32_t i, tableCopied; + + if (CGGetDisplayTransferByTable(display_id, tableSize, + redTable, greenTable, blueTable, &tableCopied) != CGDisplayNoErr) { + SDL_SetError("CGGetDisplayTransferByTable()"); + return -1; + } + + for (i = 0; i < tableCopied; i++) { + ramp[0*256+i] = (Uint16)(redTable[i] * 65535.0f); + ramp[1*256+i] = (Uint16)(greenTable[i] * 65535.0f); + ramp[2*256+i] = (Uint16)(blueTable[i] * 65535.0f); + } + return 0; +} + void Cocoa_SetWindowGrab(_THIS, SDL_Window * window) { + /* Move the cursor to the nearest point in the window */ if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { - /* FIXME: Grab mouse */ - } else { - /* FIXME: Release mouse */ + int x, y; + CGPoint cgpoint; + + SDL_GetMouseState(&x, &y); + cgpoint.x = window->x + x; + cgpoint.y = window->y + y; + CGDisplayMoveCursorToPoint(kCGDirectMainDisplay, cgpoint); } } @@ -747,7 +982,7 @@ Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) if (info->version.major <= SDL_MAJOR_VERSION) { info->subsystem = SDL_SYSWM_COCOA; - info->cocoa.window = nswindow; + info->info.cocoa.window = nswindow; return SDL_TRUE; } else { SDL_SetError("Application not compiled with SDL %d.%d\n", @@ -756,4 +991,6 @@ Cocoa_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) } } +#endif /* SDL_VIDEO_DRIVER_COCOA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_WM.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_WM.c index 101a8e06a..c079f6381 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_WM.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_WM.c @@ -1,31 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -//#include "SDL_syswm.h" -//#include "../SDL_sysvideo.h" -//#include "../../events/SDL_keyboard_c.h" +#if SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" +#include "SDL_DirectFB_window.h" #include "../../events/SDL_windowevents_c.h" @@ -127,6 +125,11 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window) if (!windata->is_managed || (window->flags & SDL_WINDOW_FULLSCREEN)) return; + SDL_DFB_CHECK(s->SetSrcBlendFunction(s, DSBF_ONE)); + SDL_DFB_CHECK(s->SetDstBlendFunction(s, DSBF_ZERO)); + SDL_DFB_CHECK(s->SetDrawingFlags(s, DSDRAW_NOFX)); + SDL_DFB_CHECK(s->SetBlittingFlags(s, DSBLIT_NOFX)); + LoadFont(_this, window); //s->SetDrawingFlags(s, DSDRAW_BLEND); s->SetColor(s, COLOR_EXPAND(t->frame_color)); @@ -181,8 +184,10 @@ DFBResult DirectFB_WM_GetClientSize(_THIS, SDL_Window * window, int *cw, int *ch) { SDL_DFB_WINDOWDATA(window); + IDirectFBWindow *dfbwin = windata->dfbwin; - SDL_DFB_CHECK(windata->window->GetSize(windata->window, cw, ch)); + SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, cw, ch)); + dfbwin->GetSize(dfbwin, cw, ch); *cw -= windata->theme.left_size + windata->theme.right_size; *ch -= windata->theme.top_size + windata->theme.caption_size + @@ -197,6 +202,9 @@ DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h) if (!windata->is_managed) windata->theme = theme_none; + else if (flags & SDL_WINDOW_BORDERLESS) + //desc.caps |= DWCAPS_NODECORATION;) + windata->theme = theme_none; else if (flags & SDL_WINDOW_FULLSCREEN) { windata->theme = theme_none; } else if (flags & SDL_WINDOW_MAXIMIZED) { @@ -220,37 +228,6 @@ DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h) windata->theme.caption_size + windata->theme.bottom_size; } -void -DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window) -{ - SDL_DFB_WINDOWDATA(window); - SDL_VideoDisplay *display = window->display; - - SDL_DFB_CHECK(windata->window->GetPosition(windata->window, - &windata->restore.x, &windata->restore.y)); - SDL_DFB_CHECK(windata->window->GetSize(windata->window, &windata->restore.w, - &windata->restore.h)); - - DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ; - - SDL_DFB_CHECK(windata->window->MoveTo(windata->window, 0, 0)); - SDL_DFB_CHECK(windata->window->Resize(windata->window, - display->current_mode.w, display->current_mode.h)); -} - -void -DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window) -{ - SDL_DFB_WINDOWDATA(window); - - DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED), - windata->restore.w, windata->restore.h); - - SDL_DFB_CHECK(windata->window->Resize(windata->window, windata->restore.w, - windata->restore.h)); - SDL_DFB_CHECK(windata->window->MoveTo(windata->window, windata->restore.x, - windata->restore.y)); -} enum { @@ -307,20 +284,20 @@ WMPos(DFB_WindowData * p, int x, int y) return pos; } -static int wm_grab; -static int wm_lastx; -static int wm_lasty; - int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) { SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); DFB_WindowData *gwindata = ((devdata->grabbed_window) ? (DFB_WindowData *) ((devdata->grabbed_window)->driverdata) : NULL); + IDirectFBWindow *dfbwin = windata->dfbwin; + DFBWindowOptions wopts; if (!windata->is_managed) return 0; + SDL_DFB_CHECK(dfbwin->GetOptions(dfbwin, &wopts)); + switch (evt->type) { case DWET_BUTTONDOWN: if (evt->buttons & DIBM_LEFT) { @@ -329,59 +306,99 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) case WM_POS_NONE: return 0; case WM_POS_CLOSE: - wm_grab = WM_POS_NONE; + windata->wm_grab = WM_POS_NONE; SDL_SendWindowEvent(window, SDL_WINDOWEVENT_CLOSE, 0, 0); return 1; case WM_POS_MAX: - wm_grab = WM_POS_NONE; - if (window->flags & SDL_WINDOW_MAXIMIZED) { - SDL_RestoreWindow(window); - } else { - SDL_MaximizeWindow(window); - } + windata->wm_grab = WM_POS_NONE; + if (window->flags & SDL_WINDOW_MAXIMIZED) { + SDL_RestoreWindow(window); + } else { + SDL_MaximizeWindow(window); + } return 1; case WM_POS_CAPTION: - DirectFB_RaiseWindow(_this, window); + if (!(wopts & DWOP_KEEP_STACKING)) { + DirectFB_RaiseWindow(_this, window); + } + if (window->flags & SDL_WINDOW_MAXIMIZED) + return 1; /* fall through */ default: - wm_grab = pos; + windata->wm_grab = pos; if (gwindata != NULL) - SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window)); - SDL_DFB_CHECK(windata->window->GrabPointer(windata->window)); - wm_lastx = evt->cx; - wm_lasty = evt->cy; + SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin)); + SDL_DFB_CHECK(dfbwin->GrabPointer(dfbwin)); + windata->wm_lastx = evt->cx; + windata->wm_lasty = evt->cy; } } return 1; case DWET_BUTTONUP: - break; - case DWET_MOTION: - if (!wm_grab) + if (!windata->wm_grab) return 0; - if (evt->buttons & DIBM_LEFT) { - int dx = evt->cx - wm_lastx; - int dy = evt->cy - wm_lasty; - int cw, ch; + if (!(evt->buttons & DIBM_LEFT)) { + if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) { + int dx = evt->cx - windata->wm_lastx; + int dy = evt->cy - windata->wm_lasty; - if (wm_grab & WM_POS_CAPTION) - SDL_DFB_CHECK(windata->window->Move(windata->window, dx, dy)); - if (wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) { - if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM) - dx = 0; - else if ((wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT) - dy = 0; - SDL_DFB_CHECK(windata->window->GetSize(windata->window, &cw, &ch)); - SDL_DFB_CHECK(windata->window->Resize(windata->window, cw + dx, ch + dy)); + if (!(wopts & DWOP_KEEP_SIZE)) { + int cw, ch; + if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM) + dx = 0; + else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT) + dy = 0; + SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch)); + + /* necessary to trigger an event - ugly*/ + SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL)); + SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx + 1, ch + dy)); + SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL)); + + SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy)); + } } - wm_lastx = evt->cx; - wm_lasty = evt->cy; + SDL_DFB_CHECK(dfbwin->UngrabPointer(dfbwin)); + if (gwindata != NULL) + SDL_DFB_CHECK(gwindata->dfbwin->GrabPointer(gwindata->dfbwin)); + windata->wm_grab = WM_POS_NONE; return 1; } - SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window)); - if (gwindata != NULL) - SDL_DFB_CHECK(gwindata->window->GrabPointer(gwindata->window)); - wm_grab = WM_POS_NONE; + break; + case DWET_MOTION: + if (!windata->wm_grab) + return 0; + if (evt->buttons & DIBM_LEFT) { + int dx = evt->cx - windata->wm_lastx; + int dy = evt->cy - windata->wm_lasty; + + if (windata->wm_grab & WM_POS_CAPTION) { + if (!(wopts & DWOP_KEEP_POSITION)) + SDL_DFB_CHECK(dfbwin->Move(dfbwin, dx, dy)); + } + if (windata->wm_grab & (WM_POS_RIGHT | WM_POS_BOTTOM)) { + if (!(wopts & DWOP_KEEP_SIZE)) { + int cw, ch; + + /* Make sure all events are disabled for this operation ! */ + SDL_DFB_CHECK(dfbwin->DisableEvents(dfbwin, DWET_ALL)); + + if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_BOTTOM) + dx = 0; + else if ((windata->wm_grab & (WM_POS_BOTTOM | WM_POS_RIGHT)) == WM_POS_RIGHT) + dy = 0; + + SDL_DFB_CHECK(dfbwin->GetSize(dfbwin, &cw, &ch)); + SDL_DFB_CHECK(dfbwin->Resize(dfbwin, cw + dx, ch + dy)); + + SDL_DFB_CHECK(dfbwin->EnableEvents(dfbwin, DWET_ALL)); + } + } + windata->wm_lastx = evt->cx; + windata->wm_lasty = evt->cy; + return 1; + } break; case DWET_KEYDOWN: break; @@ -392,3 +409,5 @@ DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, DFBWindowEvent * evt) } return 0; } + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_WM.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_WM.h index f04d0ce31..527162852 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_WM.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_WM.h @@ -1,29 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" #ifndef _SDL_directfb_wm_h #define _SDL_directfb_wm_h +#include "SDL_DirectFB_video.h" + typedef struct _DFB_Theme DFB_Theme; struct _DFB_Theme { @@ -42,8 +42,6 @@ struct _DFB_Theme }; extern void DirectFB_WM_AdjustWindowLayout(SDL_Window * window, int flags, int w, int h); -extern void DirectFB_WM_MaximizeWindow(_THIS, SDL_Window * window); -extern void DirectFB_WM_RestoreWindow(_THIS, SDL_Window * window); extern void DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window); extern int DirectFB_WM_ProcessEvent(_THIS, SDL_Window * window, diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.c index 3706186eb..840586b58 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DIRECTFB + #include "SDL_DirectFB_video.h" #include "SDL_DirectFB_dyn.h" @@ -41,6 +42,7 @@ static struct _SDL_DirectFB_Symbols #define DFB_SYM(ret, name, args, al, func) ret name args { func SDL_DirectFB_Symbols.name al ; } DFB_SYMS #undef DFB_SYM + static void *handle = NULL; int @@ -55,7 +57,7 @@ SDL_DirectFB_LoadLibrary(void) #define DFB_SYM(ret, name, args, al, func) if (!(SDL_DirectFB_Symbols.name = SDL_LoadFunction(handle, # name))) retval = 0; DFB_SYMS #undef DFB_SYM - if (! + if (! (SDL_DirectFB_Symbols.directfb_major_version = SDL_LoadFunction(handle, "directfb_major_version"))) retval = 0; @@ -111,3 +113,5 @@ SDL_DirectFB_UnLoadLibrary(void) { } #endif + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.h index 8569ab965..9a33d0a7f 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_dyn.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _SDL_DirectFB_dyn_h @@ -33,7 +32,6 @@ DFB_SYM(DFBResult, DirectFBCreate, (IDirectFB **interface), (interface), return) \ DFB_SYM(const char *, DirectFBCheckVersion, (unsigned int required_major, unsigned int required_minor, unsigned int required_micro), \ (required_major, required_minor, required_micro), return) -// #define SDL_VIDEO_DRIVER_DIRECTFB_DYNAMIC "/usr/lib/libdirectfb-1.2.so.0" int SDL_DirectFB_LoadLibrary(void); void SDL_DirectFB_UnLoadLibrary(void); diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_events.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_events.c index 8fe8db78b..1a935144b 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_events.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_events.c @@ -1,35 +1,42 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DIRECTFB + /* Handle the event stream, converting DirectFB input events into SDL events */ -#include +#include "SDL_DirectFB_video.h" +#include "SDL_DirectFB_window.h" +#include "SDL_DirectFB_modes.h" -#include "../SDL_sysvideo.h" -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" +#include "SDL_syswm.h" + +#include "../../events/SDL_mouse_c.h" #include "../../events/SDL_keyboard_c.h" +#include "../../events/SDL_windowevents_c.h" +#include "../../events/SDL_events_c.h" #include "../../events/scancodes_linux.h" +#include "../../events/scancodes_xfree86.h" + #include "SDL_DirectFB_events.h" #if USE_MULTI_API @@ -53,36 +60,36 @@ struct _cb_data }; /* The translation tables from a DirectFB keycode to a SDL keysym */ -static SDLKey oskeymap[256]; +static SDL_Scancode oskeymap[256]; -static SDL_keysym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, - SDL_keysym * keysym); -static SDL_keysym *DirectFB_TranslateKeyInputEvent(_THIS, int index, - DFBInputEvent * evt, - SDL_keysym * keysym); +static SDL_Keysym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, + SDL_Keysym * keysym); +static SDL_Keysym *DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt, + SDL_Keysym * keysym); -static void DirectFB_InitOSKeymap(_THIS, SDLKey * keypmap, int numkeys); +static void DirectFB_InitOSKeymap(_THIS, SDL_Scancode * keypmap, int numkeys); static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button); -static void -DirectFB_SetContext(_THIS, SDL_Window *window) +static void UnicodeToUtf8( Uint16 w , char *utf8buf) { -#if (DFB_VERSION_ATLEAST(1,0,0)) - /* FIXME: does not work on 1.0/1.2 with radeon driver - * the approach did work with the matrox driver - * This has simply no effect. - */ - - SDL_VideoDisplay *display = window->display; - DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; - - /* FIXME: should we handle the error */ - if (dispdata->vidIDinuse) - SDL_DFB_CHECK(dispdata->vidlayer->SwitchContext(dispdata->vidlayer, - DFB_TRUE)); -#endif - + unsigned char *utf8s = (unsigned char *) utf8buf; + + if ( w < 0x0080 ) { + utf8s[0] = ( unsigned char ) w; + utf8s[1] = 0; + } + else if ( w < 0x0800 ) { + utf8s[0] = 0xc0 | (( w ) >> 6 ); + utf8s[1] = 0x80 | (( w ) & 0x3f ); + utf8s[2] = 0; + } + else { + utf8s[0] = 0xe0 | (( w ) >> 12 ); + utf8s[1] = 0x80 | (( ( w ) >> 6 ) & 0x3f ); + utf8s[2] = 0x80 | (( w ) & 0x3f ); + utf8s[3] = 0; + } } static void @@ -164,21 +171,21 @@ ClientXY(DFB_WindowData * p, int *x, int *y) } static void -ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, - DFBWindowEvent * evt) +ProcessWindowEvent(_THIS, SDL_Window *sdlwin, DFBWindowEvent * evt) { SDL_DFB_DEVICEDATA(_this); - SDL_keysym keysym; - char text[5]; + SDL_DFB_WINDOWDATA(sdlwin); + SDL_Keysym keysym; + char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; if (evt->clazz == DFEC_WINDOW) { switch (evt->type) { case DWET_BUTTONDOWN: - if (ClientXY(p, &evt->x, &evt->y)) { + if (ClientXY(windata, &evt->x, &evt->y)) { if (!devdata->use_linux_input) { - SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0, evt->x, + SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->x, evt->y, 0); - SDL_SendMouseButton_ex(p->sdl_window, devdata->mouse_id[0], + SDL_SendMouseButton_ex(sdlwin, devdata->mouse_id[0], SDL_PRESSED, DirectFB_TranslateButton (evt->button)); @@ -188,11 +195,11 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, } break; case DWET_BUTTONUP: - if (ClientXY(p, &evt->x, &evt->y)) { + if (ClientXY(windata, &evt->x, &evt->y)) { if (!devdata->use_linux_input) { - SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0, evt->x, + SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->x, evt->y, 0); - SDL_SendMouseButton_ex(p->sdl_window, devdata->mouse_id[0], + SDL_SendMouseButton_ex(sdlwin, devdata->mouse_id[0], SDL_RELEASED, DirectFB_TranslateButton (evt->button)); @@ -202,11 +209,10 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, } break; case DWET_MOTION: - if (ClientXY(p, &evt->x, &evt->y)) { - SDL_Window *window = p->sdl_window; + if (ClientXY(windata, &evt->x, &evt->y)) { if (!devdata->use_linux_input) { - if (!(flags & SDL_WINDOW_INPUT_GRABBED)) - SDL_SendMouseMotion_ex(p->sdl_window, devdata->mouse_id[0], 0, + if (!(sdlwin->flags & SDL_WINDOW_INPUT_GRABBED)) + SDL_SendMouseMotion_ex(sdlwin, devdata->mouse_id[0], 0, evt->x, evt->y, 0); } else { /* relative movements are not exact! @@ -218,18 +224,19 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, cnt = 0; } } - if (!(window->flags & SDL_WINDOW_MOUSE_FOCUS)) - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_ENTER, 0, + if (!(sdlwin->flags & SDL_WINDOW_MOUSE_FOCUS)) + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_ENTER, 0, 0); } break; case DWET_KEYDOWN: if (!devdata->use_linux_input) { DirectFB_TranslateKey(_this, evt, &keysym); + //printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); SDL_SendKeyboardKey_ex(0, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { - SDL_memcpy(text, &keysym.unicode, 4); - text[4] = 0; + SDL_zero(text); + UnicodeToUtf8(keysym.unicode, text); if (*text) { SDL_SendKeyboardText_ex(0, text); } @@ -243,49 +250,49 @@ ProcessWindowEvent(_THIS, DFB_WindowData * p, Uint32 flags, } break; case DWET_POSITION: - if (ClientXY(p, &evt->x, &evt->y)) { - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_MOVED, + if (ClientXY(windata, &evt->x, &evt->y)) { + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_MOVED, evt->x, evt->y); } break; case DWET_POSITION_SIZE: - if (ClientXY(p, &evt->x, &evt->y)) { - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_MOVED, + if (ClientXY(windata, &evt->x, &evt->y)) { + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_MOVED, evt->x, evt->y); } /* fall throught */ case DWET_SIZE: // FIXME: what about < 0 - evt->w -= (p->theme.right_size + p->theme.left_size); + evt->w -= (windata->theme.right_size + windata->theme.left_size); evt->h -= - (p->theme.top_size + p->theme.bottom_size + - p->theme.caption_size); - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_RESIZED, + (windata->theme.top_size + windata->theme.bottom_size + + windata->theme.caption_size); + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_RESIZED, evt->w, evt->h); break; case DWET_CLOSE: - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_CLOSE, 0, 0); + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_CLOSE, 0, 0); break; case DWET_GOTFOCUS: - DirectFB_SetContext(_this, p->sdl_window); - FocusAllKeyboards(_this, p->sdl_window); - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_FOCUS_GAINED, + DirectFB_SetContext(_this, sdlwin); + FocusAllKeyboards(_this, sdlwin); + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_FOCUS_GAINED, 0, 0); break; case DWET_LOSTFOCUS: - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_FOCUS_LOST, 0, 0); FocusAllKeyboards(_this, 0); break; case DWET_ENTER: /* SDL_DirectFB_ReshowCursor(_this, 0); */ - FocusAllMice(_this, p->sdl_window); + FocusAllMice(_this, sdlwin); // FIXME: when do we really enter ? - if (ClientXY(p, &evt->x, &evt->y)) + if (ClientXY(windata, &evt->x, &evt->y)) MotionAllMice(_this, evt->x, evt->y); - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_ENTER, 0, 0); + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_ENTER, 0, 0); break; case DWET_LEAVE: - SDL_SendWindowEvent(p->sdl_window, SDL_WINDOWEVENT_LEAVE, 0, 0); + SDL_SendWindowEvent(sdlwin, SDL_WINDOWEVENT_LEAVE, 0, 0); FocusAllMice(_this, 0); /* SDL_DirectFB_ReshowCursor(_this, 1); */ break; @@ -300,9 +307,9 @@ static void ProcessInputEvent(_THIS, DFBInputEvent * ievt) { SDL_DFB_DEVICEDATA(_this); - SDL_keysym keysym; + SDL_Keysym keysym; int kbd_idx; - char text[5]; + char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; if (!devdata->use_linux_input) { if (ievt->type == DIET_AXISMOTION) { @@ -337,7 +344,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) (DFB_WindowData *) window->driverdata; int x, y; - windata->window->GetPosition(windata->window, &x, &y); + windata->dfbwin->GetPosition(windata->dfbwin, &x, &y); SDL_SendMouseMotion_ex(window, ievt->device_id, 0, last_x - (x + windata->client.x), @@ -359,11 +366,12 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) break; case DIET_KEYPRESS: kbd_idx = KbdIndex(_this, ievt->device_id); - DirectFB_TranslateKeyInputEvent(_this, kbd_idx, ievt, &keysym); + DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym); + //printf("Scancode %d %d %d\n", keysym.scancode, evt->key_code, evt->key_id); SDL_SendKeyboardKey_ex(kbd_idx, SDL_PRESSED, keysym.scancode); if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) { - SDL_memcpy(text, &keysym.unicode, 4); - text[4] = 0; + SDL_zero(text); + UnicodeToUtf8(keysym.unicode, text); if (*text) { SDL_SendKeyboardText_ex(kbd_idx, text); } @@ -371,7 +379,7 @@ ProcessInputEvent(_THIS, DFBInputEvent * ievt) break; case DIET_KEYRELEASE: kbd_idx = KbdIndex(_this, ievt->device_id); - DirectFB_TranslateKeyInputEvent(_this, kbd_idx, ievt, &keysym); + DirectFB_TranslateKeyInputEvent(_this, ievt, &keysym); SDL_SendKeyboardKey_ex(kbd_idx, SDL_RELEASED, keysym.scancode); break; case DIET_BUTTONPRESS: @@ -400,29 +408,46 @@ void DirectFB_PumpEventsWindow(_THIS) { SDL_DFB_DEVICEDATA(_this); - DFB_WindowData *p; DFBInputEvent ievt; + SDL_Window *w; - for (p = devdata->firstwin; p != NULL; p = p->next) { + for (w = devdata->firstwin; w != NULL; w = w->next) { + SDL_DFB_WINDOWDATA(w); DFBWindowEvent evt; - SDL_Window *w = p->sdl_window; - while (p->eventbuffer->GetEvent(p->eventbuffer, + while (windata->eventbuffer->GetEvent(windata->eventbuffer, DFB_EVENT(&evt)) == DFB_OK) { - if (!DirectFB_WM_ProcessEvent(_this, w, &evt)) - ProcessWindowEvent(_this, p, w->flags, &evt); + if (!DirectFB_WM_ProcessEvent(_this, w, &evt)) { + /* Send a SDL_SYSWMEVENT if the application wants them */ + if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { + SDL_SysWMmsg wmmsg; + SDL_VERSION(&wmmsg.version); + wmmsg.subsystem = SDL_SYSWM_DIRECTFB; + wmmsg.msg.dfb.event.window = evt; + SDL_SendSysWMEvent(&wmmsg); + } + ProcessWindowEvent(_this, w, &evt); + } } } /* Now get relative events in case we need them */ while (devdata->events->GetEvent(devdata->events, DFB_EVENT(&ievt)) == DFB_OK) { + + if (SDL_GetEventState(SDL_SYSWMEVENT) == SDL_ENABLE) { + SDL_SysWMmsg wmmsg; + SDL_VERSION(&wmmsg.version); + wmmsg.subsystem = SDL_SYSWM_DIRECTFB; + wmmsg.msg.dfb.event.input = ievt; + SDL_SendSysWMEvent(&wmmsg); + } ProcessInputEvent(_this, &ievt); } } void -DirectFB_InitOSKeymap(_THIS, SDLKey * keymap, int numkeys) +DirectFB_InitOSKeymap(_THIS, SDL_Scancode * keymap, int numkeys) { int i; @@ -549,19 +574,21 @@ DirectFB_InitOSKeymap(_THIS, SDLKey * keymap, int numkeys) } -static SDL_keysym * -DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_keysym * keysym) +static SDL_Keysym * +DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_Keysym * keysym) { SDL_DFB_DEVICEDATA(_this); + int kbd_idx = 0; /* Window events lag the device source KbdIndex(_this, evt->device_id); */ + DFB_KeyboardData *kbd = &devdata->keyboard[kbd_idx]; - if (evt->key_code >= 0 && - evt->key_code < SDL_arraysize(linux_scancode_table)) - keysym->scancode = linux_scancode_table[evt->key_code]; - else - keysym->scancode = SDL_SCANCODE_UNKNOWN; + keysym->scancode = SDL_SCANCODE_UNKNOWN; + + if (kbd->map && evt->key_code >= kbd->map_adjust && + evt->key_code < kbd->map_size + kbd->map_adjust) + keysym->scancode = kbd->map[evt->key_code - kbd->map_adjust]; if (keysym->scancode == SDL_SCANCODE_UNKNOWN || - devdata->keyboard[0].is_generic) { + devdata->keyboard[kbd_idx].is_generic) { if (evt->key_id - DIKI_UNKNOWN < SDL_arraysize(oskeymap)) keysym->scancode = oskeymap[evt->key_id - DIKI_UNKNOWN]; else @@ -577,20 +604,21 @@ DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_keysym * keysym) return keysym; } -static SDL_keysym * -DirectFB_TranslateKeyInputEvent(_THIS, int index, DFBInputEvent * evt, - SDL_keysym * keysym) +static SDL_Keysym * +DirectFB_TranslateKeyInputEvent(_THIS, DFBInputEvent * evt, + SDL_Keysym * keysym) { SDL_DFB_DEVICEDATA(_this); + int kbd_idx = KbdIndex(_this, evt->device_id); + DFB_KeyboardData *kbd = &devdata->keyboard[kbd_idx]; - if (evt->key_code >= 0 && - evt->key_code < SDL_arraysize(linux_scancode_table)) - keysym->scancode = linux_scancode_table[evt->key_code]; - else - keysym->scancode = SDL_SCANCODE_UNKNOWN; + keysym->scancode = SDL_SCANCODE_UNKNOWN; - if (keysym->scancode == SDL_SCANCODE_UNKNOWN || - devdata->keyboard[index].is_generic) { + if (kbd->map && evt->key_code >= kbd->map_adjust && + evt->key_code < kbd->map_size + kbd->map_adjust) + keysym->scancode = kbd->map[evt->key_code - kbd->map_adjust]; + + if (keysym->scancode == SDL_SCANCODE_UNKNOWN || devdata->keyboard[kbd_idx].is_generic) { if (evt->key_id - DIKI_UNKNOWN < SDL_arraysize(oskeymap)) keysym->scancode = oskeymap[evt->key_id - DIKI_UNKNOWN]; else @@ -630,7 +658,7 @@ EnumKeyboards(DFBInputDeviceID device_id, #if USE_MULTI_API SDL_Keyboard keyboard; #endif - SDLKey keymap[SDL_NUM_SCANCODES]; + SDL_Keycode keymap[SDL_NUM_SCANCODES]; if (!cb->sys_kbd) { if (cb->sys_ids) { @@ -653,8 +681,18 @@ EnumKeyboards(DFBInputDeviceID device_id, devdata->keyboard[devdata->num_keyboard].id = device_id; devdata->keyboard[devdata->num_keyboard].is_generic = 0; if (!strncmp("X11", desc.name, 3)) - devdata->keyboard[devdata->num_keyboard].is_generic = 1; + { + devdata->keyboard[devdata->num_keyboard].map = xfree86_scancode_table2; + devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(xfree86_scancode_table2); + devdata->keyboard[devdata->num_keyboard].map_adjust = 8; + } else { + devdata->keyboard[devdata->num_keyboard].map = linux_scancode_table; + devdata->keyboard[devdata->num_keyboard].map_size = SDL_arraysize(linux_scancode_table); + devdata->keyboard[devdata->num_keyboard].map_adjust = 0; + } + SDL_DFB_LOG("Keyboard %d - %s\n", device_id, desc.name); + SDL_GetDefaultKeymap(keymap); #if USE_MULTI_API SDL_SetKeymap(devdata->num_keyboard, 0, keymap, SDL_NUM_SCANCODES); @@ -708,74 +746,4 @@ DirectFB_QuitKeyboard(_THIS) } -#if 0 -/* FIXME: Remove once determined this is not needed in fullscreen mode */ -void -DirectFB_PumpEvents(_THIS) -{ - SDL_DFB_DEVICEDATA(_this); - DFBInputEvent evt; - static last_x = 0, last_y = 0; - - while (devdata->eventbuffer->GetEvent(devdata->eventbuffer, - DFB_EVENT(&evt)) == DFB_OK) { - SDL_keysym keysym; - DFBInputDeviceModifierMask mod; - - if (evt.clazz = DFEC_INPUT) { - if (evt.flags & DIEF_MODIFIERS) - mod = evt.modifiers; - else - mod = 0; - - switch (evt.type) { - case DIET_BUTTONPRESS: - posted += - SDL_PrivateMouseButton(SDL_PRESSED, - DirectFB_TranslateButton - (evt.button), 0, 0); - break; - case DIET_BUTTONRELEASE: - posted += - SDL_PrivateMouseButton(SDL_RELEASED, - DirectFB_TranslateButton - (evt.button), 0, 0); - break; - case DIET_KEYPRESS: - posted += - SDL_PrivateKeyboard(SDL_PRESSED, - DirectFB_TranslateKey - (evt.key_id, evt.key_symbol, - mod, &keysym)); - break; - case DIET_KEYRELEASE: - posted += - SDL_PrivateKeyboard(SDL_RELEASED, - DirectFB_TranslateKey - (evt.key_id, evt.key_symbol, - mod, &keysym)); - break; - case DIET_AXISMOTION: - if (evt.flags & DIEF_AXISREL) { - if (evt.axis == DIAI_X) - posted += - SDL_PrivateMouseMotion(0, 1, evt.axisrel, 0); - else if (evt.axis == DIAI_Y) - posted += - SDL_PrivateMouseMotion(0, 1, 0, evt.axisrel); - } else if (evt.flags & DIEF_AXISABS) { - if (evt.axis == DIAI_X) - last_x = evt.axisabs; - else if (evt.axis == DIAI_Y) - last_y = evt.axisabs; - posted += SDL_PrivateMouseMotion(0, 0, last_x, last_y); - } - break; - default: - ; - } - } - } -} -#endif - +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_events.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_events.h index 641313667..42d1e95bf 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_events.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_events.h @@ -1,30 +1,32 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" -#include "SDL_DirectFB_video.h" +#ifndef _SDL_DirectFB_events_h +#define _SDL_DirectFB_events_h + +#include "../SDL_sysvideo.h" /* Functions to be exported */ extern void DirectFB_InitKeyboard(_THIS); extern void DirectFB_QuitKeyboard(_THIS); extern void DirectFB_PumpEventsWindow(_THIS); -extern SDLKey DirectFB_GetLayoutKey(_THIS, SDLKey physicalKey); + +#endif diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_modes.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_modes.c index bb336c7cd..e56e413f6 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_modes.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_modes.c @@ -1,31 +1,33 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DIRECTFB + #include "SDL_DirectFB_video.h" +#include "SDL_DirectFB_modes.h" #define DFB_MAX_MODES 200 -struct scn_callback_t +struct screen_callback_t { int numscreens; DFBScreenID screenid[DFB_MAX_SCREENS]; @@ -40,103 +42,6 @@ struct modes_callback_t SDL_DisplayMode *modelist; }; -static const struct { - DFBSurfacePixelFormat dfb; - Uint32 sdl; -} pixelformat_tab[] = -{ - { DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 }, /* 8 bit LUT (8 bit color and alpha lookup from palette) */ - { DSPF_RGB332, SDL_PIXELFORMAT_RGB332 }, /* 8 bit RGB (1 byte, red 3@5, green 3@2, blue 2@0) */ - { DSPF_ARGB4444, SDL_PIXELFORMAT_ARGB4444 }, /* 16 bit ARGB (2 byte, alpha 4@12, red 4@8, green 4@4, blue 4@0) */ - { DSPF_ARGB1555, SDL_PIXELFORMAT_ARGB1555 }, /* 16 bit ARGB (2 byte, alpha 1@15, red 5@10, green 5@5, blue 5@0) */ - { DSPF_RGB16, SDL_PIXELFORMAT_RGB565 }, /* 16 bit RGB (2 byte, red 5@11, green 6@5, blue 5@0) */ - { DSPF_RGB24, SDL_PIXELFORMAT_RGB24 }, /* 24 bit RGB (3 byte, red 8@16, green 8@8, blue 8@0) */ - { DSPF_RGB32, SDL_PIXELFORMAT_RGB888 }, /* 24 bit RGB (4 byte, nothing@24, red 8@16, green 8@8, blue 8@0) */ - { DSPF_ARGB, SDL_PIXELFORMAT_ARGB8888 }, /* 32 bit ARGB (4 byte, alpha 8@24, red 8@16, green 8@8, blue 8@0) */ - { DSPF_RGB444, SDL_PIXELFORMAT_RGB444 }, /* 16 bit RGB (2 byte, nothing @12, red 4@8, green 4@4, blue 4@0) */ - { DSPF_YV12, SDL_PIXELFORMAT_YV12 }, /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size V/U planes) */ - { DSPF_I420,SDL_PIXELFORMAT_IYUV }, /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size U/V planes) */ - { DSPF_YUY2, SDL_PIXELFORMAT_YUY2 }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */ - { DSPF_UYVY, SDL_PIXELFORMAT_UYVY }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */ - { DSPF_RGB555, SDL_PIXELFORMAT_RGB555 }, /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */ - -#if (DFB_VERSION_ATLEAST(1,2,0)) - { DSPF_BGR555, SDL_PIXELFORMAT_BGR555 }, /* 16 bit BGR (2 byte, nothing @15, blue 5@10, green 5@5, red 5@0) */ -#else - { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR555 }, -#endif - - /* Pfff ... nonmatching formats follow */ - - { DSPF_ALUT44, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit ALUT (1 byte, alpha 4@4, color lookup 4@0) */ - { DSPF_A8, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */ - { DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */ - { DSPF_A1, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */ - { DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */ - { DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */ - { DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */ - { DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */ - { DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */ - { DSPF_A4, SDL_PIXELFORMAT_UNKNOWN }, /* 4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */ - { DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */ - { DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */ - { DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */ - { DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN }, /* 2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */ - -#if (DFB_VERSION_ATLEAST(1,3,0)) - { DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */ -#endif - -#if (DFB_VERSION_ATLEAST(1,4,0)) - { DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */ - { DSPF_YUV444P, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit full YUV planar (8 bit Y plane followed by an 8 bit Cb and an 8 bit Cr plane) */ - { DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */ - { DSPF_AVYU, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AVYU 4:4:4 (4 byte, alpha 8@24, Cr 8@16, Y 8@8, Cb 8@0) */ - { DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0) */ -#endif - - { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1MSB }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4MSB }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_RGBA8888 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR8888 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGRA8888 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_ARGB2101010 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR1555 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR565 }, - { DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU }, /**< Packed mode: Y0+V0+Y1+U0 (1 pla */ -}; - -static Uint32 -DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat) -{ - int i; - - for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++) - if (pixelformat_tab[i].dfb == pixelformat) - { - return pixelformat_tab[i].sdl; - } - return SDL_PIXELFORMAT_UNKNOWN; -} - -static DFBSurfacePixelFormat -SDLToDFBPixelFormat(Uint32 format) -{ - int i; - - for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++) - if (pixelformat_tab[i].sdl == format) - { - return pixelformat_tab[i].dfb; - } - return DSPF_UNKNOWN; -} - static DFBEnumerationResult EnumModesCallback(int width, int height, int bpp, void *data) { @@ -157,20 +62,20 @@ EnumModesCallback(int width, int height, int bpp, void *data) } static DFBEnumerationResult -cbScreens(DFBScreenID screen_id, DFBScreenDescription desc, +EnumScreensCallback(DFBScreenID screen_id, DFBScreenDescription desc, void *callbackdata) { - struct scn_callback_t *devdata = (struct scn_callback_t *) callbackdata; + struct screen_callback_t *devdata = (struct screen_callback_t *) callbackdata; devdata->screenid[devdata->numscreens++] = screen_id; return DFENUM_OK; } -DFBEnumerationResult -cbLayers(DFBDisplayLayerID layer_id, DFBDisplayLayerDescription desc, +static DFBEnumerationResult +EnumLayersCallback(DFBDisplayLayerID layer_id, DFBDisplayLayerDescription desc, void *callbackdata) { - struct scn_callback_t *devdata = (struct scn_callback_t *) callbackdata; + struct screen_callback_t *devdata = (struct screen_callback_t *) callbackdata; if (desc.caps & DLCAPS_SURFACE) { if ((desc.type & DLTF_GRAPHICS) && (desc.type & DLTF_VIDEO)) { @@ -195,7 +100,7 @@ CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, S DLSCL_ADMINISTRATIVE)); config.width = mode->w; config.height = mode->h; - config.pixelformat = SDLToDFBPixelFormat(mode->format); + config.pixelformat = DirectFB_SDLToDFBPixelFormat(mode->format); config.flags = DLCONF_WIDTH | DLCONF_HEIGHT | DLCONF_PIXELFORMAT; if (devdata->use_yuv_underlays) { config.flags |= DLCONF_OPTIONS; @@ -206,7 +111,10 @@ CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, S SDL_DFB_CHECKERR(data->layer->SetCooperativeLevel(data->layer, DLSCL_SHARED)); if (failed == 0) + { SDL_AddDisplayMode(display, mode); + SDL_DFB_LOG("Mode %d x %d Added\n", mode->w, mode->h); + } else SDL_DFB_ERR("Mode %d x %d not available: %x\n", mode->w, mode->h, failed); @@ -216,6 +124,26 @@ CheckSetDisplayMode(_THIS, SDL_VideoDisplay * display, DFB_DisplayData * data, S return; } + +void +DirectFB_SetContext(_THIS, SDL_Window *window) +{ +#if (DFB_VERSION_ATLEAST(1,0,0)) + /* FIXME: does not work on 1.0/1.2 with radeon driver + * the approach did work with the matrox driver + * This has simply no effect. + */ + + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; + + /* FIXME: should we handle the error */ + if (dispdata->vidIDinuse) + SDL_DFB_CHECK(dispdata->vidlayer->SwitchContext(dispdata->vidlayer, + DFB_TRUE)); +#endif +} + void DirectFB_InitModes(_THIS) { @@ -226,14 +154,14 @@ DirectFB_InitModes(_THIS) SDL_DisplayMode mode; DFBGraphicsDeviceDescription caps; DFBDisplayLayerConfig dlc; - struct scn_callback_t *screencbdata; + struct screen_callback_t *screencbdata; int tcw[DFB_MAX_SCREENS]; int tch[DFB_MAX_SCREENS]; int i; DFBResult ret; - SDL_DFB_CALLOC(screencbdata, 1, sizeof(*screencbdata)); + SDL_DFB_ALLOC_CLEAR(screencbdata, sizeof(*screencbdata)); screencbdata->numscreens = 0; @@ -242,7 +170,7 @@ DirectFB_InitModes(_THIS) screencbdata->vidlayer[i] = -1; } - SDL_DFB_CHECKERR(devdata->dfb->EnumScreens(devdata->dfb, &cbScreens, + SDL_DFB_CHECKERR(devdata->dfb->EnumScreens(devdata->dfb, &EnumScreensCallback, screencbdata)); for (i = 0; i < screencbdata->numscreens; i++) { @@ -253,9 +181,10 @@ DirectFB_InitModes(_THIS) [i], &screen)); screencbdata->aux = i; - SDL_DFB_CHECKERR(screen->EnumDisplayLayers(screen, &cbLayers, + SDL_DFB_CHECKERR(screen->EnumDisplayLayers(screen, &EnumLayersCallback, screencbdata)); screen->GetSize(screen, &tcw[i], &tch[i]); + screen->Release(screen); } @@ -263,10 +192,6 @@ DirectFB_InitModes(_THIS) devdata->dfb->GetDeviceDescription(devdata->dfb, &caps); - SDL_DFB_DEBUG("SDL directfb video driver - %s %s\n", __DATE__, __TIME__); - SDL_DFB_DEBUG("Using %s (%s) driver.\n", caps.name, caps.vendor); - SDL_DFB_DEBUG("Found %d screens\n", screencbdata->numscreens); - for (i = 0; i < screencbdata->numscreens; i++) { SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb, screencbdata->gralayer @@ -282,7 +207,7 @@ DirectFB_InitModes(_THIS) dlc.pixelformat = DSPF_ARGB; dlc.options = DLOP_ALPHACHANNEL; - ret = SDL_DFB_CHECK(layer->SetConfiguration(layer, &dlc)); + ret = layer->SetConfiguration(layer, &dlc); if (ret != DFB_OK) { /* try AiRGB if the previous failed */ dlc.pixelformat = DSPF_AiRGB; @@ -294,7 +219,7 @@ DirectFB_InitModes(_THIS) dlc.flags = DLCONF_ALL; SDL_DFB_CHECKERR(layer->GetConfiguration(layer, &dlc)); - mode.format = DFBToSDLPixelFormat(dlc.pixelformat); + mode.format = DirectFB_DFBToSDLPixelFormat(dlc.pixelformat); if (mode.format == SDL_PIXELFORMAT_UNKNOWN) { SDL_DFB_ERR("Unknown dfb pixelformat %x !\n", dlc.pixelformat); @@ -306,7 +231,7 @@ DirectFB_InitModes(_THIS) mode.refresh_rate = 0; mode.driverdata = NULL; - SDL_DFB_CALLOC(dispdata, 1, sizeof(*dispdata)); + SDL_DFB_ALLOC_CLEAR(dispdata, sizeof(*dispdata)); dispdata->layer = layer; dispdata->pixelformat = dlc.pixelformat; @@ -399,7 +324,7 @@ DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mod config.flags = DLCONF_WIDTH | DLCONF_HEIGHT; if (mode->format != SDL_PIXELFORMAT_UNKNOWN) { config.flags |= DLCONF_PIXELFORMAT; - config.pixelformat = SDLToDFBPixelFormat(mode->format); + config.pixelformat = DirectFB_SDLToDFBPixelFormat(mode->format); data->pixelformat = config.pixelformat; } config.width = mode->w; @@ -420,7 +345,6 @@ DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mod return -1; } - SDL_DFB_DEBUG("Trace\n"); config.flags &= ~fail; SDL_DFB_CHECKERR(data->layer->SetConfiguration(data->layer, &config)); #if (DFB_VERSION_ATLEAST(1,2,0)) @@ -454,7 +378,6 @@ DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mod void DirectFB_QuitModes(_THIS) { - //DFB_DeviceData *devdata = (DFB_DeviceData *) _this->driverdata; SDL_DisplayMode tmode; int i; @@ -462,11 +385,11 @@ DirectFB_QuitModes(_THIS) SDL_VideoDisplay *display = &_this->displays[i]; DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; - SDL_GetDesktopDisplayModeForDisplay(display, &tmode); + SDL_GetDesktopDisplayMode(i, &tmode); tmode.format = SDL_PIXELFORMAT_UNKNOWN; DirectFB_SetDisplayMode(_this, display, &tmode); - SDL_GetDesktopDisplayModeForDisplay(display, &tmode); + SDL_GetDesktopDisplayMode(i, &tmode); DirectFB_SetDisplayMode(_this, display, &tmode); if (dispdata->layer) { @@ -486,4 +409,6 @@ DirectFB_QuitModes(_THIS) } } +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_modes.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_modes.h index 6f5dbf9e6..bb59fa385 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_modes.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_modes.h @@ -1,49 +1,49 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" #ifndef _SDL_directfb_modes_h #define _SDL_directfb_modes_h -#include "SDL_DirectFB_video.h" +#include -#define SDL_DFB_DISPLAYDATA(dev, win) DFB_DisplayData *dispdata = ((win && dev) ? (DFB_DisplayData *) (win)->display->driverdata : NULL) +#include "../SDL_sysvideo.h" + +#define SDL_DFB_DISPLAYDATA(win) DFB_DisplayData *dispdata = ((win) ? (DFB_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata : NULL) typedef struct _DFB_DisplayData DFB_DisplayData; struct _DFB_DisplayData { - IDirectFBDisplayLayer *layer; - DFBSurfacePixelFormat pixelformat; + IDirectFBDisplayLayer *layer; + DFBSurfacePixelFormat pixelformat; /* FIXME: support for multiple video layer. * However, I do not know any card supporting * more than one */ - DFBDisplayLayerID vidID; - IDirectFBDisplayLayer *vidlayer; + DFBDisplayLayerID vidID; + IDirectFBDisplayLayer *vidlayer; - int vidIDinuse; + int vidIDinuse; - int cw; - int ch; + int cw; + int ch; }; @@ -52,6 +52,8 @@ extern void DirectFB_GetDisplayModes(_THIS, SDL_VideoDisplay * display); extern int DirectFB_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); extern void DirectFB_QuitModes(_THIS); +extern void DirectFB_SetContext(_THIS, SDL_Window *window); + #endif /* _SDL_directfb_modes_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_mouse.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_mouse.c index be0315b03..e83f43ae6 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_mouse.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_mouse.c @@ -1,40 +1,260 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DIRECTFB + +#include "SDL_assert.h" + #include "SDL_DirectFB_video.h" +#include "SDL_DirectFB_mouse.h" +#include "SDL_DirectFB_modes.h" +#include "SDL_DirectFB_window.h" #include "../SDL_sysvideo.h" #include "../../events/SDL_mouse_c.h" -#if USE_MULTI_API +static SDL_Cursor *DirectFB_CreateDefaultCursor(void); static SDL_Cursor *DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y); static int DirectFB_ShowCursor(SDL_Cursor * cursor); static void DirectFB_MoveCursor(SDL_Cursor * cursor); static void DirectFB_FreeCursor(SDL_Cursor * cursor); +static void DirectFB_WarpMouse(SDL_Window * window, int x, int y); +static void DirectFB_FreeMouse(SDL_Mouse * mouse); + +static const char *arrow[] = { + /* pixels */ + "X ", + "XX ", + "X.X ", + "X..X ", + "X...X ", + "X....X ", + "X.....X ", + "X......X ", + "X.......X ", + "X........X ", + "X.....XXXXX ", + "X..X..X ", + "X.X X..X ", + "XX X..X ", + "X X..X ", + " X..X ", + " X..X ", + " X..X ", + " XX ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", + " ", +}; + +static SDL_Cursor * +DirectFB_CreateDefaultCursor(void) +{ + SDL_VideoDevice *dev = SDL_GetVideoDevice(); + + SDL_DFB_DEVICEDATA(dev); + DFB_CursorData *curdata; + DFBResult ret; + DFBSurfaceDescription dsc; + SDL_Cursor *cursor; + Uint32 *dest; + Uint32 *p; + int pitch, i, j; + + SDL_DFB_ALLOC_CLEAR( cursor, sizeof(*cursor)); + SDL_DFB_ALLOC_CLEAR(curdata, sizeof(*curdata)); + + dsc.flags = + DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; + dsc.caps = DSCAPS_VIDEOONLY; + dsc.width = 32; + dsc.height = 32; + dsc.pixelformat = DSPF_ARGB; + + SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc, + &curdata->surf)); + curdata->hotx = 0; + curdata->hoty = 0; + cursor->driverdata = curdata; + + SDL_DFB_CHECKERR(curdata->surf->Lock(curdata->surf, DSLF_WRITE, + (void *) &dest, &pitch)); + + /* Relies on the fact that this is only called with ARGB surface. */ + for (i = 0; i < 32; i++) + { + for (j = 0; j < 32; j++) + { + switch (arrow[i][j]) + { + case ' ': dest[j] = 0x00000000; break; + case '.': dest[j] = 0xffffffff; break; + case 'X': dest[j] = 0xff000000; break; + } + } + dest += (pitch >> 2); + } + + curdata->surf->Unlock(curdata->surf); + return cursor; + error: + return NULL; +} + +/* Create a cursor from a surface */ +static SDL_Cursor * +DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + SDL_VideoDevice *dev = SDL_GetVideoDevice(); + + SDL_DFB_DEVICEDATA(dev); + DFB_CursorData *curdata; + DFBResult ret; + DFBSurfaceDescription dsc; + SDL_Cursor *cursor; + Uint32 *dest; + Uint32 *p; + int pitch, i; + + SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); + SDL_assert(surface->pitch == surface->w * 4); + + SDL_DFB_ALLOC_CLEAR( cursor, sizeof(*cursor)); + SDL_DFB_ALLOC_CLEAR(curdata, sizeof(*curdata)); + + dsc.flags = + DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; + dsc.caps = DSCAPS_VIDEOONLY; + dsc.width = surface->w; + dsc.height = surface->h; + dsc.pixelformat = DSPF_ARGB; + + SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc, + &curdata->surf)); + curdata->hotx = hot_x; + curdata->hoty = hot_y; + cursor->driverdata = curdata; + + SDL_DFB_CHECKERR(curdata->surf->Lock(curdata->surf, DSLF_WRITE, + (void *) &dest, &pitch)); + + p = surface->pixels; + for (i = 0; i < surface->h; i++) + memcpy((char *) dest + i * pitch, + (char *) p + i * surface->pitch, 4 * surface->w); + + curdata->surf->Unlock(curdata->surf); + return cursor; + error: + return NULL; +} + +/* Show the specified cursor, or hide if cursor is NULL */ +static int +DirectFB_ShowCursor(SDL_Cursor * cursor) +{ + SDL_DFB_CURSORDATA(cursor); + DFBResult ret; + SDL_Window *window; + + window = SDL_GetFocusWindow(); + if (!window) + return -1; + else { + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + + if (display) { + DFB_DisplayData *dispdata = + (DFB_DisplayData *) display->driverdata; + DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; + + if (cursor) + SDL_DFB_CHECKERR(windata->dfbwin-> + SetCursorShape(windata->dfbwin, + curdata->surf, curdata->hotx, + curdata->hoty)); + + SDL_DFB_CHECKERR(dispdata->layer-> + SetCooperativeLevel(dispdata->layer, + DLSCL_ADMINISTRATIVE)); + SDL_DFB_CHECKERR(dispdata->layer-> + SetCursorOpacity(dispdata->layer, + cursor ? 0xC0 : 0x00)); + SDL_DFB_CHECKERR(dispdata->layer-> + SetCooperativeLevel(dispdata->layer, + DLSCL_SHARED)); + } + } + + return 0; + error: + return -1; +} + +/* Free a window manager cursor */ +static void +DirectFB_FreeCursor(SDL_Cursor * cursor) +{ + SDL_DFB_CURSORDATA(cursor); + + SDL_DFB_RELEASE(curdata->surf); + SDL_DFB_FREE(cursor->driverdata); + SDL_DFB_FREE(cursor); +} + +/* Warp the mouse to (x,y) */ +static void +DirectFB_WarpMouse(SDL_Window * window, int x, int y) +{ + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; + DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; + DFBResult ret; + int cx, cy; + + SDL_DFB_CHECKERR(windata->dfbwin->GetPosition(windata->dfbwin, &cx, &cy)); + SDL_DFB_CHECKERR(dispdata->layer->WarpCursor(dispdata->layer, + cx + x + windata->client.x, + cy + y + windata->client.y)); + + error: + return; +} + +#if USE_MULTI_API + static void DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y); -static void DirectFB_FreeMouse(SDL_Mouse * mouse); static int id_mask; @@ -108,93 +328,6 @@ DirectFB_QuitMouse(_THIS) } } -/* Create a cursor from a surface */ -static SDL_Cursor * -DirectFB_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) -{ - SDL_VideoDevice *dev = SDL_GetVideoDevice(); - - SDL_DFB_DEVICEDATA(dev); - DFB_CursorData *curdata; - DFBResult ret; - DFBSurfaceDescription dsc; - SDL_Cursor *cursor; - Uint32 *dest; - Uint32 *p; - int pitch, i; - - SDL_DFB_CALLOC(cursor, 1, sizeof(*cursor)); - SDL_DFB_CALLOC(curdata, 1, sizeof(*curdata)); - - dsc.flags = - DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; - dsc.caps = DSCAPS_VIDEOONLY; - dsc.width = surface->w; - dsc.height = surface->h; - dsc.pixelformat = DSPF_ARGB; - - SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc, - &curdata->surf)); - curdata->hotx = hot_x; - curdata->hoty = hot_y; - cursor->driverdata = curdata; - - SDL_DFB_CHECKERR(curdata->surf->Lock(curdata->surf, DSLF_WRITE, - (void *) &dest, &pitch)); - - /* Relies on the fact that this is only called with ARGB surface. */ - p = surface->pixels; - for (i = 0; i < surface->h; i++) - memcpy((char *) dest + i * pitch, - (char *) p + i * surface->pitch, 4 * surface->w); - - curdata->surf->Unlock(curdata->surf); - return cursor; - error: - return NULL; -} - -/* Show the specified cursor, or hide if cursor is NULL */ -static int -DirectFB_ShowCursor(SDL_Cursor * cursor) -{ - SDL_DFB_CURSORDATA(cursor); - DFBResult ret; - SDL_Window *window; - - window = SDL_GetFocusWindow(); - if (!window) - return -1; - else { - SDL_VideoDisplay *display = window->display; - - if (display) { - DFB_DisplayData *dispdata = - (DFB_DisplayData *) display->driverdata; - DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; - - if (cursor) - SDL_DFB_CHECKERR(windata->window-> - SetCursorShape(windata->window, - curdata->surf, curdata->hotx, - curdata->hoty)); - - SDL_DFB_CHECKERR(dispdata->layer-> - SetCooperativeLevel(dispdata->layer, - DLSCL_ADMINISTRATIVE)); - SDL_DFB_CHECKERR(dispdata->layer-> - SetCursorOpacity(dispdata->layer, - cursor ? 0xC0 : 0x00)); - SDL_DFB_CHECKERR(dispdata->layer-> - SetCooperativeLevel(dispdata->layer, - DLSCL_SHARED)); - } - } - - return 0; - error: - return -1; -} /* This is called when a mouse motion event occurs */ static void @@ -203,28 +336,17 @@ DirectFB_MoveCursor(SDL_Cursor * cursor) } -/* Free a window manager cursor */ -static void -DirectFB_FreeCursor(SDL_Cursor * cursor) -{ - SDL_DFB_CURSORDATA(cursor); - - SDL_DFB_RELEASE(curdata->surf); - SDL_DFB_FREE(cursor->driverdata); - SDL_DFB_FREE(cursor); -} - /* Warp the mouse to (x,y) */ static void DirectFB_WarpMouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y) { - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; DFB_WindowData *windata = (DFB_WindowData *) window->driverdata; DFBResult ret; int cx, cy; - SDL_DFB_CHECKERR(windata->window->GetPosition(windata->window, &cx, &cy)); + SDL_DFB_CHECKERR(windata->dfbwin->GetPosition(windata->dfbwin, &cx, &cy)); SDL_DFB_CHECKERR(dispdata->layer->WarpCursor(dispdata->layer, cx + x + windata->client.x, cy + y + windata->client.y)); @@ -247,16 +369,26 @@ DirectFB_InitMouse(_THIS) { SDL_DFB_DEVICEDATA(_this); + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = DirectFB_CreateCursor; + mouse->ShowCursor = DirectFB_ShowCursor; + mouse->WarpMouse = DirectFB_WarpMouse; + mouse->FreeCursor = DirectFB_FreeCursor; + + SDL_SetDefaultCursor(DirectFB_CreateDefaultCursor()); + devdata->num_mice = 1; } void DirectFB_QuitMouse(_THIS) { - //SDL_DFB_DEVICEDATA(_this); } #endif +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_mouse.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_mouse.h index f04da53dc..86f96bbbf 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_mouse.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_mouse.h @@ -1,36 +1,37 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" #ifndef _SDL_DirectFB_mouse_h #define _SDL_DirectFB_mouse_h -typedef struct _DFB_CursorData DFB_CursorData; +#include +#include "../SDL_sysvideo.h" + +typedef struct _DFB_CursorData DFB_CursorData; struct _DFB_CursorData { IDirectFBSurface *surf; - int hotx; - int hoty; + int hotx; + int hoty; }; #define SDL_DFB_CURSORDATA(curs) DFB_CursorData *curdata = (DFB_CursorData *) ((curs) ? (curs)->driverdata : NULL) diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_opengl.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_opengl.c index 22c642275..7c5737c90 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_opengl.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_opengl.c @@ -1,30 +1,40 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with _this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DIRECTFB + #include "SDL_DirectFB_video.h" #if SDL_DIRECTFB_OPENGL +#include "SDL_DirectFB_opengl.h" +#include "SDL_DirectFB_window.h" + +#include +#include "SDL_loadso.h" +#endif + +#if SDL_DIRECTFB_OPENGL + struct SDL_GLDriverData { int gl_active; /* to stop switching drivers while we have a valid context */ @@ -177,7 +187,7 @@ DirectFB_GL_CreateContext(_THIS, SDL_Window * window) SDL_DFB_WINDOWDATA(window); DirectFB_GLContext *context; - SDL_DFB_CALLOC(context, 1, sizeof(DirectFB_GLContext)); + SDL_DFB_ALLOC_CLEAR(context, sizeof(DirectFB_GLContext)); SDL_DFB_CHECKERR(windata->surface->GetGL(windata->surface, &context->context)); @@ -345,4 +355,6 @@ DirectFB_GL_DestroyWindowContexts(_THIS, SDL_Window * window) #endif +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_opengl.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_opengl.h index 9757df42c..53188c37f 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_opengl.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_opengl.h @@ -1,40 +1,42 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" + #ifndef _SDL_directfb_opengl_h #define _SDL_directfb_opengl_h +#include "SDL_DirectFB_video.h" + #if SDL_DIRECTFB_OPENGL + #include "SDL_opengl.h" typedef struct _DirectFB_GLContext DirectFB_GLContext; struct _DirectFB_GLContext { - IDirectFBGL *context; - DirectFB_GLContext *next; + IDirectFBGL *context; + DirectFB_GLContext *next; - SDL_Window *sdl_window; - int is_locked; + SDL_Window *sdl_window; + int is_locked; }; /* OpenGL functions */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_render.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_render.c index 5320fc662..a2ca4be41 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_render.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_render.c @@ -1,43 +1,65 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - SDL1.3 implementation by couriersud@arcor.de - + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_DirectFB_video.h" -#include "SDL_DirectFB_render.h" -#include "../SDL_rect_c.h" -#include "../SDL_yuv_sw_c.h" +#if SDL_VIDEO_DRIVER_DIRECTFB +//#include "SDL_DirectFB_video.h" +#include "SDL_DirectFB_window.h" +#include "SDL_DirectFB_modes.h" + +#include "SDL_syswm.h" +#include "SDL_DirectFB_shape.h" + +#include "../SDL_sysvideo.h" +#include "../../render/SDL_sysrender.h" +//#include "../SDL_rect_c.h" +//#include "../SDL_yuv_sw_c.h" + +#ifndef DFB_VERSION_ATLEAST + +#define DFB_VERSIONNUM(X, Y, Z) \ + ((X)*1000 + (Y)*100 + (Z)) + +#define DFB_COMPILEDVERSION \ + DFB_VERSIONNUM(DIRECTFB_MAJOR_VERSION, DIRECTFB_MINOR_VERSION, DIRECTFB_MICRO_VERSION) + +#define DFB_VERSION_ATLEAST(X, Y, Z) \ + (DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z)) + +#define SDL_DFB_CHECK(x) x + +#endif /* the following is not yet tested ... */ #define USE_DISPLAY_PALETTE (0) + +#define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL) + + /* GDI renderer implementation */ static SDL_Renderer *DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags); -static int DirectFB_DisplayModeChanged(SDL_Renderer * renderer); -static int DirectFB_ActivateRenderer(SDL_Renderer * renderer); +static void DirectFB_ActivateRenderer(SDL_Renderer * renderer); static int DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); static int DirectFB_QueryTexturePixels(SDL_Renderer * renderer, @@ -65,7 +87,7 @@ static int DirectFB_UpdateTexture(SDL_Renderer * renderer, const void *pixels, int pitch); static int DirectFB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, + const SDL_Rect * rect, void **pixels, int *pitch); static void DirectFB_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); @@ -80,7 +102,7 @@ static int DirectFB_RenderDrawLines(SDL_Renderer * renderer, static int DirectFB_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count); static int DirectFB_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); + const SDL_Rect * rects, int count); static int DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, @@ -89,6 +111,14 @@ static void DirectFB_RenderPresent(SDL_Renderer * renderer); static void DirectFB_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); static void DirectFB_DestroyRenderer(SDL_Renderer * renderer); +static int DirectFB_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch); +static int DirectFB_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, const void * pixels, int pitch); +static int DirectFB_UpdateViewport(SDL_Renderer * renderer); + +static int PrepareDraw(SDL_Renderer * renderer); + #define SDL_DFB_WINDOWSURFACE(win) IDirectFBSurface *destsurf = ((DFB_WindowData *) ((win)->driverdata))->surface; @@ -96,32 +126,17 @@ SDL_RenderDriver DirectFB_RenderDriver = { DirectFB_CreateRenderer, { "directfb", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | - SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | + (SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_ACCELERATED), + /* (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | + (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST | - SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST), - 14, + SDL_SCALEMODE_SLOW | SDL_SCALEMODE_BEST),*/ + 0, { - SDL_PIXELFORMAT_INDEX4LSB, - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB332, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGB24, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_YUY2, - SDL_PIXELFORMAT_UYVY}, + /* formats filled in later */ + }, 0, 0} }; @@ -130,7 +145,6 @@ typedef struct { SDL_Window *window; DFBSurfaceFlipFlags flipflags; - int isyuvdirect; int size_changed; int lastBlendMode; DFBSurfaceBlittingFlags blitFlags; @@ -144,8 +158,10 @@ typedef struct void *pixels; int pitch; IDirectFBPalette *palette; - SDL_VideoDisplay *display; - SDL_DirtyRectList dirty; + int isDirty; + + SDL_VideoDisplay *display; /* only for yuv textures */ + #if (DFB_VERSION_ATLEAST(1,2,0)) DFBSurfaceRenderOptions render_options; #endif @@ -167,8 +183,12 @@ TextureHasAlpha(DirectFB_TextureData * data) /* Drawing primitive ? */ if (!data) return 0; + + return (DFB_PIXELFORMAT_HAS_ALPHA(DirectFB_SDLToDFBPixelFormat(data->format)) ? 1 : 0); +#if 0 switch (data->format) { case SDL_PIXELFORMAT_INDEX4LSB: + case SDL_PIXELFORMAT_INDEX4MSB: case SDL_PIXELFORMAT_ARGB4444: case SDL_PIXELFORMAT_ARGB1555: case SDL_PIXELFORMAT_ARGB8888: @@ -176,17 +196,36 @@ TextureHasAlpha(DirectFB_TextureData * data) case SDL_PIXELFORMAT_ABGR8888: case SDL_PIXELFORMAT_BGRA8888: case SDL_PIXELFORMAT_ARGB2101010: - return 1; + return 1; default: return 0; } +#endif +} + +static inline IDirectFBSurface *get_dfb_surface(SDL_Window *window) +{ + SDL_SysWMinfo wm_info; + SDL_VERSION(&wm_info.version); + SDL_GetWindowWMInfo(window, &wm_info); + + return wm_info.info.dfb.surface; +} + +static inline IDirectFBWindow *get_dfb_window(SDL_Window *window) +{ + SDL_SysWMinfo wm_info; + SDL_VERSION(&wm_info.version); + SDL_GetWindowWMInfo(window, &wm_info); + + return wm_info.info.dfb.window; } static void SetBlendMode(DirectFB_RenderData * data, int blendMode, DirectFB_TextureData * source) { - SDL_DFB_WINDOWSURFACE(data->window); + IDirectFBSurface *destsurf = get_dfb_surface(data->window); //FIXME: check for format change if (1 || data->lastBlendMode != blendMode) { @@ -198,12 +237,14 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode, SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ONE)); SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO)); break; +#if 0 case SDL_BLENDMODE_MASK: - data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; + data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; data->drawFlags = DSDRAW_BLEND; SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_SRCALPHA)); SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_INVSRCALPHA)); break; +#endif case SDL_BLENDMODE_BLEND: data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; data->drawFlags = DSDRAW_BLEND; @@ -225,24 +266,18 @@ SetBlendMode(DirectFB_RenderData * data, int blendMode, case SDL_BLENDMODE_MOD: data->blitFlags = DSBLIT_BLEND_ALPHACHANNEL; data->drawFlags = DSDRAW_BLEND; - SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR)); - SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO)); + //SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_DESTCOLOR)); + //SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_ZERO)); + //data->glBlendFunc(GL_ZERO, GL_SRC_COLOR); + SDL_DFB_CHECK(destsurf->SetSrcBlendFunction(destsurf, DSBF_ZERO)); + SDL_DFB_CHECK(destsurf->SetDstBlendFunction(destsurf, DSBF_SRCCOLOR)); + break; } data->lastBlendMode = blendMode; } } -void -DirectFB_AddRenderDriver(_THIS) -{ - int i; - - for (i = 0; i < _this->num_displays; ++i) { - SDL_AddRenderDriver(&_this->displays[i], &DirectFB_RenderDriver); - } -} - static int DisplayPaletteChanged(void *userdata, SDL_Palette * palette) { @@ -275,54 +310,91 @@ DisplayPaletteChanged(void *userdata, SDL_Palette * palette) return -1; } +static void +DirectFB_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) +{ + SDL_DFB_RENDERERDATA(renderer); + + if (event->event == SDL_WINDOWEVENT_SIZE_CHANGED) { + /* Rebind the context to the window area and update matrices */ + //SDL_CurrentContext = NULL; + //data->updateSize = SDL_TRUE; + renddata->size_changed = SDL_TRUE; + } +} + +int +DirectFB_RenderClear(SDL_Renderer * renderer) +{ + DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; + IDirectFBSurface *destsurf = get_dfb_surface(data->window); + + DirectFB_ActivateRenderer(renderer); + + PrepareDraw(renderer); + + destsurf->Clear(destsurf, renderer->r, renderer->g, renderer->b, renderer->a); + + + return 0; +} SDL_Renderer * DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) { - SDL_DFB_WINDOWDATA(window); - SDL_VideoDisplay *display = window->display; + IDirectFBSurface *winsurf = get_dfb_surface(window); + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_Renderer *renderer = NULL; DirectFB_RenderData *data = NULL; DFBSurfaceCapabilities scaps; - char *p; + //char *p; - SDL_DFB_CALLOC(renderer, 1, sizeof(*renderer)); - SDL_DFB_CALLOC(data, 1, sizeof(*data)); + SDL_DFB_ALLOC_CLEAR(renderer, sizeof(*renderer)); + SDL_DFB_ALLOC_CLEAR(data, sizeof(*data)); - renderer->DisplayModeChanged = DirectFB_DisplayModeChanged; - renderer->ActivateRenderer = DirectFB_ActivateRenderer; + renderer->WindowEvent = DirectFB_WindowEvent; renderer->CreateTexture = DirectFB_CreateTexture; - renderer->QueryTexturePixels = DirectFB_QueryTexturePixels; - renderer->SetTexturePalette = DirectFB_SetTexturePalette; - renderer->GetTexturePalette = DirectFB_GetTexturePalette; renderer->SetTextureAlphaMod = DirectFB_SetTextureAlphaMod; renderer->SetTextureColorMod = DirectFB_SetTextureColorMod; renderer->SetTextureBlendMode = DirectFB_SetTextureBlendMode; - renderer->SetTextureScaleMode = DirectFB_SetTextureScaleMode; renderer->UpdateTexture = DirectFB_UpdateTexture; renderer->LockTexture = DirectFB_LockTexture; + renderer->RenderClear = DirectFB_RenderClear; renderer->UnlockTexture = DirectFB_UnlockTexture; - renderer->DirtyTexture = DirectFB_DirtyTexture; renderer->RenderDrawPoints = DirectFB_RenderDrawPoints; renderer->RenderDrawLines = DirectFB_RenderDrawLines; /* SetDrawColor - no needed */ - renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode; renderer->RenderFillRects = DirectFB_RenderFillRects; - renderer->RenderDrawRects = DirectFB_RenderDrawRects; + /* RenderDrawEllipse - no reference implementation yet */ /* RenderFillEllipse - no reference implementation yet */ renderer->RenderCopy = DirectFB_RenderCopy; renderer->RenderPresent = DirectFB_RenderPresent; - /* RenderReadPixels is difficult to implement */ - /* RenderWritePixels is difficult to implement */ + + /* FIXME: Yet to be tested */ + renderer->RenderReadPixels = DirectFB_RenderReadPixels; + //renderer->RenderWritePixels = DirectFB_RenderWritePixels; + renderer->DestroyTexture = DirectFB_DestroyTexture; renderer->DestroyRenderer = DirectFB_DestroyRenderer; + renderer->UpdateViewport = DirectFB_UpdateViewport; + +#if 0 + renderer->QueryTexturePixels = DirectFB_QueryTexturePixels; + renderer->SetTexturePalette = DirectFB_SetTexturePalette; + renderer->GetTexturePalette = DirectFB_GetTexturePalette; + renderer->SetTextureScaleMode = DirectFB_SetTextureScaleMode; + renderer->DirtyTexture = DirectFB_DirtyTexture; + renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode; + renderer->RenderDrawRects = DirectFB_RenderDrawRects; +#endif + renderer->info = DirectFB_RenderDriver.info; renderer->window = window; /* SDL window */ renderer->driverdata = data; renderer->info.flags = - SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD; + SDL_RENDERER_ACCELERATED; data->window = window; @@ -334,24 +406,25 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) } else data->flipflags |= DSFLIP_ONSYNC; - SDL_DFB_CHECKERR(windata->surface-> - GetCapabilities(windata->surface, &scaps)); + SDL_DFB_CHECKERR(winsurf->GetCapabilities(winsurf, &scaps)); + +#if 0 if (scaps & DSCAPS_DOUBLE) renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; else if (scaps & DSCAPS_TRIPLE) renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; else renderer->info.flags |= SDL_RENDERER_SINGLEBUFFER; +#endif - data->isyuvdirect = 0; /* default is off! */ - p = SDL_getenv(DFBENV_USE_YUV_DIRECT); - if (p) - data->isyuvdirect = atoi(p); + DirectFB_SetSupportedPixelFormats(&renderer->info); +#if 0 /* Set up a palette watch on the display palette */ - if (display->palette) { + if (display-> palette) { SDL_AddPaletteWatch(display->palette, DisplayPaletteChanged, data); } +#endif return renderer; @@ -361,102 +434,34 @@ DirectFB_CreateRenderer(SDL_Window * window, Uint32 flags) return NULL; } -static DFBSurfacePixelFormat -SDLToDFBPixelFormat(Uint32 format) -{ - switch (format) { - case SDL_PIXELFORMAT_INDEX4LSB: - return DSPF_ALUT44; - case SDL_PIXELFORMAT_INDEX8: - return DSPF_LUT8; - case SDL_PIXELFORMAT_RGB332: - return DSPF_RGB332; - case SDL_PIXELFORMAT_RGB555: - return DSPF_ARGB1555; - case SDL_PIXELFORMAT_ARGB4444: - return DSPF_ARGB4444; - case SDL_PIXELFORMAT_ARGB1555: - return DSPF_ARGB1555; - case SDL_PIXELFORMAT_RGB565: - return DSPF_RGB16; - case SDL_PIXELFORMAT_RGB24: - return DSPF_RGB24; - case SDL_PIXELFORMAT_RGB888: - return DSPF_RGB32; - case SDL_PIXELFORMAT_ARGB8888: - return DSPF_ARGB; - case SDL_PIXELFORMAT_YV12: - return DSPF_YV12; /* Planar mode: Y + V + U (3 planes) */ - case SDL_PIXELFORMAT_IYUV: - return DSPF_I420; /* Planar mode: Y + U + V (3 planes) */ - case SDL_PIXELFORMAT_YUY2: - return DSPF_YUY2; /* Packed mode: Y0+U0+Y1+V0 (1 plane) */ - case SDL_PIXELFORMAT_UYVY: - return DSPF_UYVY; /* Packed mode: U0+Y0+V0+Y1 (1 plane) */ - case SDL_PIXELFORMAT_YVYU: - return DSPF_UNKNOWN; /* Packed mode: Y0+V0+Y1+U0 (1 plane) */ - case SDL_PIXELFORMAT_INDEX1LSB: - return DSPF_UNKNOWN; - case SDL_PIXELFORMAT_INDEX1MSB: - return DSPF_UNKNOWN; - case SDL_PIXELFORMAT_INDEX4MSB: - return DSPF_UNKNOWN; -#if (DFB_VERSION_ATLEAST(1,2,0)) - case SDL_PIXELFORMAT_RGB444: - return DSPF_RGB444; -#endif - case SDL_PIXELFORMAT_BGR24: - return DSPF_UNKNOWN; - case SDL_PIXELFORMAT_BGR888: - return DSPF_UNKNOWN; - case SDL_PIXELFORMAT_RGBA8888: - return DSPF_UNKNOWN; - case SDL_PIXELFORMAT_ABGR8888: - return DSPF_UNKNOWN; - case SDL_PIXELFORMAT_BGRA8888: - return DSPF_UNKNOWN; - case SDL_PIXELFORMAT_ARGB2101010: - return DSPF_UNKNOWN; - default: - return DSPF_UNKNOWN; - } -} - -static int +static void DirectFB_ActivateRenderer(SDL_Renderer * renderer) { + SDL_DFB_RENDERERDATA(renderer); SDL_Window *window = renderer->window; SDL_DFB_WINDOWDATA(window); - if (renddata->size_changed || windata->wm_needs_redraw) { -// DirectFB_AdjustWindowSurface(window); + if (renddata->size_changed /*|| windata->wm_needs_redraw*/) { + //DirectFB_AdjustWindowSurface(window); + renddata->size_changed = SDL_FALSE; } - return 0; } -static int -DirectFB_DisplayModeChanged(SDL_Renderer * renderer) -{ - SDL_DFB_RENDERERDATA(renderer); - - renddata->size_changed = SDL_TRUE; - return 0; -} static int DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture) { - SDL_DFB_RENDERERDATA(renderer); + //SDL_DFB_RENDERERDATA(renderer); SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DFB_DEVICEDATA(display->device); DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; DirectFB_TextureData *data = texture->driverdata; DFBDisplayLayerConfig layconf; DFBResult ret; - if (renddata->isyuvdirect && (dispdata->vidID >= 0) + if (devdata->use_yuv_direct && (dispdata->vidID >= 0) && (!dispdata->vidIDinuse) && SDL_ISPIXELFORMAT_FOURCC(data->format)) { layconf.flags = @@ -464,7 +469,7 @@ DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture) DLCONF_SURFACE_CAPS; layconf.width = texture->w; layconf.height = texture->h; - layconf.pixelformat = SDLToDFBPixelFormat(data->format); + layconf.pixelformat = DirectFB_SDLToDFBPixelFormat(data->format); layconf.surface_caps = DSCAPS_VIDEOONLY | DSCAPS_DOUBLE; SDL_DFB_CHECKERR(devdata->dfb->GetDisplayLayer(devdata->dfb, @@ -475,7 +480,7 @@ DirectFB_AcquireVidLayer(SDL_Renderer * renderer, SDL_Texture * texture) DLSCL_EXCLUSIVE)); if (devdata->use_yuv_underlays) { - ret = SDL_DFB_CHECK(dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1)); + ret = dispdata->vidlayer->SetLevel(dispdata->vidlayer, -1); if (ret != DFB_OK) SDL_DFB_DEBUG("Underlay Setlevel not supported\n"); } @@ -505,17 +510,19 @@ static int DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_DFB_DEVICEDATA(display->device); DirectFB_TextureData *data; DFBSurfaceDescription dsc; DFBSurfacePixelFormat pixelformat; - SDL_DFB_CALLOC(data, 1, sizeof(*data)); + DirectFB_ActivateRenderer(renderer); + + SDL_DFB_ALLOC_CLEAR(data, sizeof(*data)); texture->driverdata = data; /* find the right pixelformat */ - pixelformat = SDLToDFBPixelFormat(texture->format); + pixelformat = DirectFB_SDLToDFBPixelFormat(texture->format); if (pixelformat == DSPF_UNKNOWN) { SDL_SetError("Unknown pixel format %d\n", data->format); goto error; @@ -530,6 +537,12 @@ DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; dsc.width = texture->w; dsc.height = texture->h; + if(texture->format == SDL_PIXELFORMAT_YV12 || + texture->format == SDL_PIXELFORMAT_IYUV) { + /* dfb has problems with odd sizes -make them even internally */ + dsc.width += (dsc.width % 2); + dsc.height += (dsc.height % 2); + } /* <1.2 Never use DSCAPS_VIDEOONLY here. It kills performance * No DSCAPS_SYSTEMONLY either - let dfb decide * 1.2: DSCAPS_SYSTEMONLY boosts performance by factor ~8 @@ -551,22 +564,31 @@ DirectFB_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) &data->surface)); if (SDL_ISPIXELFORMAT_INDEXED(data->format) && !SDL_ISPIXELFORMAT_FOURCC(data->format)) { - SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface, - &data->palette)); +#if 1 + SDL_DFB_CHECKERR(data->surface->GetPalette(data->surface, &data->palette)); +#else + /* DFB has issues with blitting LUT8 surfaces. + * Creating a new palette does not help. + */ + DFBPaletteDescription pal_desc; + pal_desc.flags = DPDESC_SIZE; // | DPDESC_ENTRIES + pal_desc.size = 256; + SDL_DFB_CHECKERR(devdata->dfb->CreatePalette(devdata->dfb, &pal_desc,&data->palette)); + SDL_DFB_CHECKERR(data->surface->SetPalette(data->surface, data->palette)); +#endif } } #if (DFB_VERSION_ATLEAST(1,2,0)) data->render_options = DSRO_NONE; #endif - if (texture->access == SDL_TEXTUREACCESS_STREAMING) { /* 3 plane YUVs return 1 bpp, but we need more space for other planes */ if(texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) { - SDL_DFB_CALLOC(data->pixels, 1, (texture->h * data->pitch * 3 + texture->h * data->pitch * 3 % 2) / 2); + SDL_DFB_ALLOC_CLEAR(data->pixels, (texture->h * data->pitch + ((texture->h + texture->h % 2) * (data->pitch + data->pitch % 2) * 2) / 4)); } else { - SDL_DFB_CALLOC(data->pixels, 1, texture->h * data->pitch); + SDL_DFB_ALLOC_CLEAR(data->pixels, texture->h * data->pitch); } } @@ -602,21 +624,22 @@ DirectFB_SetTexturePalette(SDL_Renderer * renderer, int ncolors) { DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata; - if (SDL_ISPIXELFORMAT_INDEXED(data->format) && !SDL_ISPIXELFORMAT_FOURCC(data->format)) { DFBColor entries[256]; int i; + if (ncolors > 256) + ncolors = 256; + for (i = 0; i < ncolors; ++i) { entries[i].r = colors[i].r; entries[i].g = colors[i].g; entries[i].b = colors[i].b; - entries[i].a = 0xFF; + entries[i].a = 0xff; } SDL_DFB_CHECKERR(data-> - palette->SetEntries(data->palette, entries, ncolors, - firstcolor)); + palette->SetEntries(data->palette, entries, ncolors, firstcolor)); return 0; } else { SDL_SetError("YUV textures don't have a palette"); @@ -674,7 +697,7 @@ DirectFB_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) { switch (texture->blendMode) { case SDL_BLENDMODE_NONE: - case SDL_BLENDMODE_MASK: + //case SDL_BLENDMODE_MASK: case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: @@ -691,7 +714,7 @@ DirectFB_SetDrawBlendMode(SDL_Renderer * renderer) { switch (renderer->blendMode) { case SDL_BLENDMODE_NONE: - case SDL_BLENDMODE_MASK: + //case SDL_BLENDMODE_MASK: case SDL_BLENDMODE_BLEND: case SDL_BLENDMODE_ADD: case SDL_BLENDMODE_MOD: @@ -703,6 +726,7 @@ DirectFB_SetDrawBlendMode(SDL_Renderer * renderer) } } +#if 0 static int DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) { @@ -731,6 +755,7 @@ DirectFB_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) #endif return 0; } +#endif static int DirectFB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, @@ -742,9 +767,16 @@ DirectFB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, Uint8 *src, *dst; int row; size_t length; - int bpp = DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format)); + int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format)); // FIXME: SDL_BYTESPERPIXEL(texture->format) broken for yuv yv12 3 planes + DirectFB_ActivateRenderer(renderer); + + if ((texture->format == SDL_PIXELFORMAT_YV12) || + (texture->format == SDL_PIXELFORMAT_IYUV)) { + bpp = 1; + } + SDL_DFB_CHECKERR(data->surface->Lock(data->surface, DSLF_WRITE | DSLF_READ, ((void **) &dpixels), &dpitch)); @@ -757,24 +789,25 @@ DirectFB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, dst += dpitch; } /* copy other planes for 3 plane formats */ - if (texture->format == SDL_PIXELFORMAT_YV12 || - texture->format == SDL_PIXELFORMAT_IYUV) { + if ((texture->format == SDL_PIXELFORMAT_YV12) || + (texture->format == SDL_PIXELFORMAT_IYUV)) { src = (Uint8 *) pixels + texture->h * pitch; dst = (Uint8 *) dpixels + texture->h * dpitch + rect->y * dpitch / 4 + rect->x * bpp / 2; - for (row = 0; row < rect->h / 2; ++row) { + for (row = 0; row < rect->h / 2 + (rect->h & 1); ++row) { SDL_memcpy(dst, src, length / 2); src += pitch / 2; dst += dpitch / 2; } src = (Uint8 *) pixels + texture->h * pitch + texture->h * pitch / 4; dst = (Uint8 *) dpixels + texture->h * dpitch + texture->h * dpitch / 4 + rect->y * dpitch / 4 + rect->x * bpp / 2; - for (row = 0; row < rect->h / 2; ++row) { + for (row = 0; row < rect->h / 2 + (rect->h & 1); ++row) { SDL_memcpy(dst, src, length / 2); src += pitch / 2; dst += dpitch / 2; } } SDL_DFB_CHECKERR(data->surface->Unlock(data->surface)); + data->isDirty = 0; return 0; error: return 1; @@ -783,15 +816,18 @@ DirectFB_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, static int DirectFB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch) + const SDL_Rect * rect, void **pixels, int *pitch) { DirectFB_TextureData *texturedata = (DirectFB_TextureData *) texture->driverdata; + DirectFB_ActivateRenderer(renderer); + +#if 0 if (markDirty) { SDL_AddDirtyRect(&texturedata->dirty, rect); } +#endif if (texturedata->display) { void *fdata; @@ -806,8 +842,9 @@ DirectFB_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, *pixels = (void *) ((Uint8 *) texturedata->pixels + rect->y * texturedata->pitch + - rect->x * DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format))); + rect->x * DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format))); *pitch = texturedata->pitch; + texturedata->isDirty = 1; } return 0; @@ -821,12 +858,15 @@ DirectFB_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) DirectFB_TextureData *texturedata = (DirectFB_TextureData *) texture->driverdata; + DirectFB_ActivateRenderer(renderer); + if (texturedata->display) { SDL_DFB_CHECK(texturedata->surface->Unlock(texturedata->surface)); texturedata->pixels = NULL; } } +#if 0 static void DirectFB_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, const SDL_Rect * rects) @@ -838,12 +878,13 @@ DirectFB_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, SDL_AddDirtyRect(&data->dirty, &rects[i]); } } +#endif static int PrepareDraw(SDL_Renderer * renderer) { DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; - SDL_DFB_WINDOWSURFACE(data->window); + IDirectFBSurface *destsurf = get_dfb_surface(data->window); Uint8 r, g, b, a; @@ -857,7 +898,7 @@ PrepareDraw(SDL_Renderer * renderer) switch (renderer->blendMode) { case SDL_BLENDMODE_NONE: - case SDL_BLENDMODE_MASK: + //case SDL_BLENDMODE_MASK: case SDL_BLENDMODE_BLEND: break; case SDL_BLENDMODE_ADD: @@ -879,9 +920,11 @@ static int DirectFB_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, int count) { DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; - SDL_DFB_WINDOWSURFACE(data->window); + IDirectFBSurface *destsurf = get_dfb_surface(data->window); int i; + DirectFB_ActivateRenderer(renderer); + PrepareDraw(renderer); for (i=0; i < count; i++) SDL_DFB_CHECKERR(destsurf->DrawLine(destsurf, points[i].x, points[i].y, points[i].x, points[i].y)); @@ -894,9 +937,11 @@ static int DirectFB_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, int count) { DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; - SDL_DFB_WINDOWSURFACE(data->window); + IDirectFBSurface *destsurf = get_dfb_surface(data->window); int i; + DirectFB_ActivateRenderer(renderer); + PrepareDraw(renderer); /* Use antialiasing when available */ #if (DFB_VERSION_ATLEAST(1,2,0)) @@ -915,9 +960,11 @@ static int DirectFB_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) { DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; - SDL_DFB_WINDOWSURFACE(data->window); + IDirectFBSurface *destsurf = get_dfb_surface(data->window); int i; + DirectFB_ActivateRenderer(renderer); + PrepareDraw(renderer); for (i=0; idriverdata; - SDL_DFB_WINDOWSURFACE(data->window); + IDirectFBSurface *destsurf = get_dfb_surface(data->window); int i; + DirectFB_ActivateRenderer(renderer); + PrepareDraw(renderer); for (i=0; iFillRectangle(destsurf, rects[i]->x, rects[i]->y, - rects[i]->w, rects[i]->h)); + SDL_DFB_CHECKERR(destsurf->FillRectangle(destsurf, rects[i].x, rects[i].y, + rects[i].w, rects[i].h)); return 0; error: @@ -952,14 +1001,17 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * srcrect, const SDL_Rect * dstrect) { DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; - SDL_DFB_WINDOWSURFACE(data->window); + IDirectFBSurface *destsurf = get_dfb_surface(data->window); DirectFB_TextureData *texturedata = (DirectFB_TextureData *) texture->driverdata; - Uint8 alpha = 0xFF; + Uint8 alpha, r, g, b; + + DirectFB_ActivateRenderer(renderer); if (texturedata->display) { int px, py; SDL_Window *window = renderer->window; + IDirectFBWindow *dfbwin = get_dfb_window(window); SDL_DFB_WINDOWDATA(window); SDL_VideoDisplay *display = texturedata->display; DFB_DisplayData *dispdata = (DFB_DisplayData *) display->driverdata; @@ -969,7 +1021,7 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, srcrect->x, srcrect->y, srcrect->w, srcrect->h)); - SDL_DFB_CHECK(windata->window->GetPosition(windata->window, &px, &py)); + dfbwin->GetPosition(dfbwin, &px, &py); px += windata->client.x; py += windata->client.y; SDL_DFB_CHECKERR(dispdata-> @@ -982,10 +1034,11 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, DFBRectangle sr, dr; DFBSurfaceBlittingFlags flags = 0; +#if 0 if (texturedata->dirty.list) { SDL_DirtyRect *dirty; void *pixels; - int bpp = DFB_BYTES_PER_PIXEL(SDLToDFBPixelFormat(texture->format)); + int bpp = DFB_BYTES_PER_PIXEL(DirectFB_SDLToDFBPixelFormat(texture->format)); int pitch = texturedata->pitch; for (dirty = texturedata->dirty.list; dirty; dirty = dirty->next) { @@ -994,38 +1047,43 @@ DirectFB_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, (void *) ((Uint8 *) texturedata->pixels + rect->y * pitch + rect->x * bpp); DirectFB_UpdateTexture(renderer, texture, rect, - texturedata->pixels, + pixels, texturedata->pitch); } SDL_ClearDirtyRects(&texturedata->dirty); } +#endif + if (texturedata->isDirty) + { + SDL_Rect rect; + + rect.x = 0; + rect.y = 0; + rect.w = texture->w; + rect.h = texture->h; + + DirectFB_UpdateTexture(renderer, texture, &rect, texturedata->pixels, texturedata->pitch); + } SDLtoDFBRect(srcrect, &sr); SDLtoDFBRect(dstrect, &dr); - SDL_DFB_CHECKERR(destsurf-> - SetColor(destsurf, 0xFF, 0xFF, 0xFF, 0xFF)); - if (texture-> - modMode & (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA)) - { - if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { - alpha = texture->a; - SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, - 0xFF, alpha)); - } - if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { + alpha = r = g = b = 0xff; + if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA){ + alpha = texture->a; + flags |= DSBLIT_BLEND_COLORALPHA; + } - SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, - texture->r, - texture->g, - texture->b, alpha)); - flags |= DSBLIT_COLORIZE; - } - if (alpha < 0xFF) - flags |= DSBLIT_SRC_PREMULTCOLOR; - } else - SDL_DFB_CHECKERR(destsurf->SetColor(destsurf, 0xFF, 0xFF, - 0xFF, 0xFF)); + if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { + r = texture->r; + g = texture->g; + b = texture->b; + flags |= DSBLIT_COLORIZE; + } + SDL_DFB_CHECKERR(destsurf-> + SetColor(destsurf, r, g, b, alpha)); + + // ???? flags |= DSBLIT_SRC_PREMULTCOLOR; SetBlendMode(data, texture->blendMode, texturedata); @@ -1059,13 +1117,27 @@ DirectFB_RenderPresent(SDL_Renderer * renderer) DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; SDL_Window *window = renderer->window; SDL_DFB_WINDOWDATA(window); + SDL_ShapeData *shape_data = (window->shaper ? window->shaper->driverdata : NULL); - DFBRectangle sr; + DirectFB_ActivateRenderer(renderer); - sr.x = 0; - sr.y = 0; - sr.w = window->w; - sr.h = window->h; + if (shape_data && shape_data->surface) { + /* saturate the window surface alpha channel */ + SDL_DFB_CHECK(windata->window_surface->SetSrcBlendFunction(windata->window_surface, DSBF_ONE)); + SDL_DFB_CHECK(windata->window_surface->SetDstBlendFunction(windata->window_surface, DSBF_ONE)); + SDL_DFB_CHECK(windata->window_surface->SetDrawingFlags(windata->window_surface, DSDRAW_BLEND)); + SDL_DFB_CHECK(windata->window_surface->SetColor(windata->window_surface, 0, 0, 0, 0xff)); + SDL_DFB_CHECK(windata->window_surface->FillRectangle(windata->window_surface, 0,0, windata->size.w, windata->size.h)); + + /* blit the mask */ + SDL_DFB_CHECK(windata->surface->SetSrcBlendFunction(windata->surface, DSBF_DESTCOLOR)); + SDL_DFB_CHECK(windata->surface->SetDstBlendFunction(windata->surface, DSBF_ZERO)); + SDL_DFB_CHECK(windata->surface->SetBlittingFlags(windata->surface, DSBLIT_BLEND_ALPHACHANNEL)); +#if (DFB_VERSION_ATLEAST(1,2,0)) + SDL_DFB_CHECK(windata->surface->SetRenderOptions(windata->surface, DSRO_NONE)); +#endif + SDL_DFB_CHECK(windata->surface->Blit(windata->surface, shape_data->surface, NULL, 0, 0)); + } /* Send the data to the display */ SDL_DFB_CHECK(windata->window_surface->Flip(windata->window_surface, NULL, @@ -1077,9 +1149,12 @@ DirectFB_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) { DirectFB_TextureData *data = (DirectFB_TextureData *) texture->driverdata; + DirectFB_ActivateRenderer(renderer); + if (!data) { return; } + //SDL_FreeDirtyRects(&data->dirty); SDL_DFB_RELEASE(data->palette); SDL_DFB_RELEASE(data->surface); if (data->display) { @@ -1091,7 +1166,6 @@ DirectFB_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) DLSCL_ADMINISTRATIVE)); SDL_DFB_RELEASE(dispdata->vidlayer); } - SDL_FreeDirtyRects(&data->dirty); SDL_DFB_FREE(data->pixels); SDL_free(data); texture->driverdata = NULL; @@ -1101,6 +1175,13 @@ static void DirectFB_DestroyRenderer(SDL_Renderer * renderer) { DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(data->window); + +#if 0 + if (display->palette) { + SDL_DelPaletteWatch(display->palette, DisplayPaletteChanged, data); + } +#endif if (data) { SDL_free(data); @@ -1108,4 +1189,75 @@ DirectFB_DestroyRenderer(SDL_Renderer * renderer) SDL_free(renderer); } +static int +DirectFB_UpdateViewport(SDL_Renderer * renderer) +{ + IDirectFBSurface *winsurf = get_dfb_surface(renderer->window); + DFBRegion dreg; + + dreg.x1 = renderer->viewport.x; + dreg.y1 = renderer->viewport.y; + dreg.x2 = dreg.x1 + renderer->viewport.w - 1; + dreg.y2 = dreg.y1 + renderer->viewport.h - 1; + + winsurf->SetClip(winsurf, &dreg); + return 0; +} + +static int +DirectFB_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, void * pixels, int pitch) +{ + Uint32 sdl_format; + void * laypixels; + int laypitch; + DFBSurfacePixelFormat dfb_format; + IDirectFBSurface *winsurf = get_dfb_surface(renderer->window); + + DirectFB_ActivateRenderer(renderer); + + winsurf->GetPixelFormat(winsurf, &dfb_format); + sdl_format = DirectFB_DFBToSDLPixelFormat(dfb_format); + winsurf->Lock(winsurf, DSLF_READ, (void **) &laypixels, &laypitch); + + laypixels += (rect->y * laypitch + rect->x * SDL_BYTESPERPIXEL(sdl_format) ); + SDL_ConvertPixels(rect->w, rect->h, + sdl_format, laypixels, laypitch, + format, pixels, pitch); + + winsurf->Unlock(winsurf); + + return 0; +} + +#if 0 +static int +DirectFB_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, + Uint32 format, const void * pixels, int pitch) +{ + SDL_Window *window = renderer->window; + SDL_DFB_WINDOWDATA(window); + Uint32 sdl_format; + void * laypixels; + int laypitch; + DFBSurfacePixelFormat dfb_format; + + SDL_DFB_CHECK(windata->surface->GetPixelFormat(windata->surface, &dfb_format)); + sdl_format = DirectFB_DFBToSDLPixelFormat(dfb_format); + + SDL_DFB_CHECK(windata->surface->Lock(windata->surface, DSLF_WRITE, (void **) &laypixels, &laypitch)); + + laypixels += (rect->y * laypitch + rect->x * SDL_BYTESPERPIXEL(sdl_format) ); + SDL_ConvertPixels(rect->w, rect->h, + format, pixels, pitch, + sdl_format, laypixels, laypitch); + + SDL_DFB_CHECK(windata->surface->Unlock(windata->surface)); + + return 0; +} +#endif + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_render.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_render.h index 0b4851a91..d6f34cffe 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_render.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_render.h @@ -1,30 +1,25 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" + /* SDL surface based renderer implementation */ -#define SDL_DFB_RENDERERDATA(rend) DirectFB_RenderData *renddata = ((rend) ? (DirectFB_RenderData *) (rend)->driverdata : NULL) - -extern void DirectFB_AddRenderDriver(_THIS); - /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_shape.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_shape.c new file mode 100644 index 000000000..5f8f2d163 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_shape.c @@ -0,0 +1,134 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB + +#include "SDL_assert.h" +#include "SDL_DirectFB_video.h" +#include "SDL_DirectFB_shape.h" +#include "SDL_DirectFB_window.h" + +#include "../SDL_shape_internals.h" + +SDL_Window* +DirectFB_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { + return SDL_CreateWindow(title,x,y,w,h,flags /*| SDL_DFB_WINDOW_SHAPED */); +} + +SDL_WindowShaper* +DirectFB_CreateShaper(SDL_Window* window) { + SDL_WindowShaper* result = NULL; + + result = malloc(sizeof(SDL_WindowShaper)); + result->window = window; + result->mode.mode = ShapeModeDefault; + result->mode.parameters.binarizationCutoff = 1; + result->userx = result->usery = 0; + SDL_ShapeData* data = SDL_malloc(sizeof(SDL_ShapeData)); + result->driverdata = data; + data->surface = NULL; + window->shaper = result; + int resized_properly = DirectFB_ResizeWindowShape(window); + SDL_assert(resized_properly == 0); + + return result; +} + +int +DirectFB_ResizeWindowShape(SDL_Window* window) { + SDL_ShapeData* data = window->shaper->driverdata; + SDL_assert(data != NULL); + + if (window->x != -1000) + { + window->shaper->userx = window->x; + window->shaper->usery = window->y; + } + SDL_SetWindowPosition(window,-1000,-1000); + + return 0; +} + +int +DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode) { + + if(shaper == NULL || shape == NULL || shaper->driverdata == NULL) + return -1; + if(shape->format->Amask == 0 && SDL_SHAPEMODEALPHA(shape_mode->mode)) + return -2; + if(shape->w != shaper->window->w || shape->h != shaper->window->h) + return -3; + + { + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(shaper->window); + SDL_DFB_DEVICEDATA(display->device); + Uint32 *pixels; + Sint32 pitch; + Uint32 h,w; + Uint8 *src, *bitmap; + DFBSurfaceDescription dsc; + + SDL_ShapeData *data = shaper->driverdata; + + SDL_DFB_RELEASE(data->surface); + + dsc.flags = DSDESC_WIDTH | DSDESC_HEIGHT | DSDESC_PIXELFORMAT | DSDESC_CAPS; + dsc.width = shape->w; + dsc.height = shape->h; + dsc.caps = DSCAPS_PREMULTIPLIED; + dsc.pixelformat = DSPF_ARGB; + + SDL_DFB_CHECKERR(devdata->dfb->CreateSurface(devdata->dfb, &dsc, &data->surface)); + + /* Assume that shaper->alphacutoff already has a value, because SDL_SetWindowShape() should have given it one. */ + SDL_DFB_ALLOC_CLEAR(bitmap, shape->w * shape->h); + SDL_CalculateShapeBitmap(shaper->mode,shape,bitmap,1); + + src = bitmap; + + SDL_DFB_CHECK(data->surface->Lock(data->surface, DSLF_WRITE | DSLF_READ, (void **) &pixels, &pitch)); + + h = shaper->window->h; + while (h--) { + for (w = 0; w < shaper->window->w; w++) { + if (*src) + pixels[w] = 0xFFFFFFFF; + else + pixels[w] = 0; + src++; + + } + pixels += (pitch >> 2); + } + SDL_DFB_CHECK(data->surface->Unlock(data->surface)); + SDL_DFB_FREE(bitmap); + + /* FIXME: Need to call this here - Big ?? */ + DirectFB_WM_RedrawLayout(SDL_GetDisplayForWindow(shaper->window)->device, shaper->window); + } + + return 0; +error: + return -1; +} + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_shape.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_shape.h new file mode 100644 index 000000000..d1edb756b --- /dev/null +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_shape.h @@ -0,0 +1,39 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#ifndef _SDL_DirectFB_shape_h +#define _SDL_DirectFB_shape_h + +#include + +#include "../SDL_sysvideo.h" +#include "SDL_shape.h" + +typedef struct { + IDirectFBSurface *surface; +} SDL_ShapeData; + +extern SDL_Window* DirectFB_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags); +extern SDL_WindowShaper* DirectFB_CreateShaper(SDL_Window* window); +extern int DirectFB_ResizeWindowShape(SDL_Window* window); +extern int DirectFB_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shapeMode); + +#endif /* _SDL_DirectFB_shape_h */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_video.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_video.c index 117b5442d..83835df2d 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_video.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_video.c @@ -1,27 +1,38 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - SDL1.3 implementation by couriersud@arcor.de - + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DIRECTFB + +#include "SDL_DirectFB_video.h" + +#include "SDL_DirectFB_events.h" +/* + * #include "SDL_DirectFB_keyboard.h" + */ +#include "SDL_DirectFB_modes.h" +#include "SDL_DirectFB_mouse.h" +#include "SDL_DirectFB_opengl.h" +#include "SDL_DirectFB_window.h" +#include "SDL_DirectFB_WM.h" #include "SDL_config.h" @@ -46,6 +57,8 @@ #include "SDL_DirectFB_events.h" #include "SDL_DirectFB_render.h" #include "SDL_DirectFB_mouse.h" +#include "SDL_DirectFB_shape.h" + #include "SDL_DirectFB_dyn.h" @@ -61,6 +74,10 @@ VideoBootStrap DirectFB_bootstrap = { DirectFB_Available, DirectFB_CreateDevice }; +static const DirectFBSurfaceDrawingFlagsNames(drawing_flags); +static const DirectFBSurfaceBlittingFlagsNames(blitting_flags); +static const DirectFBAccelerationMaskNames(acceleration_mask); + /* DirectFB driver bootstrap functions */ static int @@ -89,7 +106,7 @@ DirectFB_CreateDevice(int devindex) return NULL; /* Initialize all variables that we clean on shutdown */ - SDL_DFB_CALLOC(device, 1, sizeof(SDL_VideoDevice)); + SDL_DFB_ALLOC_CLEAR(device, sizeof(SDL_VideoDevice)); /* Set the function pointers */ @@ -128,8 +145,13 @@ DirectFB_CreateDevice(int devindex) #endif + /* Shaped window support */ + device->shape_driver.CreateShaper = DirectFB_CreateShaper; + device->shape_driver.SetWindowShape = DirectFB_SetWindowShape; + device->shape_driver.ResizeWindowShape = DirectFB_ResizeWindowShape; + device->free = DirectFB_DeleteDevice; - fprintf(LOG_CHANNEL, "Device setup %p!!\n", device->ShowWindow); + return device; error: if (device) @@ -137,10 +159,6 @@ DirectFB_CreateDevice(int devindex) return (0); } -static const DirectFBSurfaceDrawingFlagsNames(drawing_flags); -static const DirectFBSurfaceBlittingFlagsNames(blitting_flags); -static const DirectFBAccelerationMaskNames(acceleration_mask); - static void DirectFB_DeviceInformation(IDirectFB * dfb) { @@ -149,59 +167,64 @@ DirectFB_DeviceInformation(IDirectFB * dfb) dfb->GetDeviceDescription(dfb, &desc); - fprintf(LOG_CHANNEL, "DirectFB Device Information\n"); - fprintf(LOG_CHANNEL, "===========================\n"); - fprintf(LOG_CHANNEL, "Name: %s\n", desc.name); - fprintf(LOG_CHANNEL, "Vendor: %s\n", desc.vendor); - fprintf(LOG_CHANNEL, "Driver Name: %s\n", desc.driver.name); - fprintf(LOG_CHANNEL, "Driver Vendor: %s\n", desc.driver.vendor); - fprintf(LOG_CHANNEL, "Driver Version: %d.%d\n", desc.driver.major, + SDL_DFB_LOG( "DirectFB Device Information"); + SDL_DFB_LOG( "==========================="); + SDL_DFB_LOG( "Name: %s", desc.name); + SDL_DFB_LOG( "Vendor: %s", desc.vendor); + SDL_DFB_LOG( "Driver Name: %s", desc.driver.name); + SDL_DFB_LOG( "Driver Vendor: %s", desc.driver.vendor); + SDL_DFB_LOG( "Driver Version: %d.%d", desc.driver.major, desc.driver.minor); - fprintf(LOG_CHANNEL, "\nVideo memoory: %d\n", desc.video_memory); + SDL_DFB_LOG( "Video memoory: %d", desc.video_memory); - fprintf(LOG_CHANNEL, "\nBlitting flags:\n"); + SDL_DFB_LOG( "Blitting flags:"); for (n = 0; blitting_flags[n].flag; n++) { if (desc.blitting_flags & blitting_flags[n].flag) - fprintf(LOG_CHANNEL, " %s\n", blitting_flags[n].name); + SDL_DFB_LOG( " %s", blitting_flags[n].name); } - fprintf(LOG_CHANNEL, "\nDrawing flags:\n"); + SDL_DFB_LOG( "Drawing flags:"); for (n = 0; drawing_flags[n].flag; n++) { if (desc.drawing_flags & drawing_flags[n].flag) - fprintf(LOG_CHANNEL, " %s\n", drawing_flags[n].name); + SDL_DFB_LOG( " %s", drawing_flags[n].name); } - fprintf(LOG_CHANNEL, "\nAcceleration flags:\n"); + SDL_DFB_LOG( "Acceleration flags:"); for (n = 0; acceleration_mask[n].mask; n++) { if (desc.acceleration_mask & acceleration_mask[n].mask) - fprintf(LOG_CHANNEL, " %s\n", acceleration_mask[n].name); + SDL_DFB_LOG( " %s", acceleration_mask[n].name); } } +static int readBoolEnv(const char *env_name, int def_val) +{ + char *stemp; + + stemp = SDL_getenv(env_name); + if (stemp) + return atoi(stemp); + else + return def_val; +} + static int DirectFB_VideoInit(_THIS) { IDirectFB *dfb = NULL; DFB_DeviceData *devdata = NULL; - char *stemp; DFBResult ret; - SDL_DFB_CALLOC(devdata, 1, sizeof(*devdata)); + SDL_DFB_ALLOC_CLEAR(devdata, sizeof(*devdata)); SDL_DFB_CHECKERR(DirectFBInit(NULL, NULL)); /* avoid switching to the framebuffer when we * are running X11 */ - stemp = SDL_getenv(DFBENV_USE_X11_CHECK); - if (stemp) - ret = atoi(stemp); - else - ret = 1; - + ret = readBoolEnv(DFBENV_USE_X11_CHECK , 1); if (ret) { if (SDL_getenv("DISPLAY")) DirectFBSetOption("system", "x11"); @@ -210,22 +233,20 @@ DirectFB_VideoInit(_THIS) } /* FIXME: Reenable as default once multi kbd/mouse interface is sorted out */ - devdata->use_linux_input = 0; /* default: on */ - stemp = SDL_getenv(DFBENV_USE_LINUX_INPUT); - if (stemp) - devdata->use_linux_input = atoi(stemp); + devdata->use_linux_input = readBoolEnv(DFBENV_USE_LINUX_INPUT, 0); /* default: on */ if (!devdata->use_linux_input) + { + SDL_DFB_LOG("Disabling linxu input\n"); DirectFBSetOption("disable-module", "linux_input"); - + } + SDL_DFB_CHECKERR(DirectFBCreate(&dfb)); DirectFB_DeviceInformation(dfb); - devdata->use_yuv_underlays = 0; /* default: off */ - stemp = SDL_getenv(DFBENV_USE_YUV_UNDERLAY); - if (stemp) - devdata->use_yuv_underlays = atoi(stemp); - + + devdata->use_yuv_underlays = readBoolEnv(DFBENV_USE_YUV_UNDERLAY, 0); /* default: off */ + devdata->use_yuv_direct = readBoolEnv(DFBENV_USE_YUV_DIRECT, 0); /* default is off! */ /* Create global Eventbuffer for axis events */ if (devdata->use_linux_input) { @@ -239,14 +260,10 @@ DirectFB_VideoInit(_THIS) &devdata->events)); } - devdata->initialized = 1; - /* simple window manager support */ - stemp = SDL_getenv(DFBENV_USE_WM); - if (stemp) - devdata->has_own_wm = atoi(stemp); - else - devdata->has_own_wm = 0; + devdata->has_own_wm = readBoolEnv(DFBENV_USE_WM, 0); + + devdata->initialized = 1; devdata->dfb = dfb; devdata->firstwin = NULL; @@ -260,7 +277,6 @@ DirectFB_VideoInit(_THIS) DirectFB_GL_Initialize(_this); #endif - DirectFB_AddRenderDriver(_this); DirectFB_InitMouse(_this); DirectFB_InitKeyboard(_this); @@ -282,6 +298,7 @@ DirectFB_VideoQuit(_THIS) DirectFB_QuitKeyboard(_this); DirectFB_QuitMouse(_this); + devdata->events->Reset(devdata->events); SDL_DFB_RELEASE(devdata->events); SDL_DFB_RELEASE(devdata->dfb); @@ -291,3 +308,116 @@ DirectFB_VideoQuit(_THIS) devdata->initialized = 0; } + +/* DirectFB driver general support functions */ + +static const struct { + DFBSurfacePixelFormat dfb; + Uint32 sdl; +} pixelformat_tab[] = +{ + { DSPF_RGB32, SDL_PIXELFORMAT_RGB888 }, /* 24 bit RGB (4 byte, nothing@24, red 8@16, green 8@8, blue 8@0) */ + { DSPF_ARGB, SDL_PIXELFORMAT_ARGB8888 }, /* 32 bit ARGB (4 byte, alpha 8@24, red 8@16, green 8@8, blue 8@0) */ + { DSPF_RGB16, SDL_PIXELFORMAT_RGB565 }, /* 16 bit RGB (2 byte, red 5@11, green 6@5, blue 5@0) */ + { DSPF_RGB332, SDL_PIXELFORMAT_RGB332 }, /* 8 bit RGB (1 byte, red 3@5, green 3@2, blue 2@0) */ + { DSPF_ARGB4444, SDL_PIXELFORMAT_ARGB4444 }, /* 16 bit ARGB (2 byte, alpha 4@12, red 4@8, green 4@4, blue 4@0) */ + { DSPF_ARGB1555, SDL_PIXELFORMAT_ARGB1555 }, /* 16 bit ARGB (2 byte, alpha 1@15, red 5@10, green 5@5, blue 5@0) */ + { DSPF_RGB24, SDL_PIXELFORMAT_RGB24 }, /* 24 bit RGB (3 byte, red 8@16, green 8@8, blue 8@0) */ + { DSPF_RGB444, SDL_PIXELFORMAT_RGB444 }, /* 16 bit RGB (2 byte, nothing @12, red 4@8, green 4@4, blue 4@0) */ + { DSPF_YV12, SDL_PIXELFORMAT_YV12 }, /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size V/U planes) */ + { DSPF_I420,SDL_PIXELFORMAT_IYUV }, /* 12 bit YUV (8 bit Y plane followed by 8 bit quarter size U/V planes) */ + { DSPF_YUY2, SDL_PIXELFORMAT_YUY2 }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains CbYCrY [31:0]) */ + { DSPF_UYVY, SDL_PIXELFORMAT_UYVY }, /* 16 bit YUV (4 byte/ 2 pixel, macropixel contains YCbYCr [31:0]) */ + { DSPF_RGB555, SDL_PIXELFORMAT_RGB555 }, /* 16 bit RGB (2 byte, nothing @15, red 5@10, green 5@5, blue 5@0) */ +#if (ENABLE_LUT8) + { DSPF_LUT8, SDL_PIXELFORMAT_INDEX8 }, /* 8 bit LUT (8 bit color and alpha lookup from palette) */ +#endif + +#if (DFB_VERSION_ATLEAST(1,2,0)) + { DSPF_BGR555, SDL_PIXELFORMAT_BGR555 }, /* 16 bit BGR (2 byte, nothing @15, blue 5@10, green 5@5, red 5@0) */ +#else + { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR555 }, +#endif + + /* Pfff ... nonmatching formats follow */ + + { DSPF_ALUT44, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit ALUT (1 byte, alpha 4@4, color lookup 4@0) */ + { DSPF_A8, SDL_PIXELFORMAT_UNKNOWN }, /* 8 bit alpha (1 byte, alpha 8@0), e.g. anti-aliased glyphs */ + { DSPF_AiRGB, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit ARGB (4 byte, inv. alpha 8@24, red 8@16, green 8@8, blue 8@0) */ + { DSPF_A1, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (1 byte/ 8 pixel, most significant bit used first) */ + { DSPF_NV12, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CbCr [15:0] plane) */ + { DSPF_NV16, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit YUV (8 bit Y plane followed by one 16 bit half width CbCr [15:0] plane) */ + { DSPF_ARGB2554, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit ARGB (2 byte, alpha 2@14, red 5@9, green 5@4, blue 4@0) */ + { DSPF_NV21, SDL_PIXELFORMAT_UNKNOWN }, /* 12 bit YUV (8 bit Y plane followed by one 16 bit quarter size CrCb [15:0] plane) */ + { DSPF_AYUV, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AYUV (4 byte, alpha 8@24, Y 8@16, Cb 8@8, Cr 8@0) */ + { DSPF_A4, SDL_PIXELFORMAT_UNKNOWN }, /* 4 bit alpha (1 byte/ 2 pixel, more significant nibble used first) */ + { DSPF_ARGB1666, SDL_PIXELFORMAT_UNKNOWN }, /* 1 bit alpha (3 byte/ alpha 1@18, red 6@16, green 6@6, blue 6@0) */ + { DSPF_ARGB6666, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit alpha (3 byte/ alpha 6@18, red 6@16, green 6@6, blue 6@0) */ + { DSPF_RGB18, SDL_PIXELFORMAT_UNKNOWN }, /* 6 bit RGB (3 byte/ red 6@16, green 6@6, blue 6@0) */ + { DSPF_LUT2, SDL_PIXELFORMAT_UNKNOWN }, /* 2 bit LUT (1 byte/ 4 pixel, 2 bit color and alpha lookup from palette) */ + +#if (DFB_VERSION_ATLEAST(1,3,0)) + { DSPF_RGBA4444, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 4@12, green 4@8, blue 4@4, alpha 4@0) */ +#endif + +#if (DFB_VERSION_ATLEAST(1,4,3)) + { DSPF_RGBA5551, SDL_PIXELFORMAT_UNKNOWN }, /* 16 bit RGBA (2 byte, red 5@11, green 5@6, blue 5@1, alpha 1@0) */ + { DSPF_YUV444P, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit full YUV planar (8 bit Y plane followed by an 8 bit Cb and an 8 bit Cr plane) */ + { DSPF_ARGB8565, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit ARGB (3 byte, alpha 8@16, red 5@11, green 6@5, blue 5@0) */ + { DSPF_AVYU, SDL_PIXELFORMAT_UNKNOWN }, /* 32 bit AVYU 4:4:4 (4 byte, alpha 8@24, Cr 8@16, Y 8@8, Cb 8@0) */ + { DSPF_VYU, SDL_PIXELFORMAT_UNKNOWN }, /* 24 bit VYU 4:4:4 (3 byte, Cr 8@16, Y 8@8, Cb 8@0) */ +#endif + + { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1LSB }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX1MSB }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4LSB }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_INDEX4MSB }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR24 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR888 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_RGBA8888 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR8888 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGRA8888 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_ARGB2101010 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR4444 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_ABGR1555 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_BGR565 }, + { DSPF_UNKNOWN, SDL_PIXELFORMAT_YVYU }, /**< Packed mode: Y0+V0+Y1+U0 (1 pla */ +}; + +Uint32 +DirectFB_DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat) +{ + int i; + + for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++) + if (pixelformat_tab[i].dfb == pixelformat) + { + return pixelformat_tab[i].sdl; + } + return SDL_PIXELFORMAT_UNKNOWN; +} + +DFBSurfacePixelFormat +DirectFB_SDLToDFBPixelFormat(Uint32 format) +{ + int i; + + for (i=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++) + if (pixelformat_tab[i].sdl == format) + { + return pixelformat_tab[i].dfb; + } + return DSPF_UNKNOWN; +} + +void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo* ri) +{ + int i, j; + + for (i=0, j=0; pixelformat_tab[i].dfb != DSPF_UNKNOWN; i++) + if (pixelformat_tab[i].sdl != SDL_PIXELFORMAT_UNKNOWN) + ri->texture_formats[j++] = pixelformat_tab[i].sdl; + ri->num_texture_formats = j; +} + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_video.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_video.h index 6c5732cb7..3a49614d4 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_video.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_video.h @@ -1,45 +1,35 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ + #include "SDL_config.h" #ifndef _SDL_DirectFB_video_h #define _SDL_DirectFB_video_h -#include "../SDL_sysvideo.h" - #include #include -#include "SDL_mouse.h" - - -/* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in - * in case we see this again ... - */ - -#define USE_MULTI_API (0) - -#define DEBUG 1 -#define LOG_CHANNEL stdout +#include "../SDL_sysvideo.h" +#include "SDL_scancode.h" +#include "SDL_render.h" #define DFB_VERSIONNUM(X, Y, Z) \ ((X)*1000 + (Y)*100 + (Z)) @@ -51,26 +41,32 @@ (DFB_COMPILEDVERSION >= DFB_VERSIONNUM(X, Y, Z)) #if (DFB_VERSION_ATLEAST(1,0,0)) +#ifdef SDL_VIDEO_OPENGL #define SDL_DIRECTFB_OPENGL 1 -#include +#endif #else #error "SDL_DIRECTFB: Please compile against libdirectfb version >= 1.0.0" #endif -#if SDL_DIRECTFB_OPENGL -#include "SDL_loadso.h" +/* Set below to 1 to compile with (old) multi mice/keyboard api. Code left in + * in case we see this again ... + */ + +#define USE_MULTI_API (0) + +/* Support for LUT8/INDEX8 pixel format. + * This is broken in DirectFB 1.4.3. It works in 1.4.0 and 1.4.5 + * occurred. + */ + +#if (DFB_COMPILEDVERSION == DFB_VERSIONNUM(1, 4, 3)) +#define ENABLE_LUT8 (0) +#else +#define ENABLE_LUT8 (1) #endif -#include "SDL_DirectFB_events.h" -/* - * #include "SDL_DirectFB_gamma.h" - * #include "SDL_DirectFB_keyboard.h" - */ -#include "SDL_DirectFB_modes.h" -#include "SDL_DirectFB_mouse.h" -#include "SDL_DirectFB_opengl.h" -#include "SDL_DirectFB_window.h" -#include "SDL_DirectFB_WM.h" +#define DIRECTFB_DEBUG 1 +#define LOG_CHANNEL stdout #define DFBENV_USE_YUV_UNDERLAY "SDL_DIRECTFB_YUV_UNDERLAY" /* Default: off */ #define DFBENV_USE_YUV_DIRECT "SDL_DIRECTFB_YUV_DIRECT" /* Default: off */ @@ -82,76 +78,103 @@ #define SDL_DFB_FREE(x) do { if ( (x) != NULL ) { SDL_free(x); x = NULL; } } while (0) #define SDL_DFB_UNLOCK(x) do { if ( (x) != NULL ) { x->Unlock(x); } } while (0) -#if DEBUG -/* FIXME: do something with DEBUG */ -#endif - #define SDL_DFB_CONTEXT "SDL_DirectFB" -static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line, const char *src_code) { +#define SDL_DFB_ERR(x...) \ + do { \ + fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t", \ + SDL_DFB_CONTEXT, __FILE__, __LINE__ ); \ + fprintf(LOG_CHANNEL, x ); \ + } while (0) + +#if (DIRECTFB_DEBUG) + +#define SDL_DFB_LOG(x...) \ + do { \ + fprintf(LOG_CHANNEL, "%s: ", SDL_DFB_CONTEXT); \ + fprintf(LOG_CHANNEL, x ); \ + fprintf(LOG_CHANNEL, "\n"); \ + } while (0) + +#define SDL_DFB_DEBUG(x...) SDL_DFB_ERR( x ) + +static inline DFBResult sdl_dfb_check(DFBResult ret, const char *src_file, int src_line) { if (ret != DFB_OK) { - fprintf(LOG_CHANNEL, "%s <%d>:\n\t", src_file, src_line ); - fprintf(LOG_CHANNEL, "\t%s\n", src_code ); - fprintf(LOG_CHANNEL, "\t%s\n", DirectFBErrorString (ret) ); - SDL_SetError( src_code, DirectFBErrorString (ret) ); + SDL_DFB_LOG("%s (%d):%s", src_file, src_line, DirectFBErrorString (ret) ); + SDL_SetError("%s:%s", SDL_DFB_CONTEXT, DirectFBErrorString (ret) ); } return ret; } -#define SDL_DFB_CHECK(x...) sdl_dfb_check( x, __FILE__, __LINE__, #x ) +#define SDL_DFB_CHECK(x...) do { sdl_dfb_check( x, __FILE__, __LINE__); } while (0) +#define SDL_DFB_CHECKERR(x...) do { if ( sdl_dfb_check( x, __FILE__, __LINE__) != DFB_OK ) goto error; } while (0) -#define SDL_DFB_CHECKERR(x...) if ( sdl_dfb_check( x, __FILE__, __LINE__, #x ) != DFB_OK ) goto error +#else -#define SDL_DFB_DEBUG(x...) \ - do { \ - fprintf(LOG_CHANNEL, "%s: %s <%d>:\n\t", \ - SDL_DFB_CONTEXT, __FILE__, __LINE__ ); \ - fprintf(LOG_CHANNEL, x ); \ - } while (0) +#define SDL_DFB_CHECK(x...) x +#define SDL_DFB_CHECKERR(x...) do { if (x != DFB_OK ) goto error; } while (0) +#define SDL_DFB_LOG(x...) do {} while (0) +#define SDL_DFB_DEBUG(x...) do {} while (0) + +#endif -#define SDL_DFB_ERR(x...) SDL_DFB_DEBUG( x ) #define SDL_DFB_CALLOC(r, n, s) \ - do { \ - r = SDL_calloc (n, s); \ - if (!(r)) { \ - fprintf( LOG_CHANNEL, "%s <%d>:\n\t", __FILE__, __LINE__ ); \ - SDL_OutOfMemory(); \ - goto error; \ - } \ + do { \ + r = SDL_calloc (n, s); \ + if (!(r)) { \ + SDL_DFB_ERR("Out of memory"); \ + SDL_OutOfMemory(); \ + goto error; \ + } \ } while (0) +#define SDL_DFB_ALLOC_CLEAR(r, s) SDL_DFB_CALLOC(r, 1, s) + /* Private display data */ #define SDL_DFB_DEVICEDATA(dev) DFB_DeviceData *devdata = (dev ? (DFB_DeviceData *) ((dev)->driverdata) : NULL) #define DFB_MAX_SCREENS 10 +typedef struct _DFB_KeyboardData DFB_KeyboardData; +struct _DFB_KeyboardData +{ + const SDL_Scancode *map; /* keyboard scancode map */ + int map_size; /* size of map */ + int map_adjust; /* index adjust */ + int is_generic; /* generic keyboard */ + int id; +}; + typedef struct _DFB_DeviceData DFB_DeviceData; struct _DFB_DeviceData { int initialized; - IDirectFB *dfb; - int num_mice; - int mouse_id[0x100]; - int num_keyboard; - struct - { - int is_generic; - int id; - } keyboard[10]; - DFB_WindowData *firstwin; + IDirectFB *dfb; + int num_mice; + int mouse_id[0x100]; + int num_keyboard; + DFB_KeyboardData keyboard[10]; + SDL_Window *firstwin; + + int use_yuv_underlays; + int use_yuv_direct; + int use_linux_input; + int has_own_wm; - int use_yuv_underlays; - int use_linux_input; - int has_own_wm; /* window grab */ - SDL_Window *grabbed_window; + SDL_Window *grabbed_window; /* global events */ IDirectFBEventBuffer *events; }; +Uint32 DirectFB_DFBToSDLPixelFormat(DFBSurfacePixelFormat pixelformat); +DFBSurfacePixelFormat DirectFB_SDLToDFBPixelFormat(Uint32 format); +void DirectFB_SetSupportedPixelFormats(SDL_RendererInfo *ri); + + #endif /* _SDL_DirectFB_video_h */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_window.c b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_window.c index 1dd2eeb18..094116a36 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_window.c +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_window.c @@ -1,153 +1,169 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_syswm.h" -#include "../SDL_sysvideo.h" -#include "../../events/SDL_keyboard_c.h" -#include "../../video/SDL_pixels_c.h" +#if SDL_VIDEO_DRIVER_DIRECTFB #include "SDL_DirectFB_video.h" +#include "SDL_DirectFB_modes.h" +#include "SDL_DirectFB_window.h" +#include "SDL_DirectFB_shape.h" + #if SDL_DIRECTFB_OPENGL #include "SDL_DirectFB_opengl.h" #endif -static void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window); +#include "SDL_syswm.h" + +#include "../SDL_pixels_c.h" int DirectFB_CreateWindow(_THIS, SDL_Window * window) { SDL_DFB_DEVICEDATA(_this); - SDL_DFB_DISPLAYDATA(_this, window); + SDL_DFB_DISPLAYDATA(window); DFB_WindowData *windata = NULL; DFBWindowOptions wopts; DFBWindowDescription desc; int x, y; + int bshaped = 0; - SDL_DFB_CALLOC(window->driverdata, 1, sizeof(DFB_WindowData)); + SDL_DFB_ALLOC_CLEAR(window->driverdata, sizeof(DFB_WindowData)); windata = (DFB_WindowData *) window->driverdata; windata->is_managed = devdata->has_own_wm; - +#if 1 SDL_DFB_CHECKERR(devdata->dfb->SetCooperativeLevel(devdata->dfb, DFSCL_NORMAL)); SDL_DFB_CHECKERR(dispdata->layer->SetCooperativeLevel(dispdata->layer, DLSCL_ADMINISTRATIVE)); - +#endif + /* FIXME ... ughh, ugly */ + if (window->x == -1000 && window->y == -1000) + bshaped = 1; + /* Fill the window description. */ - if (window->x == SDL_WINDOWPOS_CENTERED) { - x = (dispdata->cw - window->w) / 2; - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { - x = 0; - } else { - x = window->x; - } - if (window->y == SDL_WINDOWPOS_CENTERED) { - y = (dispdata->ch - window->h) / 2; - } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { - y = 0; - } else { - y = window->y; - } - if (window->flags & SDL_WINDOW_FULLSCREEN) { - x = 0; - y = 0; - } + x = window->x; + y = window->y; DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); /* Create Window */ + desc.caps = 0; desc.flags = - DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_PIXELFORMAT | DWDESC_POSX - | DWDESC_POSY | DWDESC_SURFACE_CAPS; + DWDESC_WIDTH | DWDESC_HEIGHT | DWDESC_POSX | DWDESC_POSY | DWDESC_SURFACE_CAPS; + + if (bshaped) { + desc.flags |= DWDESC_CAPS; + desc.caps |= DWCAPS_ALPHACHANNEL; + } + else + { + desc.flags |= DWDESC_PIXELFORMAT; + } + + if (!(window->flags & SDL_WINDOW_BORDERLESS)) + desc.caps |= DWCAPS_NODECORATION; + desc.posx = x; desc.posy = y; desc.width = windata->size.w; desc.height = windata->size.h; desc.pixelformat = dispdata->pixelformat; desc.surface_caps = DSCAPS_PREMULTIPLIED; - + /* Create the window. */ SDL_DFB_CHECKERR(dispdata->layer->CreateWindow(dispdata->layer, &desc, - &windata->window)); + &windata->dfbwin)); /* Set Options */ - SDL_DFB_CHECK(windata->window->GetOptions(windata->window, &wopts)); + SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts)); - if (window->flags & SDL_WINDOW_RESIZABLE) - wopts |= DWOP_SCALE; - else + /* explicit rescaling of surface */ + wopts |= DWOP_SCALE; + if (window->flags & SDL_WINDOW_RESIZABLE) { + wopts &= ~DWOP_KEEP_SIZE; + } + else { wopts |= DWOP_KEEP_SIZE; + } if (window->flags & SDL_WINDOW_FULLSCREEN) { wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_STACKING | DWOP_KEEP_SIZE; - SDL_DFB_CHECK(windata->window->SetStackingClass(windata->window, DWSC_UPPER)); + SDL_DFB_CHECK(windata->dfbwin->SetStackingClass(windata->dfbwin, DWSC_UPPER)); } - SDL_DFB_CHECK(windata->window->SetOptions(windata->window, wopts)); + + if (bshaped) { + wopts |= DWOP_SHAPED | DWOP_ALPHACHANNEL; + wopts &= ~DWOP_OPAQUE_REGION; + } + + SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts)); /* See what we got */ - SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize + SDL_DFB_CHECK(DirectFB_WM_GetClientSize (_this, window, &window->w, &window->h)); /* Get the window's surface. */ - SDL_DFB_CHECKERR(windata->window->GetSurface(windata->window, + SDL_DFB_CHECKERR(windata->dfbwin->GetSurface(windata->dfbwin, &windata->window_surface)); + /* And get a subsurface for rendering */ SDL_DFB_CHECKERR(windata->window_surface-> GetSubSurface(windata->window_surface, &windata->client, &windata->surface)); - SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0xFF)); + SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, 0xFF)); /* Create Eventbuffer */ - SDL_DFB_CHECKERR(windata->window->CreateEventBuffer(windata->window, + + SDL_DFB_CHECKERR(windata->dfbwin->CreateEventBuffer(windata->dfbwin, &windata-> eventbuffer)); - SDL_DFB_CHECKERR(windata->window-> - EnableEvents(windata->window, DWET_ALL)); + SDL_DFB_CHECKERR(windata->dfbwin-> + EnableEvents(windata->dfbwin, DWET_ALL)); /* Create a font */ /* FIXME: once during Video_Init */ windata->font = NULL; /* Make it the top most window. */ - SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window)); + SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin)); /* remember parent */ - windata->sdl_window = window; + //windata->sdlwin = window; /* Add to list ... */ windata->next = devdata->firstwin; windata->opacity = 0xFF; - devdata->firstwin = windata; + devdata->firstwin = window; /* Draw Frame */ DirectFB_WM_RedrawLayout(_this, window); return 0; error: - SDL_DFB_RELEASE(windata->window); - SDL_DFB_RELEASE(windata->surface); + SDL_DFB_RELEASE(windata->surface); + SDL_DFB_RELEASE(windata->dfbwin); return -1; } @@ -185,8 +201,7 @@ DirectFB_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) int pitch, i; /* Convert the icon to ARGB for modern window managers */ - SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0xFF000000); + SDL_InitFormat(&format, SDL_PIXELFORMAT_ARGB8888); surface = SDL_ConvertSurface(icon, &format, 0); if (!surface) { return; @@ -228,59 +243,49 @@ DirectFB_SetWindowPosition(_THIS, SDL_Window * window) SDL_DFB_WINDOWDATA(window); int x, y; - if (window->y == SDL_WINDOWPOS_UNDEFINED) - y = 0; - else - y = window->y; + x = window->x; + y = window->y; - if (window->x == SDL_WINDOWPOS_UNDEFINED) - x = 0; - else - x = window->x; - - if (window->flags & SDL_WINDOW_FULLSCREEN) { - x = 0; - y = 0; - } DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); - SDL_DFB_CHECK(windata->window->MoveTo(windata->window, x, y)); + SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, x, y)); } void DirectFB_SetWindowSize(_THIS, SDL_Window * window) { - //SDL_DFB_DEVICEDATA(_this); SDL_DFB_WINDOWDATA(window); + if(SDL_IsShapedWindow(window)) + DirectFB_ResizeWindowShape(window); + if (!(window->flags & SDL_WINDOW_FULLSCREEN)) { int cw; int ch; /* Make sure all events are disabled for this operation ! */ - SDL_DFB_CHECKERR(windata->window->DisableEvents(windata->window, + SDL_DFB_CHECKERR(windata->dfbwin->DisableEvents(windata->dfbwin, DWET_ALL)); - SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize(_this, window, &cw, &ch)); if (cw != window->w || ch != window->h) { DirectFB_WM_AdjustWindowLayout(window, window->flags, window->w, window->h); - SDL_DFB_CHECKERR(windata->window->Resize(windata->window, + SDL_DFB_CHECKERR(windata->dfbwin->Resize(windata->dfbwin, windata->size.w, windata->size.h)); } SDL_DFB_CHECKERR(DirectFB_WM_GetClientSize (_this, window, &window->w, &window->h)); - DirectFB_AdjustWindowSurface(_this, window); + DirectFB_AdjustWindowSurface(window); - SDL_DFB_CHECKERR(windata->window->EnableEvents(windata->window, + SDL_DFB_CHECKERR(windata->dfbwin->EnableEvents(windata->dfbwin, DWET_ALL)); } return; error: - SDL_DFB_CHECK(windata->window->EnableEvents(windata->window, DWET_ALL)); + SDL_DFB_CHECK(windata->dfbwin->EnableEvents(windata->dfbwin, DWET_ALL)); return; } @@ -289,7 +294,7 @@ DirectFB_ShowWindow(_THIS, SDL_Window * window) { SDL_DFB_WINDOWDATA(window); - SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, windata->opacity)); + SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, windata->opacity)); } @@ -298,8 +303,8 @@ DirectFB_HideWindow(_THIS, SDL_Window * window) { SDL_DFB_WINDOWDATA(window); - SDL_DFB_CHECK(windata->window->GetOpacity(windata->window, &windata->opacity)); - SDL_DFB_CHECK(windata->window->SetOpacity(windata->window, 0)); + SDL_DFB_CHECK(windata->dfbwin->GetOpacity(windata->dfbwin, &windata->opacity)); + SDL_DFB_CHECK(windata->dfbwin->SetOpacity(windata->dfbwin, 0)); } void @@ -307,19 +312,32 @@ DirectFB_RaiseWindow(_THIS, SDL_Window * window) { SDL_DFB_WINDOWDATA(window); - SDL_DFB_CHECK(windata->window->RaiseToTop(windata->window)); - SDL_DFB_CHECK(windata->window->RequestFocus(windata->window)); + SDL_DFB_CHECK(windata->dfbwin->RaiseToTop(windata->dfbwin)); + SDL_DFB_CHECK(windata->dfbwin->RequestFocus(windata->dfbwin)); } void DirectFB_MaximizeWindow(_THIS, SDL_Window * window) { SDL_DFB_WINDOWDATA(window); + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + DFBWindowOptions wopts; - if (windata->is_managed) { - DirectFB_WM_MaximizeWindow(_this, window); - } else - SDL_Unsupported(); + SDL_DFB_CHECK(windata->dfbwin->GetPosition(windata->dfbwin, + &windata->restore.x, &windata->restore.y)); + SDL_DFB_CHECK(windata->dfbwin->GetSize(windata->dfbwin, &windata->restore.w, + &windata->restore.h)); + + DirectFB_WM_AdjustWindowLayout(window, window->flags | SDL_WINDOW_MAXIMIZED, display->current_mode.w, display->current_mode.h) ; + + SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, 0, 0)); + SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin, + display->current_mode.w, display->current_mode.h)); + + /* Set Options */ + SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts)); + wopts |= DWOP_KEEP_SIZE | DWOP_KEEP_POSITION; + SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts)); } void @@ -334,11 +352,29 @@ void DirectFB_RestoreWindow(_THIS, SDL_Window * window) { SDL_DFB_WINDOWDATA(window); + DFBWindowOptions wopts; + + /* Set Options */ + SDL_DFB_CHECK(windata->dfbwin->GetOptions(windata->dfbwin, &wopts)); + wopts &= ~(DWOP_KEEP_SIZE | DWOP_KEEP_POSITION); + SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts)); + + /* Window layout */ + DirectFB_WM_AdjustWindowLayout(window, window->flags & ~(SDL_WINDOW_MAXIMIZED | SDL_WINDOW_MINIMIZED), + windata->restore.w, windata->restore.h); + SDL_DFB_CHECK(windata->dfbwin->Resize(windata->dfbwin, windata->restore.w, + windata->restore.h)); + SDL_DFB_CHECK(windata->dfbwin->MoveTo(windata->dfbwin, windata->restore.x, + windata->restore.y)); + + if (!(window->flags & SDL_WINDOW_RESIZABLE)) + wopts |= DWOP_KEEP_SIZE; + + if (window->flags & SDL_WINDOW_FULLSCREEN) + wopts |= DWOP_KEEP_POSITION | DWOP_KEEP_SIZE; + SDL_DFB_CHECK(windata->dfbwin->SetOptions(windata->dfbwin, wopts)); + - if (windata->is_managed) { - DirectFB_WM_RestoreWindow(_this, window); - } else - SDL_Unsupported(); } void @@ -351,15 +387,15 @@ DirectFB_SetWindowGrab(_THIS, SDL_Window * window) if ((window->flags & SDL_WINDOW_INPUT_GRABBED)) { if (gwindata != NULL) { - SDL_DFB_CHECK(gwindata->window->UngrabPointer(gwindata->window)); - SDL_DFB_CHECK(gwindata->window->UngrabKeyboard(gwindata->window)); + SDL_DFB_CHECK(gwindata->dfbwin->UngrabPointer(gwindata->dfbwin)); + SDL_DFB_CHECK(gwindata->dfbwin->UngrabKeyboard(gwindata->dfbwin)); } - SDL_DFB_CHECK(windata->window->GrabPointer(windata->window)); - SDL_DFB_CHECK(windata->window->GrabKeyboard(windata->window)); + SDL_DFB_CHECK(windata->dfbwin->GrabPointer(windata->dfbwin)); + SDL_DFB_CHECK(windata->dfbwin->GrabKeyboard(windata->dfbwin)); devdata->grabbed_window = window; } else { - SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window)); - SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window)); + SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin)); + SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin)); devdata->grabbed_window = NULL; } } @@ -372,13 +408,22 @@ DirectFB_DestroyWindow(_THIS, SDL_Window * window) DFB_WindowData *p; /* Some cleanups */ - SDL_DFB_CHECK(windata->window->UngrabPointer(windata->window)); - SDL_DFB_CHECK(windata->window->UngrabKeyboard(windata->window)); + SDL_DFB_CHECK(windata->dfbwin->UngrabPointer(windata->dfbwin)); + SDL_DFB_CHECK(windata->dfbwin->UngrabKeyboard(windata->dfbwin)); #if SDL_DIRECTFB_OPENGL DirectFB_GL_DestroyWindowContexts(_this, window); #endif + if (window->shaper) + { + SDL_ShapeData *data = window->shaper->driverdata; + SDL_DFB_CHECK(data->surface->ReleaseSource(data->surface)); + SDL_DFB_RELEASE(data->surface); + SDL_DFB_FREE(data); + SDL_DFB_FREE(window->shaper); + } + SDL_DFB_CHECK(windata->window_surface->SetFont(windata->window_surface, NULL)); SDL_DFB_CHECK(windata->surface->ReleaseSource(windata->surface)); SDL_DFB_CHECK(windata->window_surface->ReleaseSource(windata->window_surface)); @@ -388,13 +433,14 @@ DirectFB_DestroyWindow(_THIS, SDL_Window * window) SDL_DFB_RELEASE(windata->surface); SDL_DFB_RELEASE(windata->window_surface); - SDL_DFB_RELEASE(windata->window); + SDL_DFB_RELEASE(windata->dfbwin); /* Remove from list ... */ - p = devdata->firstwin; - while (p && p->next != windata) - p = p->next; + p = devdata->firstwin->driverdata; + + while (p && p->next != window) + p = (p->next ? p->next->driverdata : NULL); if (p) p->next = windata->next; else @@ -407,12 +453,25 @@ SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo * info) { - SDL_Unsupported(); - return SDL_FALSE; + SDL_DFB_DEVICEDATA(_this); + SDL_DFB_WINDOWDATA(window); + + if (info->version.major == SDL_MAJOR_VERSION && + info->version.minor == SDL_MINOR_VERSION) { + info->subsystem = SDL_SYSWM_DIRECTFB; + info->info.dfb.dfb = devdata->dfb; + info->info.dfb.window = windata->dfbwin; + info->info.dfb.surface = windata->surface; + return SDL_TRUE; + } else { + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + return SDL_FALSE; + } } -static void -DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window) +void +DirectFB_AdjustWindowSurface(SDL_Window * window) { SDL_DFB_WINDOWDATA(window); int adjust = windata->wm_needs_redraw; @@ -429,11 +488,11 @@ DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window) if (adjust) { #if SDL_DIRECTFB_OPENGL - DirectFB_GL_FreeWindowContexts(_this, window); + DirectFB_GL_FreeWindowContexts(SDL_GetVideoDevice(), window); #endif -#if DFB_VERSION_ATLEAST(1,2,1) - SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window, +#if (DFB_VERSION_ATLEAST(1,2,1)) + SDL_DFB_CHECKERR(windata->dfbwin->ResizeSurface(windata->dfbwin, windata->size.w, windata->size.h)); SDL_DFB_CHECKERR(windata->surface->MakeSubSurface(windata->surface, @@ -443,24 +502,26 @@ DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window) #else DFBWindowOptions opts; - SDL_DFB_CHECKERR(windata->window->GetOptions(windata->window, &opts)); + SDL_DFB_CHECKERR(windata->dfbwin->GetOptions(windata->dfbwin, &opts)); /* recreate subsurface */ SDL_DFB_RELEASE(windata->surface); if (opts & DWOP_SCALE) - SDL_DFB_CHECKERR(windata->window->ResizeSurface(windata->window, + SDL_DFB_CHECKERR(windata->dfbwin->ResizeSurface(windata->dfbwin, windata->size.w, windata->size.h)); SDL_DFB_CHECKERR(windata->window_surface-> GetSubSurface(windata->window_surface, &windata->client, &windata->surface)); #endif - DirectFB_WM_RedrawLayout(_this, window); + DirectFB_WM_RedrawLayout(SDL_GetVideoDevice(), window); #if SDL_DIRECTFB_OPENGL - DirectFB_GL_ReAllocWindowContexts(_this, window); + DirectFB_GL_ReAllocWindowContexts(SDL_GetVideoDevice(), window); #endif } error: return; } + +#endif /* SDL_VIDEO_DRIVER_DIRECTFB */ diff --git a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_window.h b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_window.h index e94ab8c3b..6cb1f3b20 100644 --- a/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_window.h +++ b/project/jni/sdl-1.3/src/video/directfb/SDL_DirectFB_window.h @@ -1,29 +1,28 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" #ifndef _SDL_directfb_window_h #define _SDL_directfb_window_h +#include "SDL_DirectFB_video.h" #include "SDL_DirectFB_WM.h" #define SDL_DFB_WINDOWDATA(win) DFB_WindowData *windata = ((win) ? (DFB_WindowData *) ((win)->driverdata) : NULL) @@ -31,22 +30,28 @@ typedef struct _DFB_WindowData DFB_WindowData; struct _DFB_WindowData { - IDirectFBSurface *surface; - IDirectFBSurface *window_surface; /* only used with has_own_wm */ - IDirectFBWindow *window; - IDirectFBEventBuffer *eventbuffer; - SDL_Window *sdl_window; - DFB_WindowData *next; - Uint8 opacity; - DFBRectangle client; - DFBDimension size; + IDirectFBSurface *window_surface; /* window surface */ + IDirectFBSurface *surface; /* client drawing surface */ + IDirectFBWindow *dfbwin; + IDirectFBEventBuffer *eventbuffer; + //SDL_Window *sdlwin; + SDL_Window *next; + Uint8 opacity; + DFBRectangle client; + DFBDimension size; + DFBRectangle restore; + /* WM extras */ - DFBRectangle restore; - int is_managed; - int wm_needs_redraw; - IDirectFBSurface *icon; - IDirectFBFont *font; - DFB_Theme theme; + int is_managed; + int wm_needs_redraw; + IDirectFBSurface *icon; + IDirectFBFont *font; + DFB_Theme theme; + + /* WM moving and sizing */ + int wm_grab; + int wm_lastx; + int wm_lasty; }; extern int DirectFB_CreateWindow(_THIS, SDL_Window * window); @@ -69,7 +74,7 @@ extern void DirectFB_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool DirectFB_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); -//extern void DirectFB_AdjustWindowSurface(_THIS, SDL_Window * window); +extern void DirectFB_AdjustWindowSurface(SDL_Window * window); #endif /* _SDL_directfb_window_h */ diff --git a/project/jni/sdl-1.3/src/video/dummy/SDL_nullevents.c b/project/jni/sdl-1.3/src/video/dummy/SDL_nullevents.c index 195b8fc69..f348f842a 100644 --- a/project/jni/sdl-1.3/src/video/dummy/SDL_nullevents.c +++ b/project/jni/sdl-1.3/src/video/dummy/SDL_nullevents.c @@ -1,30 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DUMMY + /* Being a null driver, there's no event stream. We just define stubs for most of the API. */ -#include "../../events/SDL_sysevents.h" #include "../../events/SDL_events_c.h" #include "SDL_nullvideo.h" @@ -36,4 +36,6 @@ DUMMY_PumpEvents(_THIS) /* do nothing. */ } +#endif /* SDL_VIDEO_DRIVER_DUMMY */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/dummy/SDL_nullevents_c.h b/project/jni/sdl-1.3/src/video/dummy/SDL_nullevents_c.h index d9319812d..22ce458ae 100644 --- a/project/jni/sdl-1.3/src/video/dummy/SDL_nullevents_c.h +++ b/project/jni/sdl-1.3/src/video/dummy/SDL_nullevents_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/dummy/SDL_nullframebuffer.c b/project/jni/sdl-1.3/src/video/dummy/SDL_nullframebuffer.c new file mode 100644 index 000000000..f9cca9a1d --- /dev/null +++ b/project/jni/sdl-1.3/src/video/dummy/SDL_nullframebuffer.c @@ -0,0 +1,94 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_DUMMY + +#include "../SDL_sysvideo.h" +#include "SDL_nullframebuffer_c.h" + + +#define DUMMY_SURFACE "_SDL_DummySurface" + +int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +{ + SDL_Surface *surface; + const Uint32 surface_format = SDL_PIXELFORMAT_RGB888; + int w, h; + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + + /* Free the old framebuffer surface */ + surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE); + if (surface) { + SDL_FreeSurface(surface); + } + + /* Create a new one */ + SDL_PixelFormatEnumToMasks(surface_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); + SDL_GetWindowSize(window, &w, &h); + surface = SDL_CreateRGBSurface(0, w, h, bpp, Rmask, Gmask, Bmask, Amask); + if (!surface) { + return -1; + } + + /* Save the info and return! */ + SDL_SetWindowData(window, DUMMY_SURFACE, surface); + *format = surface_format; + *pixels = surface->pixels; + *pitch = surface->pitch; + return 0; +} + +int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects) +{ + static int frame_number; + SDL_Surface *surface; + + surface = (SDL_Surface *) SDL_GetWindowData(window, DUMMY_SURFACE); + if (!surface) { + SDL_SetError("Couldn't find dummy surface for window"); + return -1; + } + + /* Send the data to the display */ + if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) { + char file[128]; + SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp", + SDL_GetWindowID(window), ++frame_number); + SDL_SaveBMP(surface, file); + } + return 0; +} + +void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +{ + SDL_Surface *surface; + + surface = (SDL_Surface *) SDL_SetWindowData(window, DUMMY_SURFACE, NULL); + if (surface) { + SDL_FreeSurface(surface); + } +} + +#endif /* SDL_VIDEO_DRIVER_DUMMY */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/dummy/SDL_nullframebuffer_c.h b/project/jni/sdl-1.3/src/video/dummy/SDL_nullframebuffer_c.h new file mode 100644 index 000000000..19f475d20 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/dummy/SDL_nullframebuffer_c.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +extern int SDL_DUMMY_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); +extern int SDL_DUMMY_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects); +extern void SDL_DUMMY_DestroyWindowFramebuffer(_THIS, SDL_Window * window); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/dummy/SDL_nullrender.c b/project/jni/sdl-1.3/src/video/dummy/SDL_nullrender.c deleted file mode 100644 index 96c752f96..000000000 --- a/project/jni/sdl-1.3/src/video/dummy/SDL_nullrender.c +++ /dev/null @@ -1,344 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" -#include "../SDL_sysvideo.h" -#include "../SDL_yuv_sw_c.h" -#include "../SDL_renderer_sw.h" - - -/* SDL surface based renderer implementation */ - -static SDL_Renderer *SDL_DUMMY_CreateRenderer(SDL_Window * window, - Uint32 flags); -static int SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_Rect * dstrect); -static int SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, - const SDL_Rect * rect, - Uint32 format, - void * pixels, int pitch); -static int SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, - const SDL_Rect * rect, - Uint32 format, - const void * pixels, int pitch); -static void SDL_DUMMY_RenderPresent(SDL_Renderer * renderer); -static void SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer); - - -SDL_RenderDriver SDL_DUMMY_RenderDriver = { - SDL_DUMMY_CreateRenderer, - { - "dummy", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTDISCARD), - } -}; - -typedef struct -{ - int current_screen; - SDL_Surface *screens[3]; -} SDL_DUMMY_RenderData; - -SDL_Renderer * -SDL_DUMMY_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - SDL_VideoDisplay *display = window->display; - SDL_DisplayMode *displayMode = &display->current_mode; - SDL_Renderer *renderer; - SDL_DUMMY_RenderData *data; - int i, n; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (!SDL_PixelFormatEnumToMasks - (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown display format"); - return NULL; - } - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (SDL_DUMMY_RenderData *) SDL_malloc(sizeof(*data)); - if (!data) { - SDL_DUMMY_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - SDL_zerop(data); - - renderer->RenderDrawPoints = SDL_DUMMY_RenderDrawPoints; - renderer->RenderDrawLines = SDL_DUMMY_RenderDrawLines; - renderer->RenderDrawRects = SDL_DUMMY_RenderDrawRects; - renderer->RenderFillRects = SDL_DUMMY_RenderFillRects; - renderer->RenderCopy = SDL_DUMMY_RenderCopy; - renderer->RenderReadPixels = SDL_DUMMY_RenderReadPixels; - renderer->RenderWritePixels = SDL_DUMMY_RenderWritePixels; - renderer->RenderPresent = SDL_DUMMY_RenderPresent; - renderer->DestroyRenderer = SDL_DUMMY_DestroyRenderer; - renderer->info.name = SDL_DUMMY_RenderDriver.info.name; - renderer->info.flags = 0; - renderer->window = window; - renderer->driverdata = data; - Setup_SoftwareRenderer(renderer); - - if (flags & SDL_RENDERER_PRESENTFLIP2) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; - n = 2; - } else if (flags & SDL_RENDERER_PRESENTFLIP3) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; - n = 3; - } else { - renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; - n = 1; - } - for (i = 0; i < n; ++i) { - data->screens[i] = - SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask, - Bmask, Amask); - if (!data->screens[i]) { - SDL_DUMMY_DestroyRenderer(renderer); - return NULL; - } - SDL_SetSurfacePalette(data->screens[i], display->palette); - } - data->current_screen = 0; - - return renderer; -} - -static int -SDL_DUMMY_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, int count) -{ - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Surface *target = data->screens[data->current_screen]; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - Uint32 color = SDL_MapRGBA(target->format, - renderer->r, renderer->g, renderer->b, - renderer->a); - - return SDL_DrawPoints(target, points, count, color); - } else { - return SDL_BlendPoints(target, points, count, renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } -} - -static int -SDL_DUMMY_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, int count) -{ - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Surface *target = data->screens[data->current_screen]; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - Uint32 color = SDL_MapRGBA(target->format, - renderer->r, renderer->g, renderer->b, - renderer->a); - - return SDL_DrawLines(target, points, count, color); - } else { - return SDL_BlendLines(target, points, count, renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } -} - -static int -SDL_DUMMY_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Surface *target = data->screens[data->current_screen]; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - Uint32 color = SDL_MapRGBA(target->format, - renderer->r, renderer->g, renderer->b, - renderer->a); - - return SDL_DrawRects(target, rects, count, color); - } else { - return SDL_BlendRects(target, rects, count, - renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } -} - -static int -SDL_DUMMY_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Surface *target = data->screens[data->current_screen]; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - Uint32 color = SDL_MapRGBA(target->format, - renderer->r, renderer->g, renderer->b, - renderer->a); - - return SDL_FillRects(target, rects, count, color); - } else { - return SDL_BlendFillRects(target, rects, count, - renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } -} - -static int -SDL_DUMMY_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - SDL_Surface *target = data->screens[data->current_screen]; - void *pixels = - (Uint8 *) target->pixels + dstrect->y * target->pitch + - dstrect->x * target->format->BytesPerPixel; - return SDL_SW_CopyYUVToRGB((SDL_SW_YUVTexture *) texture->driverdata, - srcrect, display->current_mode.format, - dstrect->w, dstrect->h, pixels, - target->pitch); - } else { - SDL_Surface *surface = (SDL_Surface *) texture->driverdata; - SDL_Surface *target = data->screens[data->current_screen]; - SDL_Rect real_srcrect = *srcrect; - SDL_Rect real_dstrect = *dstrect; - - return SDL_LowerBlit(surface, &real_srcrect, target, &real_dstrect); - } -} - -static int -SDL_DUMMY_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) -{ - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - SDL_Surface *screen = data->screens[data->current_screen]; - Uint32 screen_format = display->current_mode.format; - Uint8 *screen_pixels = (Uint8 *) screen->pixels + - rect->y * screen->pitch + - rect->x * screen->format->BytesPerPixel; - int screen_pitch = screen->pitch; - - return SDL_ConvertPixels(rect->w, rect->h, - screen_format, screen_pixels, screen_pitch, - format, pixels, pitch); -} - -static int -SDL_DUMMY_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch) -{ - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - SDL_Surface *screen = data->screens[data->current_screen]; - Uint32 screen_format = display->current_mode.format; - Uint8 *screen_pixels = (Uint8 *) screen->pixels + - rect->y * screen->pitch + - rect->x * screen->format->BytesPerPixel; - int screen_pitch = screen->pitch; - - return SDL_ConvertPixels(rect->w, rect->h, - format, pixels, pitch, - screen_format, screen_pixels, screen_pitch); -} - -static void -SDL_DUMMY_RenderPresent(SDL_Renderer * renderer) -{ - static int frame_number; - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - - /* Send the data to the display */ - if (SDL_getenv("SDL_VIDEO_DUMMY_SAVE_FRAMES")) { - char file[128]; - SDL_snprintf(file, sizeof(file), "SDL_window%d-%8.8d.bmp", - renderer->window->id, ++frame_number); - SDL_SaveBMP(data->screens[data->current_screen], file); - } - - /* Update the flipping chain, if any */ - if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { - data->current_screen = (data->current_screen + 1) % 2; - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { - data->current_screen = (data->current_screen + 1) % 3; - } -} - -static void -SDL_DUMMY_DestroyRenderer(SDL_Renderer * renderer) -{ - SDL_DUMMY_RenderData *data = - (SDL_DUMMY_RenderData *) renderer->driverdata; - int i; - - if (data) { - for (i = 0; i < SDL_arraysize(data->screens); ++i) { - if (data->screens[i]) { - SDL_FreeSurface(data->screens[i]); - } - } - SDL_free(data); - } - SDL_free(renderer); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/dummy/SDL_nullrender_c.h b/project/jni/sdl-1.3/src/video/dummy/SDL_nullrender_c.h deleted file mode 100644 index f3366f05f..000000000 --- a/project/jni/sdl-1.3/src/video/dummy/SDL_nullrender_c.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* SDL surface based renderer implementation */ - -extern SDL_RenderDriver SDL_DUMMY_RenderDriver; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/dummy/SDL_nullvideo.c b/project/jni/sdl-1.3/src/video/dummy/SDL_nullvideo.c index 840d12e3b..c5c21233e 100644 --- a/project/jni/sdl-1.3/src/video/dummy/SDL_nullvideo.c +++ b/project/jni/sdl-1.3/src/video/dummy/SDL_nullvideo.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_DUMMY + /* Dummy SDL video driver implementation; this is just enough to make an * SDL-based application THINK it's got a working video driver, for * applications that call SDL_Init(SDL_INIT_VIDEO) when they don't need it, @@ -44,7 +45,7 @@ #include "SDL_nullvideo.h" #include "SDL_nullevents_c.h" -#include "SDL_nullrender_c.h" +#include "SDL_nullframebuffer_c.h" #define DUMMYVID_DRIVER_NAME "dummy" @@ -92,6 +93,9 @@ DUMMY_CreateDevice(int devindex) device->VideoQuit = DUMMY_VideoQuit; device->SetDisplayMode = DUMMY_SetDisplayMode; device->PumpEvents = DUMMY_PumpEvents; + device->CreateWindowFramebuffer = SDL_DUMMY_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = SDL_DUMMY_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = SDL_DUMMY_DestroyWindowFramebuffer; device->free = DUMMY_DeleteDevice; @@ -118,7 +122,6 @@ DUMMY_VideoInit(_THIS) if (SDL_AddBasicVideoDisplay(&mode) < 0) { return -1; } - SDL_AddRenderDriver(&_this->displays[0], &SDL_DUMMY_RenderDriver); SDL_zero(mode); SDL_AddDisplayMode(&_this->displays[0], &mode); @@ -138,4 +141,6 @@ DUMMY_VideoQuit(_THIS) { } +#endif /* SDL_VIDEO_DRIVER_DUMMY */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/dummy/SDL_nullvideo.h b/project/jni/sdl-1.3/src/video/dummy/SDL_nullvideo.h index a7ed2e94c..cf6892a45 100644 --- a/project/jni/sdl-1.3/src/video/dummy/SDL_nullvideo.h +++ b/project/jni/sdl-1.3/src/video/dummy/SDL_nullvideo.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/fbcon/3dfx_mmio.h b/project/jni/sdl-1.3/src/video/fbcon/3dfx_mmio.h deleted file mode 100644 index c3c2aac66..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/3dfx_mmio.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* 3Dfx register definitions */ - -#include "3dfx_regs.h" - -/* 3Dfx control macros */ - -#define tdfx_in8(reg) *(volatile Uint8 *)(mapped_io + (reg)) -#define tdfx_in32(reg) *(volatile Uint32 *)(mapped_io + (reg)) - -#define tdfx_out8(reg,v) *(volatile Uint8 *)(mapped_io + (reg)) = v; -#define tdfx_out32(reg,v) *(volatile Uint32 *)(mapped_io + (reg)) = v; - - -/* Wait for fifo space */ -#define tdfx_wait(space) \ -{ \ - while ( (tdfx_in8(TDFX_STATUS) & 0x1F) < space ) \ - ; \ -} - - -/* Wait for idle accelerator */ -#define tdfx_waitidle() \ -{ \ - int i = 0; \ - \ - tdfx_wait(1); \ - tdfx_out32(COMMAND_3D, COMMAND_3D_NOP); \ - do { \ - i = (tdfx_in32(TDFX_STATUS) & STATUS_BUSY) ? 0 : i + 1; \ - } while ( i != 3 ); \ -} -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/3dfx_regs.h b/project/jni/sdl-1.3/src/video/fbcon/3dfx_regs.h deleted file mode 100644 index 436c37b13..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/3dfx_regs.h +++ /dev/null @@ -1,83 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _3DFX_REGS_H -#define _3DFX_REGS_H - -/* This information comes from the public 3Dfx specs for the Voodoo 3000 */ - -/* mapped_io register offsets */ -#define TDFX_STATUS 0x00 - -#define INTCTRL (0x00100000 + 0x04) -#define CLIP0MIN (0x00100000 + 0x08) -#define CLIP0MAX (0x00100000 + 0x0c) -#define DSTBASE (0x00100000 + 0x10) -#define DSTFORMAT (0x00100000 + 0x14) -#define SRCCOLORKEYMIN (0x00100000 + 0x18) -#define SRCCOLORKEYMAX (0x00100000 + 0x1c) -#define DSTCOLORKEYMIN (0x00100000 + 0x20) -#define DSTCOLORKEYMAX (0x00100000 + 0x24) -#define BRESERROR0 (0x00100000 + 0x28) -#define BRESERROR1 (0x00100000 + 0x2c) -#define ROP_2D (0x00100000 + 0x30) -#define SRCBASE (0x00100000 + 0x34) -#define COMMANDEXTRA_2D (0x00100000 + 0x38) -#define PATTERN0 (0x00100000 + 0x44) -#define PATTERN1 (0x00100000 + 0x48) -#define CLIP1MIN (0x00100000 + 0x4c) -#define CLIP1MAX (0x00100000 + 0x50) -#define SRCFORMAT (0x00100000 + 0x54) -#define SRCSIZE (0x00100000 + 0x58) -#define SRCXY (0x00100000 + 0x5c) -#define COLORBACK (0x00100000 + 0x60) -#define COLORFORE (0x00100000 + 0x64) -#define DSTSIZE (0x00100000 + 0x68) -#define DSTXY (0x00100000 + 0x6c) -#define COMMAND_2D (0x00100000 + 0x70) -#define LAUNCH_2D (0x00100000 + 0x80) -#define PATTERNBASE (0x00100000 + 0x100) - -#define COMMAND_3D (0x00200000 + 0x120) - -/* register bitfields (not all, only as needed) */ - -#define BIT(x) (1UL << (x)) - -#define COMMAND_2D_BITBLT 0x01 -#define COMMAND_2D_FILLRECT 0x05 -#define COMMAND_2D_LINE 0x06 -#define COMMAND_2D_POLYGON_FILL 0x08 -#define COMMAND_2D_INITIATE BIT(8) -#define COMMAND_2D_REVERSELINE BIT(9) -#define COMMAND_2D_STIPPLELINE BIT(12) -#define COMMAND_2D_MONOCHROME_PATT BIT(13) -#define COMMAND_2D_MONOCHROME_TRANSP BIT(16) - -#define COMMAND_3D_NOP 0x00 - -#define STATUS_RETRACE BIT(6) -#define STATUS_BUSY BIT(9) - -#endif /* _3DFX_REGS_H */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fb3dfx.c b/project/jni/sdl-1.3/src/video/fbcon/SDL_fb3dfx.c deleted file mode 100644 index ac8d38693..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fb3dfx.c +++ /dev/null @@ -1,225 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" -#include "../SDL_blit.h" -#include "SDL_fb3dfx.h" -#include "3dfx_mmio.h" - - -/* Wait for vertical retrace */ -static void -WaitVBL(_THIS) -{ - /* find start of retrace */ - tdfx_waitidle(); - while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == STATUS_RETRACE); - /* wait until we're past the start */ - while ((tdfx_in32(TDFX_STATUS) & STATUS_RETRACE) == 0); -} - -static void -WaitIdle(_THIS) -{ - tdfx_waitidle(); -} - -/* Sets video mem colorkey and accelerated blit function */ -static int -SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) -{ - return (0); -} - -static int -FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) -{ - int bpp; - char *dst_base; - Uint32 format; - int dstX, dstY; - - /* Don't blit to the display surface when switched away */ - if (switched_away) { - return -2; /* no hardware access */ - } - if (dst == this->screen) { - SDL_mutexP(hw_lock); - } - - /* Set the destination pixel format */ - dst_base = (char *) ((char *) dst->pixels - mapped_mem); - bpp = dst->format->BitsPerPixel; - format = dst->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13); - - /* Calculate source and destination base coordinates */ - dstX = rect->x; - dstY = rect->y; - - /* Execute the fill command */ - tdfx_wait(6); - tdfx_out32(DSTBASE, (Uint32) dst_base); - tdfx_out32(DSTFORMAT, format); - tdfx_out32(COLORFORE, color); - tdfx_out32(COMMAND_2D, COMMAND_2D_FILLRECT); - tdfx_out32(DSTSIZE, rect->w | (rect->h << 16)); - tdfx_out32(LAUNCH_2D, dstX | (dstY << 16)); - - FB_AddBusySurface(dst); - - if (dst == this->screen) { - SDL_mutexV(hw_lock); - } - return (0); -} - -static int -HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) -{ - SDL_VideoDevice *this = current_video; - int bpp; - Uint32 src_format; - Uint32 dst_format; - char *src_base; - char *dst_base; - int srcX, srcY; - int dstX, dstY; - Uint32 blitop; - Uint32 use_colorkey; - - /* Don't blit to the display surface when switched away */ - if (switched_away) { - return -2; /* no hardware access */ - } - if (dst == this->screen) { - SDL_mutexP(hw_lock); - } - - /* Set the source and destination pixel format */ - src_base = (char *) ((char *) src->pixels - mapped_mem); - bpp = src->format->BitsPerPixel; - src_format = src->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13); - dst_base = (char *) ((char *) dst->pixels - mapped_mem); - bpp = dst->format->BitsPerPixel; - dst_format = dst->pitch | ((bpp + ((bpp == 8) ? 0 : 8)) << 13); - - srcX = srcrect->x; - srcY = srcrect->y; - dstX = dstrect->x; - dstY = dstrect->y; - - /* Assemble the blit operation */ - blitop = COMMAND_2D_BITBLT | (0xCC << 24); - if (srcX <= dstX) { - blitop |= BIT(14); - srcX += (dstrect->w - 1); - dstX += (dstrect->w - 1); - } - if (srcY <= dstY) { - blitop |= BIT(15); - srcY += (dstrect->h - 1); - dstY += (dstrect->h - 1); - } - - /* Perform the blit! */ - if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - tdfx_wait(3); - tdfx_out32(SRCCOLORKEYMIN, src->format->colorkey); - tdfx_out32(SRCCOLORKEYMAX, src->format->colorkey); - tdfx_out32(ROP_2D, 0xAA00); - use_colorkey = 1; - } else { - use_colorkey = 0; - } - tdfx_wait(9); - tdfx_out32(SRCBASE, (Uint32) src_base); - tdfx_out32(SRCFORMAT, src_format); - tdfx_out32(DSTBASE, (Uint32) dst_base); - tdfx_out32(DSTFORMAT, src_format); - tdfx_out32(COMMAND_2D, blitop); - tdfx_out32(COMMANDEXTRA_2D, use_colorkey); - tdfx_out32(DSTSIZE, dstrect->w | (dstrect->h << 16)); - tdfx_out32(DSTXY, dstX | (dstY << 16)); - tdfx_out32(LAUNCH_2D, srcX | (srcY << 16)); - - FB_AddBusySurface(src); - FB_AddBusySurface(dst); - - if (dst == this->screen) { - SDL_mutexV(hw_lock); - } - return (0); -} - -static int -CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) -{ - int accelerated; - - /* Set initial acceleration on */ - src->flags |= SDL_HWACCEL; - - /* Set the surface attributes */ - if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { - if (!this->info.blit_hw_A) { - src->flags &= ~SDL_HWACCEL; - } - } - if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - if (!this->info.blit_hw_CC) { - src->flags &= ~SDL_HWACCEL; - } - } - - /* Check to see if final surface blit is accelerated */ - accelerated = !!(src->flags & SDL_HWACCEL); - if (accelerated) { - src->map->hw_blit = HWAccelBlit; - } - return (accelerated); -} - -void -FB_3DfxAccel(_THIS, __u32 card) -{ - /* We have hardware accelerated surface functions */ - this->CheckHWBlit = CheckHWBlit; - wait_vbl = WaitVBL; - wait_idle = WaitIdle; - - /* Reset the 3Dfx controller */ - tdfx_out32(BRESERROR0, 0); - tdfx_out32(BRESERROR1, 0); - - /* The 3Dfx has an accelerated color fill */ - this->info.blit_fill = 1; - this->FillHWRect = FillHWRect; - - /* The 3Dfx has accelerated normal and colorkey blits */ - this->info.blit_hw = 1; - this->info.blit_hw_CC = 1; - this->SetHWColorKey = SetHWColorKey; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fb3dfx.h b/project/jni/sdl-1.3/src/video/fbcon/SDL_fb3dfx.h deleted file mode 100644 index 4b9d538f0..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fb3dfx.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* 3Dfx hardware acceleration for the SDL framebuffer console driver */ - -#include "SDL_fbvideo.h" - -/* Set up the driver for 3Dfx acceleration */ -extern void FB_3DfxAccel(_THIS, __u32 card); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbelo.c b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbelo.c deleted file mode 100644 index 2da7e6628..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbelo.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include -#include -#include - -#include "SDL_stdinc.h" -#include "SDL_fbvideo.h" -#include "SDL_fbelo.h" - -/* - calibration default values - values are read from the following environment variables: - - SDL_ELO_MIN_X - SDL_ELO_MAX_X - SDL_ELO_MIN_Y - SDL_ELO_MAX_Y -*/ - -static int ELO_MIN_X = 400; -static int ELO_MAX_X = 3670; -static int ELO_MIN_Y = 500; -static int ELO_MAX_Y = 3540; - -#define ELO_SNAP_SIZE 6 -#define ELO_TOUCH_BYTE 'T' -#define ELO_ID 'I' -#define ELO_MODE 'M' -#define ELO_PARAMETER 'P' -#define ELO_REPORT 'B' -#define ELO_ACK 'A' - -#define ELO_INIT_CHECKSUM 0xAA - -#define ELO_BTN_PRESS 0x01 -#define ELO_STREAM 0x02 -#define ELO_BTN_RELEASE 0x04 - -#define ELO_TOUCH_MODE 0x01 -#define ELO_STREAM_MODE 0x02 -#define ELO_UNTOUCH_MODE 0x04 -#define ELO_RANGE_CHECK_MODE 0x40 -#define ELO_TRIM_MODE 0x02 -#define ELO_CALIB_MODE 0x04 -#define ELO_SCALING_MODE 0x08 -#define ELO_TRACKING_MODE 0x40 - -#define ELO_SERIAL_MASK 0xF8 - -#define ELO_SERIAL_IO '0' - -#define ELO_MAX_TRIALS 3 -#define ELO_MAX_WAIT 100000 -#define ELO_UNTOUCH_DELAY 5 -#define ELO_REPORT_DELAY 1 - -/* eloParsePacket -*/ -int -eloParsePacket(unsigned char *mousebuf, int *dx, int *dy, int *button_state) -{ - static int elo_button = 0; - static int last_x = 0; - static int last_y = 0; - int x, y; - - /* Check if we have a touch packet */ - if (mousebuf[1] != ELO_TOUCH_BYTE) { - return 0; - } - - x = ((mousebuf[4] << 8) | mousebuf[3]); - y = ((mousebuf[6] << 8) | mousebuf[5]); - - if ((SDL_abs(x - last_x) > ELO_SNAP_SIZE) - || (SDL_abs(y - last_y) > ELO_SNAP_SIZE)) { - *dx = ((mousebuf[4] << 8) | mousebuf[3]); - *dy = ((mousebuf[6] << 8) | mousebuf[5]); - } else { - *dx = last_x; - *dy = last_y; - } - - last_x = *dx; - last_y = *dy; - - if ((mousebuf[2] & 0x07) == ELO_BTN_PRESS) { - elo_button = 1; - } - if ((mousebuf[2] & 0x07) == ELO_BTN_RELEASE) { - elo_button = 0; - } - - *button_state = elo_button; - return 1; -} - -/* Convert the raw coordinates from the ELO controller - to a screen position. -*/ -void -eloConvertXY(_THIS, int *dx, int *dy) -{ - int input_x = *dx; - int input_y = *dy; - int width = ELO_MAX_X - ELO_MIN_X; - int height = ELO_MAX_Y - ELO_MIN_Y; - - *dx = - ((int) cache_vinfo.xres - - ((int) cache_vinfo.xres * (input_x - ELO_MIN_X)) / width); - *dy = (cache_vinfo.yres * (input_y - ELO_MIN_Y)) / height; -} - - -/* eloGetPacket -*/ -int -eloGetPacket(unsigned char *buffer, int *buffer_p, int *checksum, int fd) -{ - int num_bytes; - int ok; - - if (fd == 0) { - num_bytes = ELO_PACKET_SIZE; - } else { - num_bytes = read(fd, - (char *) (buffer + *buffer_p), - ELO_PACKET_SIZE - *buffer_p); - } - - if (num_bytes < 0) { -#ifdef DEBUG_MOUSE - fprintf(stderr, - "System error while reading from Elographics touchscreen.\n"); -#endif - return 0; - } - - while (num_bytes) { - if ((*buffer_p == 0) && (buffer[0] != ELO_START_BYTE)) { - SDL_memcpy(&buffer[0], &buffer[1], num_bytes - 1); - } else { - if (*buffer_p < ELO_PACKET_SIZE - 1) { - *checksum = *checksum + buffer[*buffer_p]; - *checksum = *checksum % 256; - } - (*buffer_p)++; - } - num_bytes--; - } - - if (*buffer_p == ELO_PACKET_SIZE) { - ok = (*checksum == buffer[ELO_PACKET_SIZE - 1]); - *checksum = ELO_INIT_CHECKSUM; - *buffer_p = 0; - - if (!ok) { - return 0; - } - - return 1; - } else { - return 0; - } -} - -/* eloSendPacket -*/ - -int -eloSendPacket(unsigned char *packet, int fd) -{ - int i, result; - int sum = ELO_INIT_CHECKSUM; - - packet[0] = ELO_START_BYTE; - for (i = 0; i < ELO_PACKET_SIZE - 1; i++) { - sum += packet[i]; - sum &= 0xFF; - } - packet[ELO_PACKET_SIZE - 1] = sum; - - result = write(fd, packet, ELO_PACKET_SIZE); - - if (result != ELO_PACKET_SIZE) { -#ifdef DEBUG_MOUSE - printf("System error while sending to Elographics touchscreen.\n"); -#endif - return 0; - } else { - return 1; - } -} - - -/* eloWaitForInput - */ -int -eloWaitForInput(int fd, int timeout) -{ - fd_set readfds; - struct timeval to; - int r; - - FD_ZERO(&readfds); - FD_SET(fd, &readfds); - to.tv_sec = 0; - to.tv_usec = timeout; - - r = select(FD_SETSIZE, &readfds, NULL, NULL, &to); - return r; -} - -/* eloWaitReply - */ -int -eloWaitReply(unsigned char type, unsigned char *reply, int fd) -{ - int ok; - int i, result; - int reply_p = 0; - int sum = ELO_INIT_CHECKSUM; - - i = ELO_MAX_TRIALS; - do { - ok = 0; - - result = eloWaitForInput(fd, ELO_MAX_WAIT); - - if (result > 0) { - ok = eloGetPacket(reply, &reply_p, &sum, fd); - - if (ok && reply[1] != type && type != ELO_PARAMETER) { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Wrong reply received\n"); -#endif - ok = 0; - } - } else { -#ifdef DEBUG_MOUSE - fprintf(stderr, "No input!\n"); -#endif - } - - if (result == 0) { - i--; - } - } while (!ok && (i > 0)); - - return ok; -} - - -/* eloWaitAck - */ - -int -eloWaitAck(int fd) -{ - unsigned char packet[ELO_PACKET_SIZE]; - int i, nb_errors; - - if (eloWaitReply(ELO_ACK, packet, fd)) { - for (i = 0, nb_errors = 0; i < 4; i++) { - if (packet[2 + i] != '0') { - nb_errors++; - } - } - - if (nb_errors != 0) { -#ifdef DEBUG_MOUSE - fprintf(stderr, - "Elographics acknowledge packet reports %d errors\n", - nb_errors); -#endif - } - return 1; - } else { - return 0; - } -} - - -/* eloSendQuery -- -*/ -int -eloSendQuery(unsigned char *request, unsigned char *reply, int fd) -{ - int ok; - - if (eloSendPacket(request, fd)) { - ok = eloWaitReply(toupper(request[1]), reply, fd); - if (ok) { - ok = eloWaitAck(fd); - } - return ok; - } else { - return 0; - } -} - - -/* eloSendControl -*/ -int -eloSendControl(unsigned char *control, int fd) -{ - if (eloSendPacket(control, fd)) { - return eloWaitAck(fd); - } else { - return 0; - } -} - -/* eloInitController -*/ -int -eloInitController(int fd) -{ - unsigned char req[ELO_PACKET_SIZE]; - unsigned char reply[ELO_PACKET_SIZE]; - const char *buffer = NULL; - int result = 0; - - struct termios mouse_termios; - - /* try to read the calibration values */ - buffer = SDL_getenv("SDL_ELO_MIN_X"); - if (buffer) { - ELO_MIN_X = SDL_atoi(buffer); - } - buffer = SDL_getenv("SDL_ELO_MAX_X"); - if (buffer) { - ELO_MAX_X = SDL_atoi(buffer); - } - buffer = SDL_getenv("SDL_ELO_MIN_Y"); - if (buffer) { - ELO_MIN_Y = SDL_atoi(buffer); - } - buffer = SDL_getenv("SDL_ELO_MAX_Y"); - if (buffer) { - ELO_MAX_Y = SDL_atoi(buffer); - } -#ifdef DEBUG_MOUSE - fprintf(stderr, - "ELO calibration values:\nmin_x: %i\nmax_x: %i\nmin_y: %i\nmax_y: %i\n", - ELO_MIN_X, ELO_MAX_X, ELO_MIN_Y, ELO_MAX_Y); -#endif - - /* set comm params */ - SDL_memset(&mouse_termios, 0, sizeof(mouse_termios)); - mouse_termios.c_cflag = B9600 | CS8 | CREAD | CLOCAL; - mouse_termios.c_cc[VMIN] = 1; - result = tcsetattr(fd, TCSANOW, &mouse_termios); - - if (result < 0) { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Unable to configure Elographics touchscreen port\n"); -#endif - return 0; - } - - SDL_memset(req, 0, ELO_PACKET_SIZE); - req[1] = tolower(ELO_PARAMETER); - if (!eloSendQuery(req, reply, fd)) { -#ifdef DEBUG_MOUSE - fprintf(stderr, - "Not at the specified rate or model 2310, will continue\n"); -#endif - } - - SDL_memset(req, 0, ELO_PACKET_SIZE); - req[1] = tolower(ELO_ID); - if (eloSendQuery(req, reply, fd)) { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Ok, controller configured!\n"); -#endif - } else { -#ifdef DEBUG_MOUSE - fprintf(stderr, - "Unable to ask Elographics touchscreen identification\n"); -#endif - return 0; - } - - SDL_memset(req, 0, ELO_PACKET_SIZE); - req[1] = ELO_MODE; - req[3] = ELO_TOUCH_MODE | ELO_STREAM_MODE | ELO_UNTOUCH_MODE; - req[4] = ELO_TRACKING_MODE; - if (!eloSendControl(req, fd)) { -#ifdef DEBUG_MOUSE - fprintf(stderr, - "Unable to change Elographics touchscreen operating mode\n"); -#endif - return 0; - } - - SDL_memset(req, 0, ELO_PACKET_SIZE); - req[1] = ELO_REPORT; - req[2] = ELO_UNTOUCH_DELAY; - req[3] = ELO_REPORT_DELAY; - if (!eloSendControl(req, fd)) { -#ifdef DEBUG_MOUSE - fprintf(stderr, - "Unable to change Elographics touchscreen reports timings\n"); -#endif - return 0; - } - - return 1; -} - -int -eloReadPosition(_THIS, int fd, int *x, int *y, int *button_state, int *realx, - int *realy) -{ - unsigned char buffer[ELO_PACKET_SIZE]; - int pointer = 0; - int checksum = ELO_INIT_CHECKSUM; - - while (pointer < ELO_PACKET_SIZE) { - if (eloGetPacket(buffer, &pointer, &checksum, fd)) { - break; - } - } - - if (!eloParsePacket(buffer, realx, realy, button_state)) { - return 0; - } - - *x = *realx; - *y = *realy; - - eloConvertXY(this, x, y); - - return 1; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbelo.h b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbelo.h deleted file mode 100644 index 40a45e226..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbelo.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef SDL_fbelo_h -#define SDL_fbelo_h - -#include "SDL_fbvideo.h" - -/* ELO */ -#define ELO_PACKET_SIZE 10 -#define ELO_START_BYTE 'U' - -/* eloConvertXY - Convert the raw coordinates from the ELO controller - to a screen position. -*/ -void eloConvertXY(_THIS, int *dx, int *dy); - -/* eloInitController(int fd) - Initialize the ELO serial touchscreen controller -*/ -int eloInitController(int fd); - -/* eloParsePacket - extract position and button state from a packet -*/ -int eloParsePacket(unsigned char *mousebuf, int *dx, int *dy, - int *button_state); - -/* eloReadPosition - read a packet and get the cursor position -*/ - -int eloReadPosition(_THIS, int fd, int *x, int *y, int *button_state, - int *realx, int *realy); - -#endif /* SDL_fbelo_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbevents.c b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbevents.c deleted file mode 100644 index 4c6d1125e..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbevents.c +++ /dev/null @@ -1,1391 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Handle the event stream, converting console events into SDL events */ - -#include -#include -#include -#include -#include -#include -#include -#include - -/* For parsing /proc */ -#include -#include - -#include -#include -#include - -#include "SDL_timer.h" -#include "SDL_mutex.h" -#include "../SDL_sysvideo.h" -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" -#include "SDL_fbvideo.h" -#include "SDL_fbevents_c.h" -#include "SDL_fbkeys.h" - -#include "SDL_fbelo.h" - -#ifndef GPM_NODE_FIFO -#define GPM_NODE_FIFO "/dev/gpmdata" -#endif - -/*#define DEBUG_KEYBOARD*/ -/*#define DEBUG_MOUSE*/ - -/* The translation tables from a console scancode to a SDL keysym */ -#define NUM_VGAKEYMAPS (1<= 0) && (saved_kbd_mode >= 0)); -} - -int -FB_EnterGraphicsMode(_THIS) -{ - struct termios keyboard_termios; - - /* Set medium-raw keyboard mode */ - if ((keyboard_fd >= 0) && !FB_InGraphicsMode(this)) { - - /* Switch to the correct virtual terminal */ - if (current_vt > 0) { - struct vt_stat vtstate; - - if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) { - saved_vt = vtstate.v_active; - } - if (ioctl(keyboard_fd, VT_ACTIVATE, current_vt) == 0) { - ioctl(keyboard_fd, VT_WAITACTIVE, current_vt); - } - } - - /* Set the terminal input mode */ - if (tcgetattr(keyboard_fd, &saved_kbd_termios) < 0) { - SDL_SetError("Unable to get terminal attributes"); - if (keyboard_fd > 0) { - close(keyboard_fd); - } - keyboard_fd = -1; - return (-1); - } - if (ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0) { - SDL_SetError("Unable to get current keyboard mode"); - if (keyboard_fd > 0) { - close(keyboard_fd); - } - keyboard_fd = -1; - return (-1); - } - keyboard_termios = saved_kbd_termios; - keyboard_termios.c_lflag &= ~(ICANON | ECHO | ISIG); - keyboard_termios.c_iflag &= - ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON); - keyboard_termios.c_cc[VMIN] = 0; - keyboard_termios.c_cc[VTIME] = 0; - if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) { - FB_CloseKeyboard(this); - SDL_SetError("Unable to set terminal attributes"); - return (-1); - } - /* This will fail if we aren't root or this isn't our tty */ - if (ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0) { - FB_CloseKeyboard(this); - SDL_SetError("Unable to set keyboard in raw mode"); - return (-1); - } - if (ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0) { - FB_CloseKeyboard(this); - SDL_SetError("Unable to set keyboard in graphics mode"); - return (-1); - } - /* Prevent switching the virtual terminal */ - ioctl(keyboard_fd, VT_LOCKSWITCH, 1); - } - return (keyboard_fd); -} - -void -FB_LeaveGraphicsMode(_THIS) -{ - if (FB_InGraphicsMode(this)) { - ioctl(keyboard_fd, KDSETMODE, KD_TEXT); - ioctl(keyboard_fd, KDSKBMODE, saved_kbd_mode); - tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios); - saved_kbd_mode = -1; - - /* Head back over to the original virtual terminal */ - ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1); - if (saved_vt > 0) { - ioctl(keyboard_fd, VT_ACTIVATE, saved_vt); - } - } -} - -void -FB_CloseKeyboard(_THIS) -{ - if (keyboard_fd >= 0) { - FB_LeaveGraphicsMode(this); - if (keyboard_fd > 0) { - close(keyboard_fd); - } - } - keyboard_fd = -1; -} - -int -FB_OpenKeyboard(_THIS) -{ - /* Open only if not already opened */ - if (keyboard_fd < 0) { - static const char *const tty0[] = { "/dev/tty0", "/dev/vc/0", NULL }; - static const char *const vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL }; - int i, tty0_fd; - - /* Try to query for a free virtual terminal */ - tty0_fd = -1; - for (i = 0; tty0[i] && (tty0_fd < 0); ++i) { - tty0_fd = open(tty0[i], O_WRONLY, 0); - } - if (tty0_fd < 0) { - tty0_fd = dup(0); /* Maybe stdin is a VT? */ - } - ioctl(tty0_fd, VT_OPENQRY, ¤t_vt); - close(tty0_fd); - if ((geteuid() == 0) && (current_vt > 0)) { - for (i = 0; vcs[i] && (keyboard_fd < 0); ++i) { - char vtpath[12]; - - SDL_snprintf(vtpath, SDL_arraysize(vtpath), vcs[i], - current_vt); - keyboard_fd = open(vtpath, O_RDWR, 0); -#ifdef DEBUG_KEYBOARD - fprintf(stderr, "vtpath = %s, fd = %d\n", - vtpath, keyboard_fd); -#endif /* DEBUG_KEYBOARD */ - - /* This needs to be our controlling tty - so that the kernel ioctl() calls work - */ - if (keyboard_fd >= 0) { - tty0_fd = open("/dev/tty", O_RDWR, 0); - if (tty0_fd >= 0) { - ioctl(tty0_fd, TIOCNOTTY, 0); - close(tty0_fd); - } - } - } - } - if (keyboard_fd < 0) { - /* Last resort, maybe our tty is a usable VT */ - struct vt_stat vtstate; - - keyboard_fd = open("/dev/tty", O_RDWR); - - if (ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) { - current_vt = vtstate.v_active; - } else { - current_vt = 0; - } - } -#ifdef DEBUG_KEYBOARD - fprintf(stderr, "Current VT: %d\n", current_vt); -#endif - saved_kbd_mode = -1; - - /* Make sure that our input is a console terminal */ - { - int dummy; - if (ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0) { - close(keyboard_fd); - keyboard_fd = -1; - SDL_SetError("Unable to open a console terminal"); - } - } - - /* Set up keymap */ - FB_vgainitkeymaps(keyboard_fd); - } - return (keyboard_fd); -} - -static enum -{ - MOUSE_NONE = -1, - MOUSE_MSC, /* Note: GPM uses the MSC protocol */ - MOUSE_PS2, - MOUSE_IMPS2, - MOUSE_MS, - MOUSE_BM, - MOUSE_ELO, - MOUSE_TSLIB, - NUM_MOUSE_DRVS -} mouse_drv = MOUSE_NONE; - -void -FB_CloseMouse(_THIS) -{ -#if SDL_INPUT_TSLIB - if (ts_dev != NULL) { - ts_close(ts_dev); - ts_dev = NULL; - mouse_fd = -1; - } -#endif /* SDL_INPUT_TSLIB */ - if (mouse_fd > 0) { - close(mouse_fd); - } - mouse_fd = -1; -} - -/* Returns processes listed in /proc with the desired name */ -static int -find_pid(DIR * proc, const char *wanted_name) -{ - struct dirent *entry; - int pid; - - /* First scan proc for the gpm process */ - pid = 0; - while ((pid == 0) && ((entry = readdir(proc)) != NULL)) { - if (isdigit(entry->d_name[0])) { - FILE *status; - char path[PATH_MAX]; - char name[PATH_MAX]; - - SDL_snprintf(path, SDL_arraysize(path), "/proc/%s/status", - entry->d_name); - status = fopen(path, "r"); - if (status) { - name[0] = '\0'; - fscanf(status, "Name: %s", name); - if (SDL_strcmp(name, wanted_name) == 0) { - pid = SDL_atoi(entry->d_name); - } - fclose(status); - } - } - } - return pid; -} - -/* Returns true if /dev/gpmdata is being written to by gpm */ -static int -gpm_available(char *proto, size_t protolen) -{ - int available; - DIR *proc; - int pid; - int cmdline, len, arglen; - char path[PATH_MAX]; - char args[PATH_MAX], *arg; - - /* Don't bother looking if the fifo isn't there */ -#ifdef DEBUG_MOUSE - fprintf(stderr, "testing gpm\n"); -#endif - if (access(GPM_NODE_FIFO, F_OK) < 0) { - return (0); - } - - available = 0; - proc = opendir("/proc"); - if (proc) { - char raw_proto[10] = { '\0' }; - char repeat_proto[10] = { '\0' }; - while (!available && (pid = find_pid(proc, "gpm")) > 0) { - SDL_snprintf(path, SDL_arraysize(path), "/proc/%d/cmdline", pid); - cmdline = open(path, O_RDONLY, 0); - if (cmdline >= 0) { - len = read(cmdline, args, sizeof(args)); - arg = args; - while (len > 0) { - arglen = SDL_strlen(arg) + 1; -#ifdef DEBUG_MOUSE - fprintf(stderr, "gpm arg %s len %d\n", arg, arglen); -#endif - if (SDL_strcmp(arg, "-t") == 0) { - /* protocol string, keep it for later */ - char *t, *s; - t = arg + arglen; - s = SDL_strchr(t, ' '); - if (s) - *s = 0; - SDL_strlcpy(raw_proto, t, SDL_arraysize(raw_proto)); - if (s) - *s = ' '; - } - if (SDL_strncmp(arg, "-R", 2) == 0) { - char *t, *s; - available = 1; - t = arg + 2; - s = SDL_strchr(t, ' '); - if (s) - *s = 0; - SDL_strlcpy(repeat_proto, t, - SDL_arraysize(repeat_proto)); - if (s) - *s = ' '; - } - len -= arglen; - arg += arglen; - } - close(cmdline); - } - } - closedir(proc); - - if (available) { - if (SDL_strcmp(repeat_proto, "raw") == 0) { - SDL_strlcpy(proto, raw_proto, protolen); - } else if (*repeat_proto) { - SDL_strlcpy(proto, repeat_proto, protolen); - } else { - SDL_strlcpy(proto, "msc", protolen); - } - } - } - return available; -} - - -/* rcg06112001 Set up IMPS/2 mode, if possible. This gives - * us access to the mousewheel, etc. Returns zero if - * writes to device failed, but you still need to query the - * device to see which mode it's actually in. - */ -static int -set_imps2_mode(int fd) -{ - /* If you wanted to control the mouse mode (and we do :) ) ... - Set IMPS/2 protocol: - {0xf3,200,0xf3,100,0xf3,80} - Reset mouse device: - {0xFF} - */ - Uint8 set_imps2[] = { 0xf3, 200, 0xf3, 100, 0xf3, 80 }; - /*Uint8 reset = 0xff; */ - fd_set fdset; - struct timeval tv; - int retval = 0; - - if (write(fd, &set_imps2, sizeof(set_imps2)) == sizeof(set_imps2)) { - /* Don't reset it, that'll clear IMPS/2 mode on some mice - if (write(fd, &reset, sizeof (reset)) == sizeof (reset) ) { - retval = 1; - } - */ - } - - /* Get rid of any chatter from the above */ - FD_ZERO(&fdset); - FD_SET(fd, &fdset); - tv.tv_sec = 0; - tv.tv_usec = 0; - while (select(fd + 1, &fdset, 0, 0, &tv) > 0) { - char temp[32]; - read(fd, temp, sizeof(temp)); - } - - return retval; -} - - -/* Returns true if the mouse uses the IMPS/2 protocol */ -static int -detect_imps2(int fd) -{ - int imps2; - - imps2 = 0; - - if (SDL_getenv("SDL_MOUSEDEV_IMPS2")) { - imps2 = 1; - } - if (!imps2) { - Uint8 query_ps2 = 0xF2; - fd_set fdset; - struct timeval tv; - - /* Get rid of any mouse motion noise */ - FD_ZERO(&fdset); - FD_SET(fd, &fdset); - tv.tv_sec = 0; - tv.tv_usec = 0; - while (select(fd + 1, &fdset, 0, 0, &tv) > 0) { - char temp[32]; - read(fd, temp, sizeof(temp)); - } - - /* Query for the type of mouse protocol */ - if (write(fd, &query_ps2, sizeof(query_ps2)) == sizeof(query_ps2)) { - Uint8 ch = 0; - - /* Get the mouse protocol response */ - do { - FD_ZERO(&fdset); - FD_SET(fd, &fdset); - tv.tv_sec = 1; - tv.tv_usec = 0; - if (select(fd + 1, &fdset, 0, 0, &tv) < 1) { - break; - } - } while ((read(fd, &ch, sizeof(ch)) == sizeof(ch)) && - ((ch == 0xFA) || (ch == 0xAA))); - - /* Experimental values (Logitech wheelmouse) */ -#ifdef DEBUG_MOUSE - fprintf(stderr, "Last mouse mode: 0x%x\n", ch); -#endif - if ((ch == 3) || (ch == 4)) { - imps2 = 1; - } - } - } - return imps2; -} - -int -FB_OpenMouse(_THIS) -{ - int i; - const char *mousedev; - const char *mousedrv; - - mousedrv = SDL_getenv("SDL_MOUSEDRV"); - mousedev = SDL_getenv("SDL_MOUSEDEV"); - mouse_fd = -1; - -#if SDL_INPUT_TSLIB - if (mousedrv && (SDL_strcmp(mousedrv, "TSLIB") == 0)) { - if (mousedev == NULL) - mousedev = SDL_getenv("TSLIB_TSDEVICE"); - if (mousedev != NULL) { - ts_dev = ts_open(mousedev, 1); - if ((ts_dev != NULL) && (ts_config(ts_dev) >= 0)) { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Using tslib touchscreen\n"); -#endif - mouse_drv = MOUSE_TSLIB; - mouse_fd = ts_fd(ts_dev); - return mouse_fd; - } - } - mouse_drv = MOUSE_NONE; - return mouse_fd; - } -#endif /* SDL_INPUT_TSLIB */ - - /* ELO TOUCHSCREEN SUPPORT */ - - if (mousedrv && (SDL_strcmp(mousedrv, "ELO") == 0)) { - mouse_fd = open(mousedev, O_RDWR); - if (mouse_fd >= 0) { - if (eloInitController(mouse_fd)) { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Using ELO touchscreen\n"); -#endif - mouse_drv = MOUSE_ELO; - } - - } else if (mouse_fd < 0) { - mouse_drv = MOUSE_NONE; - } - - return (mouse_fd); - } - - /* STD MICE */ - - if (mousedev == NULL) { - /* FIXME someday... allow multiple mice in this driver */ - static const char *ps2mice[] = { - "/dev/input/mice", "/dev/usbmouse", "/dev/psaux", NULL - }; - /* First try to use GPM in repeater mode */ - if (mouse_fd < 0) { - char proto[10]; - if (gpm_available(proto, SDL_arraysize(proto))) { - mouse_fd = open(GPM_NODE_FIFO, O_RDONLY, 0); - if (mouse_fd >= 0) { - if (SDL_strcmp(proto, "msc") == 0) { - mouse_drv = MOUSE_MSC; - } else if (SDL_strcmp(proto, "ps2") == 0) { - mouse_drv = MOUSE_PS2; - } else if (SDL_strcmp(proto, "imps2") == 0) { - mouse_drv = MOUSE_IMPS2; - } else if (SDL_strcmp(proto, "ms") == 0 || - SDL_strcmp(proto, "bare") == 0) { - mouse_drv = MOUSE_MS; - } else if (SDL_strcmp(proto, "bm") == 0) { - mouse_drv = MOUSE_BM; - } else { - /* Unknown protocol... */ -#ifdef DEBUG_MOUSE - fprintf(stderr, - "GPM mouse using unknown protocol = %s\n", - proto); -#endif - close(mouse_fd); - mouse_fd = -1; - } - } -#ifdef DEBUG_MOUSE - if (mouse_fd >= 0) { - fprintf(stderr, - "Using GPM mouse, protocol = %s\n", proto); - } -#endif /* DEBUG_MOUSE */ - } - } - /* Now try to use a modern PS/2 mouse */ - for (i = 0; (mouse_fd < 0) && ps2mice[i]; ++i) { - mouse_fd = open(ps2mice[i], O_RDWR, 0); - if (mouse_fd < 0) { - mouse_fd = open(ps2mice[i], O_RDONLY, 0); - } - if (mouse_fd >= 0) { - /* rcg06112001 Attempt to set IMPS/2 mode */ - set_imps2_mode(mouse_fd); - if (detect_imps2(mouse_fd)) { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Using IMPS2 mouse\n"); -#endif - mouse_drv = MOUSE_IMPS2; - } else { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Using PS2 mouse\n"); -#endif - mouse_drv = MOUSE_PS2; - } - } - } - /* Next try to use a PPC ADB port mouse */ - if (mouse_fd < 0) { - mouse_fd = open("/dev/adbmouse", O_RDONLY, 0); - if (mouse_fd >= 0) { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Using ADB mouse\n"); -#endif - mouse_drv = MOUSE_BM; - } - } - } - /* Default to a serial Microsoft mouse */ - if (mouse_fd < 0) { - if (mousedev == NULL) { - mousedev = "/dev/mouse"; - } - mouse_fd = open(mousedev, O_RDONLY, 0); - if (mouse_fd >= 0) { - struct termios mouse_termios; - - /* Set the sampling speed to 1200 baud */ - tcgetattr(mouse_fd, &mouse_termios); - mouse_termios.c_iflag = IGNBRK | IGNPAR; - mouse_termios.c_oflag = 0; - mouse_termios.c_lflag = 0; - mouse_termios.c_line = 0; - mouse_termios.c_cc[VTIME] = 0; - mouse_termios.c_cc[VMIN] = 1; - mouse_termios.c_cflag = CREAD | CLOCAL | HUPCL; - mouse_termios.c_cflag |= CS8; - mouse_termios.c_cflag |= B1200; - tcsetattr(mouse_fd, TCSAFLUSH, &mouse_termios); - if (mousedrv && (SDL_strcmp(mousedrv, "PS2") == 0)) { -#ifdef DEBUG_MOUSE - fprintf(stderr, - "Using (user specified) PS2 mouse on %s\n", mousedev); -#endif - mouse_drv = MOUSE_PS2; - } else { -#ifdef DEBUG_MOUSE - fprintf(stderr, "Using (default) MS mouse on %s\n", mousedev); -#endif - mouse_drv = MOUSE_MS; - } - } - } - if (mouse_fd < 0) { - mouse_drv = MOUSE_NONE; - } - return (mouse_fd); -} - -static int posted = 0; - -void -FB_vgamousecallback(int button, int relative, int dx, int dy) -{ - int button_1, button_3; - int button_state; - int state_changed; - int i; - Uint8 state; - - if (dx || dy) { - posted += SDL_PrivateMouseMotion(0, relative, dx, dy); - } - - /* Swap button 1 and 3 */ - button_1 = (button & 0x04) >> 2; - button_3 = (button & 0x01) << 2; - button &= ~0x05; - button |= (button_1 | button_3); - - /* See what changed */ - button_state = SDL_GetMouseState(NULL, NULL); - state_changed = button_state ^ button; - for (i = 0; i < 8; ++i) { - if (state_changed & (1 << i)) { - if (button & (1 << i)) { - state = SDL_PRESSED; - } else { - state = SDL_RELEASED; - } - posted += SDL_PrivateMouseButton(state, i + 1, 0, 0); - } - } -} - -/* Handle input from tslib */ -#if SDL_INPUT_TSLIB -static void -handle_tslib(_THIS) -{ - struct ts_sample sample; - int button; - - while (ts_read(ts_dev, &sample, 1) > 0) { - button = (sample.pressure > 0) ? 1 : 0; - button <<= 2; /* must report it as button 3 */ - FB_vgamousecallback(button, 0, sample.x, sample.y); - } - return; -} -#endif /* SDL_INPUT_TSLIB */ - -/* For now, use MSC, PS/2, and MS protocols - Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.) - */ -static void -handle_mouse(_THIS) -{ - static int start = 0; - static unsigned char mousebuf[BUFSIZ]; - static int relative = 1; - - int i, nread; - int button = 0; - int dx = 0, dy = 0; - int packetsize = 0; - int realx, realy; - - /* Figure out the mouse packet size */ - switch (mouse_drv) { - case MOUSE_NONE: - /* Ack! */ - read(mouse_fd, mousebuf, BUFSIZ); - return; - case MOUSE_MSC: - packetsize = 5; - break; - case MOUSE_IMPS2: - packetsize = 4; - break; - case MOUSE_PS2: - case MOUSE_MS: - case MOUSE_BM: - packetsize = 3; - break; - case MOUSE_ELO: - /* try to read the next packet */ - if (eloReadPosition - (this, mouse_fd, &dx, &dy, &button, &realx, &realy)) { - button = (button & 0x01) << 2; - FB_vgamousecallback(button, 0, dx, dy); - } - return; /* nothing left to do */ - case MOUSE_TSLIB: -#if SDL_INPUT_TSLIB - handle_tslib(this); -#endif - return; /* nothing left to do */ - default: - /* Uh oh.. */ - packetsize = 0; - break; - } - - /* Special handling for the quite sensitive ELO controller */ - if (mouse_drv == MOUSE_ELO) { - - } - - /* Read as many packets as possible */ - nread = read(mouse_fd, &mousebuf[start], BUFSIZ - start); - if (nread < 0) { - return; - } - nread += start; -#ifdef DEBUG_MOUSE - fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start); -#endif - for (i = 0; i < (nread - (packetsize - 1)); i += packetsize) { - switch (mouse_drv) { - case MOUSE_NONE: - break; - case MOUSE_MSC: - /* MSC protocol has 0x80 in high byte */ - if ((mousebuf[i] & 0xF8) != 0x80) { - /* Go to next byte */ - i -= (packetsize - 1); - continue; - } - /* Get current mouse state */ - button = (~mousebuf[i]) & 0x07; - dx = (signed char) (mousebuf[i + 1]) + - (signed char) (mousebuf[i + 3]); - dy = -((signed char) (mousebuf[i + 2]) + - (signed char) (mousebuf[i + 4])); - break; - case MOUSE_PS2: - /* PS/2 protocol has nothing in high byte */ - if ((mousebuf[i] & 0xC0) != 0) { - /* Go to next byte */ - i -= (packetsize - 1); - continue; - } - /* Get current mouse state */ - button = (mousebuf[i] & 0x04) >> 1 | /*Middle */ - (mousebuf[i] & 0x02) >> 1 | /*Right */ - (mousebuf[i] & 0x01) << 2; /*Left */ - dx = (mousebuf[i] & 0x10) ? - mousebuf[i + 1] - 256 : mousebuf[i + 1]; - dy = (mousebuf[i] & 0x20) ? - -(mousebuf[i + 2] - 256) : -mousebuf[i + 2]; - break; - case MOUSE_IMPS2: - /* Get current mouse state */ - button = (mousebuf[i] & 0x04) >> 1 | /*Middle */ - (mousebuf[i] & 0x02) >> 1 | /*Right */ - (mousebuf[i] & 0x01) << 2 | /*Left */ - (mousebuf[i] & 0x40) >> 3 | /* 4 */ - (mousebuf[i] & 0x80) >> 3; /* 5 */ - dx = (mousebuf[i] & 0x10) ? - mousebuf[i + 1] - 256 : mousebuf[i + 1]; - dy = (mousebuf[i] & 0x20) ? - -(mousebuf[i + 2] - 256) : -mousebuf[i + 2]; - switch (mousebuf[i + 3] & 0x0F) { - case 0x0E: /* DX = +1 */ - case 0x02: /* DX = -1 */ - break; - case 0x0F: /* DY = +1 (map button 4) */ - FB_vgamousecallback(button | (1 << 3), 1, 0, 0); - break; - case 0x01: /* DY = -1 (map button 5) */ - FB_vgamousecallback(button | (1 << 4), 1, 0, 0); - break; - } - break; - case MOUSE_MS: - /* Microsoft protocol has 0x40 in high byte */ - if ((mousebuf[i] & 0x40) != 0x40) { - /* Go to next byte */ - i -= (packetsize - 1); - continue; - } - /* Get current mouse state */ - button = ((mousebuf[i] & 0x20) >> 3) | - ((mousebuf[i] & 0x10) >> 4); - dx = (signed char) (((mousebuf[i] & 0x03) << 6) | - (mousebuf[i + 1] & 0x3F)); - dy = (signed char) (((mousebuf[i] & 0x0C) << 4) | - (mousebuf[i + 2] & 0x3F)); - break; - case MOUSE_BM: - /* BusMouse protocol has 0xF8 in high byte */ - if ((mousebuf[i] & 0xF8) != 0x80) { - /* Go to next byte */ - i -= (packetsize - 1); - continue; - } - /* Get current mouse state */ - button = (~mousebuf[i]) & 0x07; - dx = (signed char) mousebuf[i + 1]; - dy = -(signed char) mousebuf[i + 2]; - break; - default: - /* Uh oh.. */ - dx = 0; - dy = 0; - break; - } - FB_vgamousecallback(button, relative, dx, dy); - } - if (i < nread) { - SDL_memcpy(mousebuf, &mousebuf[i], (nread - i)); - start = (nread - i); - } else { - start = 0; - } - return; -} - -/* Handle switching to another VC, returns when our VC is back */ -static void -switch_vt_prep(_THIS) -{ - SDL_Surface *screen = SDL_VideoSurface; - - SDL_PrivateAppActive(0, - (SDL_APPACTIVE | SDL_APPINPUTFOCUS | - SDL_APPMOUSEFOCUS)); - - /* Save the contents of the screen, and go to text mode */ - wait_idle(this); - screen_arealen = ((screen->h + (2 * this->offset_y)) * screen->pitch); - screen_contents = (Uint8 *) SDL_malloc(screen_arealen); - if (screen_contents) { - SDL_memcpy(screen_contents, screen->pixels, screen_arealen); - } - FB_SavePaletteTo(this, 256, screen_palette); - ioctl(console_fd, FBIOGET_VSCREENINFO, &screen_vinfo); - ioctl(keyboard_fd, KDSETMODE, KD_TEXT); - ioctl(keyboard_fd, VT_UNLOCKSWITCH, 1); -} - -static void -switch_vt_done(_THIS) -{ - SDL_Surface *screen = SDL_VideoSurface; - - /* Restore graphics mode and the contents of the screen */ - ioctl(keyboard_fd, VT_LOCKSWITCH, 1); - ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS); - ioctl(console_fd, FBIOPUT_VSCREENINFO, &screen_vinfo); - FB_RestorePaletteFrom(this, 256, screen_palette); - if (screen_contents) { - SDL_memcpy(screen->pixels, screen_contents, screen_arealen); - SDL_free(screen_contents); - screen_contents = NULL; - } - - /* Get updates to the shadow surface while switched away */ - if (SDL_ShadowSurface) { - SDL_UpdateRect(SDL_ShadowSurface, 0, 0, 0, 0); - } - - SDL_PrivateAppActive(1, - (SDL_APPACTIVE | SDL_APPINPUTFOCUS | - SDL_APPMOUSEFOCUS)); -} - -static void -switch_vt(_THIS, unsigned short which) -{ - struct vt_stat vtstate; - - /* Figure out whether or not we're switching to a new console */ - if ((ioctl(keyboard_fd, VT_GETSTATE, &vtstate) < 0) || - (which == vtstate.v_active)) { - return; - } - - /* New console, switch to it */ - SDL_mutexP(hw_lock); - switch_vt_prep(this); - if (ioctl(keyboard_fd, VT_ACTIVATE, which) == 0) { - ioctl(keyboard_fd, VT_WAITACTIVE, which); - switched_away = 1; - } else { - switch_vt_done(this); - } - SDL_mutexV(hw_lock); -} - -static void -handle_keyboard(_THIS) -{ - unsigned char keybuf[BUFSIZ]; - int i, nread; - int pressed; - int scancode; - SDL_keysym keysym; - - nread = read(keyboard_fd, keybuf, BUFSIZ); - for (i = 0; i < nread; ++i) { - scancode = keybuf[i] & 0x7F; - if (keybuf[i] & 0x80) { - pressed = SDL_RELEASED; - } else { - pressed = SDL_PRESSED; - } - TranslateKey(scancode, &keysym); - /* Handle Ctrl-Alt-FN for vt switch */ - switch (keysym.sym) { - case SDLK_F1: - case SDLK_F2: - case SDLK_F3: - case SDLK_F4: - case SDLK_F5: - case SDLK_F6: - case SDLK_F7: - case SDLK_F8: - case SDLK_F9: - case SDLK_F10: - case SDLK_F11: - case SDLK_F12: - if ((SDL_GetModState() & KMOD_CTRL) && - (SDL_GetModState() & KMOD_ALT)) { - if (pressed) { - switch_vt(this, (keysym.sym - SDLK_F1) + 1); - } - break; - } - /* Fall through to normal processing */ - default: - posted += SDL_PrivateKeyboard(pressed, &keysym); - break; - } - } -} - -void -FB_PumpEvents(_THIS) -{ - fd_set fdset; - int max_fd; - static struct timeval zero; - - do { - if (switched_away) { - struct vt_stat vtstate; - - SDL_mutexP(hw_lock); - if ((ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0) && - vtstate.v_active == current_vt) { - switched_away = 0; - switch_vt_done(this); - } - SDL_mutexV(hw_lock); - } - - posted = 0; - - FD_ZERO(&fdset); - max_fd = 0; - if (keyboard_fd >= 0) { - FD_SET(keyboard_fd, &fdset); - if (max_fd < keyboard_fd) { - max_fd = keyboard_fd; - } - } - if (mouse_fd >= 0) { - FD_SET(mouse_fd, &fdset); - if (max_fd < mouse_fd) { - max_fd = mouse_fd; - } - } - if (select(max_fd + 1, &fdset, NULL, NULL, &zero) > 0) { - if (keyboard_fd >= 0) { - if (FD_ISSET(keyboard_fd, &fdset)) { - handle_keyboard(this); - } - } - if (mouse_fd >= 0) { - if (FD_ISSET(mouse_fd, &fdset)) { - handle_mouse(this); - } - } - } - } while (posted); -} - -void -FB_InitOSKeymap(_THIS) -{ - int i; - - /* Initialize the Linux key translation table */ - - /* First get the ascii keys and others not well handled */ - for (i = 0; i < SDL_arraysize(keymap); ++i) { - switch (i) { - /* These aren't handled by the x86 kernel keymapping (?) */ - case SCANCODE_PRINTSCREEN: - keymap[i] = SDLK_PRINT; - break; - case SCANCODE_BREAK: - keymap[i] = SDLK_BREAK; - break; - case SCANCODE_BREAK_ALTERNATIVE: - keymap[i] = SDLK_PAUSE; - break; - case SCANCODE_LEFTSHIFT: - keymap[i] = SDLK_LSHIFT; - break; - case SCANCODE_RIGHTSHIFT: - keymap[i] = SDLK_RSHIFT; - break; - case SCANCODE_LEFTCONTROL: - keymap[i] = SDLK_LCTRL; - break; - case SCANCODE_RIGHTCONTROL: - keymap[i] = SDLK_RCTRL; - break; - case SCANCODE_RIGHTWIN: - keymap[i] = SDLK_RSUPER; - break; - case SCANCODE_LEFTWIN: - keymap[i] = SDLK_LSUPER; - break; - case SCANCODE_LEFTALT: - keymap[i] = SDLK_LALT; - break; - case SCANCODE_RIGHTALT: - keymap[i] = SDLK_RALT; - break; - case 127: - keymap[i] = SDLK_MENU; - break; - /* this should take care of all standard ascii keys */ - default: - keymap[i] = KVAL(vga_keymap[0][i]); - break; - } - } - for (i = 0; i < SDL_arraysize(keymap); ++i) { - switch (keymap_temp[i]) { - case K_F1: - keymap[i] = SDLK_F1; - break; - case K_F2: - keymap[i] = SDLK_F2; - break; - case K_F3: - keymap[i] = SDLK_F3; - break; - case K_F4: - keymap[i] = SDLK_F4; - break; - case K_F5: - keymap[i] = SDLK_F5; - break; - case K_F6: - keymap[i] = SDLK_F6; - break; - case K_F7: - keymap[i] = SDLK_F7; - break; - case K_F8: - keymap[i] = SDLK_F8; - break; - case K_F9: - keymap[i] = SDLK_F9; - break; - case K_F10: - keymap[i] = SDLK_F10; - break; - case K_F11: - keymap[i] = SDLK_F11; - break; - case K_F12: - keymap[i] = SDLK_F12; - break; - - case K_DOWN: - keymap[i] = SDLK_DOWN; - break; - case K_LEFT: - keymap[i] = SDLK_LEFT; - break; - case K_RIGHT: - keymap[i] = SDLK_RIGHT; - break; - case K_UP: - keymap[i] = SDLK_UP; - break; - - case K_P0: - keymap[i] = SDLK_KP0; - break; - case K_P1: - keymap[i] = SDLK_KP1; - break; - case K_P2: - keymap[i] = SDLK_KP2; - break; - case K_P3: - keymap[i] = SDLK_KP3; - break; - case K_P4: - keymap[i] = SDLK_KP4; - break; - case K_P5: - keymap[i] = SDLK_KP5; - break; - case K_P6: - keymap[i] = SDLK_KP6; - break; - case K_P7: - keymap[i] = SDLK_KP7; - break; - case K_P8: - keymap[i] = SDLK_KP8; - break; - case K_P9: - keymap[i] = SDLK_KP9; - break; - case K_PPLUS: - keymap[i] = SDLK_KP_PLUS; - break; - case K_PMINUS: - keymap[i] = SDLK_KP_MINUS; - break; - case K_PSTAR: - keymap[i] = SDLK_KP_MULTIPLY; - break; - case K_PSLASH: - keymap[i] = SDLK_KP_DIVIDE; - break; - case K_PENTER: - keymap[i] = SDLK_KP_ENTER; - break; - case K_PDOT: - keymap[i] = SDLK_KP_PERIOD; - break; - - case K_SHIFT: - if (keymap[i] != SDLK_RSHIFT) - keymap[i] = SDLK_LSHIFT; - break; - case K_SHIFTL: - keymap[i] = SDLK_LSHIFT; - break; - case K_SHIFTR: - keymap[i] = SDLK_RSHIFT; - break; - case K_CTRL: - if (keymap[i] != SDLK_RCTRL) - keymap[i] = SDLK_LCTRL; - break; - case K_CTRLL: - keymap[i] = SDLK_LCTRL; - break; - case K_CTRLR: - keymap[i] = SDLK_RCTRL; - break; - case K_ALT: - keymap[i] = SDLK_LALT; - break; - case K_ALTGR: - keymap[i] = SDLK_RALT; - break; - - case K_INSERT: - keymap[i] = SDLK_INSERT; - break; - case K_REMOVE: - keymap[i] = SDLK_DELETE; - break; - case K_PGUP: - keymap[i] = SDLK_PAGEUP; - break; - case K_PGDN: - keymap[i] = SDLK_PAGEDOWN; - break; - case K_FIND: - keymap[i] = SDLK_HOME; - break; - case K_SELECT: - keymap[i] = SDLK_END; - break; - - case K_NUM: - keymap[i] = SDLK_NUMLOCK; - break; - case K_CAPS: - keymap[i] = SDLK_CAPSLOCK; - break; - - case K_F13: - keymap[i] = SDLK_PRINT; - break; - case K_HOLD: - keymap[i] = SDLK_SCROLLOCK; - break; - case K_PAUSE: - keymap[i] = SDLK_PAUSE; - break; - - case 127: - keymap[i] = SDLK_BACKSPACE; - break; - - default: - break; - } - } -} - -static SDL_keysym * -TranslateKey(int scancode, SDL_keysym * keysym) -{ - /* Set the keysym information */ - keysym->scancode = scancode; - keysym->sym = keymap[scancode]; - keysym->mod = KMOD_NONE; - - /* If UNICODE is on, get the UNICODE value for the key */ - keysym->unicode = 0; - if (SDL_TranslateUNICODE) { - int map; - SDLMod modstate; - - modstate = SDL_GetModState(); - map = 0; - if (modstate & KMOD_SHIFT) { - map |= (1 << KG_SHIFT); - } - if (modstate & KMOD_CTRL) { - map |= (1 << KG_CTRL); - } - if (modstate & KMOD_LALT) { - map |= (1 << KG_ALT); - } - if (modstate & KMOD_RALT) { - map |= (1 << KG_ALTGR); - } - if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) { - if (modstate & KMOD_CAPS) { - map ^= (1 << KG_SHIFT); - } - } - if (KTYP(vga_keymap[map][scancode]) == KT_PAD) { - if (modstate & KMOD_NUM) { - keysym->unicode = KVAL(vga_keymap[map][scancode]); - } - } else { - keysym->unicode = KVAL(vga_keymap[map][scancode]); - } - } - return (keysym); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbevents_c.h b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbevents_c.h deleted file mode 100644 index 150e2b2a9..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbevents_c.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_fbvideo.h" - -/* Variables and functions exported by SDL_sysevents.c to other parts - of the native video subsystem (SDL_sysvideo.c) -*/ -extern int FB_OpenKeyboard(_THIS); -extern void FB_CloseKeyboard(_THIS); -extern int FB_OpenMouse(_THIS); -extern void FB_CloseMouse(_THIS); -extern int FB_EnterGraphicsMode(_THIS); -extern int FB_InGraphicsMode(_THIS); -extern void FB_LeaveGraphicsMode(_THIS); - -extern void FB_InitOSKeymap(_THIS); -extern void FB_PumpEvents(_THIS); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbkeys.h b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbkeys.h deleted file mode 100644 index 1f5117c32..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbkeys.h +++ /dev/null @@ -1,139 +0,0 @@ - -/* Scancodes for the Linux framebuffer console - - Taken with thanks from SVGAlib 1.4.0 -*/ - -#define SCANCODE_ESCAPE 1 - -#define SCANCODE_1 2 -#define SCANCODE_2 3 -#define SCANCODE_3 4 -#define SCANCODE_4 5 -#define SCANCODE_5 6 -#define SCANCODE_6 7 -#define SCANCODE_7 8 -#define SCANCODE_8 9 -#define SCANCODE_9 10 -#define SCANCODE_0 11 - -#define SCANCODE_MINUS 12 -#define SCANCODE_EQUAL 13 - -#define SCANCODE_BACKSPACE 14 -#define SCANCODE_TAB 15 - -#define SCANCODE_Q 16 -#define SCANCODE_W 17 -#define SCANCODE_E 18 -#define SCANCODE_R 19 -#define SCANCODE_T 20 -#define SCANCODE_Y 21 -#define SCANCODE_U 22 -#define SCANCODE_I 23 -#define SCANCODE_O 24 -#define SCANCODE_P 25 -#define SCANCODE_BRACKET_LEFT 26 -#define SCANCODE_BRACKET_RIGHT 27 - -#define SCANCODE_ENTER 28 - -#define SCANCODE_LEFTCONTROL 29 - -#define SCANCODE_A 30 -#define SCANCODE_S 31 -#define SCANCODE_D 32 -#define SCANCODE_F 33 -#define SCANCODE_G 34 -#define SCANCODE_H 35 -#define SCANCODE_J 36 -#define SCANCODE_K 37 -#define SCANCODE_L 38 -#define SCANCODE_SEMICOLON 39 -#define SCANCODE_APOSTROPHE 40 -#define SCANCODE_GRAVE 41 - -#define SCANCODE_LEFTSHIFT 42 -#define SCANCODE_BACKSLASH 43 - -#define SCANCODE_Z 44 -#define SCANCODE_X 45 -#define SCANCODE_C 46 -#define SCANCODE_V 47 -#define SCANCODE_B 48 -#define SCANCODE_N 49 -#define SCANCODE_M 50 -#define SCANCODE_COMMA 51 -#define SCANCODE_PERIOD 52 -#define SCANCODE_SLASH 53 - -#define SCANCODE_RIGHTSHIFT 54 -#define SCANCODE_KEYPADMULTIPLY 55 - -#define SCANCODE_LEFTALT 56 -#define SCANCODE_SPACE 57 -#define SCANCODE_CAPSLOCK 58 - -#define SCANCODE_F1 59 -#define SCANCODE_F2 60 -#define SCANCODE_F3 61 -#define SCANCODE_F4 62 -#define SCANCODE_F5 63 -#define SCANCODE_F6 64 -#define SCANCODE_F7 65 -#define SCANCODE_F8 66 -#define SCANCODE_F9 67 -#define SCANCODE_F10 68 - -#define SCANCODE_NUMLOCK 69 -#define SCANCODE_SCROLLLOCK 70 - -#define SCANCODE_KEYPAD7 71 -#define SCANCODE_CURSORUPLEFT 71 -#define SCANCODE_KEYPAD8 72 -#define SCANCODE_CURSORUP 72 -#define SCANCODE_KEYPAD9 73 -#define SCANCODE_CURSORUPRIGHT 73 -#define SCANCODE_KEYPADMINUS 74 -#define SCANCODE_KEYPAD4 75 -#define SCANCODE_CURSORLEFT 75 -#define SCANCODE_KEYPAD5 76 -#define SCANCODE_KEYPAD6 77 -#define SCANCODE_CURSORRIGHT 77 -#define SCANCODE_KEYPADPLUS 78 -#define SCANCODE_KEYPAD1 79 -#define SCANCODE_CURSORDOWNLEFT 79 -#define SCANCODE_KEYPAD2 80 -#define SCANCODE_CURSORDOWN 80 -#define SCANCODE_KEYPAD3 81 -#define SCANCODE_CURSORDOWNRIGHT 81 -#define SCANCODE_KEYPAD0 82 -#define SCANCODE_KEYPADPERIOD 83 - -#define SCANCODE_LESS 86 - -#define SCANCODE_F11 87 -#define SCANCODE_F12 88 - -#define SCANCODE_KEYPADENTER 96 -#define SCANCODE_RIGHTCONTROL 97 -#define SCANCODE_CONTROL 97 -#define SCANCODE_KEYPADDIVIDE 98 -#define SCANCODE_PRINTSCREEN 99 -#define SCANCODE_RIGHTALT 100 -#define SCANCODE_BREAK 101 /* Beware: is 119 */ -#define SCANCODE_BREAK_ALTERNATIVE 119 /* on some keyboards! */ - -#define SCANCODE_HOME 102 -#define SCANCODE_CURSORBLOCKUP 103 /* Cursor key block */ -#define SCANCODE_PAGEUP 104 -#define SCANCODE_CURSORBLOCKLEFT 105 /* Cursor key block */ -#define SCANCODE_CURSORBLOCKRIGHT 106 /* Cursor key block */ -#define SCANCODE_END 107 -#define SCANCODE_CURSORBLOCKDOWN 108 /* Cursor key block */ -#define SCANCODE_PAGEDOWN 109 -#define SCANCODE_INSERT 110 -#define SCANCODE_REMOVE 111 - -#define SCANCODE_RIGHTWIN 126 -#define SCANCODE_LEFTWIN 125 -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmatrox.c b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmatrox.c deleted file mode 100644 index 888a0ab21..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmatrox.c +++ /dev/null @@ -1,285 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" -#include "../SDL_blit.h" -#include "SDL_fbmatrox.h" -#include "matrox_mmio.h" - - -/* Wait for vertical retrace - taken from the XFree86 Matrox driver */ -static void -WaitVBL(_THIS) -{ - int count; - - /* find start of retrace */ - mga_waitidle(); - while ((mga_in8(0x1FDA) & 0x08)); - while (!(mga_in8(0x1FDA) & 0x08)); - /* wait until we're past the start */ - count = mga_in32(0x1E20) + 2; - while (mga_in32(0x1E20) < count); -} - -static void -WaitIdle(_THIS) -{ - mga_waitidle(); -} - -/* Sets video mem colorkey and accelerated blit function */ -static int -SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) -{ - return (0); -} - -/* Sets per surface hardware alpha value */ -#if 0 -static int -SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value) -{ - return (0); -} -#endif - -static int -FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) -{ - int dstX, dstY; - Uint32 fxbndry; - Uint32 ydstlen; - Uint32 fillop; - - /* Don't blit to the display surface when switched away */ - if (switched_away) { - return -2; /* no hardware access */ - } - if (dst == this->screen) { - SDL_mutexP(hw_lock); - } - - switch (dst->format->BytesPerPixel) { - case 1: - color |= (color << 8); - case 2: - color |= (color << 16); - break; - } - - /* Set up the X/Y base coordinates */ - FB_dst_to_xy(this, dst, &dstX, &dstY); - - /* Adjust for the current rectangle */ - dstX += rect->x; - dstY += rect->y; - - /* Set up the X boundaries */ - fxbndry = (dstX | ((dstX + rect->w) << 16)); - - /* Set up the Y boundaries */ - ydstlen = (rect->h | (dstY << 16)); - - /* Set up for color fill operation */ - fillop = MGADWG_TRAP | MGADWG_SOLID | - MGADWG_ARZERO | MGADWG_SGNZERO | MGADWG_SHIFTZERO; - - /* Execute the operations! */ - mga_wait(5); - mga_out32(MGAREG_DWGCTL, fillop | MGADWG_REPLACE); - mga_out32(MGAREG_FCOL, color); - mga_out32(MGAREG_FXBNDRY, fxbndry); - mga_out32(MGAREG_YDSTLEN + MGAREG_EXEC, ydstlen); - - FB_AddBusySurface(dst); - - if (dst == this->screen) { - SDL_mutexV(hw_lock); - } - return (0); -} - -static int -HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) -{ - SDL_VideoDevice *this = current_video; - int pitch, w, h; - int srcX, srcY; - int dstX, dstY; - Uint32 sign; - Uint32 start, stop; - int skip; - Uint32 blitop; - - /* FIXME: For now, only blit to display surface */ - if (dst->pitch != SDL_VideoSurface->pitch) { - return (src->map->sw_blit(src, srcrect, dst, dstrect)); - } - - /* Don't blit to the display surface when switched away */ - if (switched_away) { - return -2; /* no hardware access */ - } - if (dst == this->screen) { - SDL_mutexP(hw_lock); - } - - /* Calculate source and destination base coordinates (in pixels) */ - w = dstrect->w; - h = dstrect->h; - FB_dst_to_xy(this, src, &srcX, &srcY); - FB_dst_to_xy(this, dst, &dstX, &dstY); - - /* Adjust for the current blit rectangles */ - srcX += srcrect->x; - srcY += srcrect->y; - dstX += dstrect->x; - dstY += dstrect->y; - pitch = dst->pitch / dst->format->BytesPerPixel; - - /* Set up the blit direction (sign) flags */ - sign = 0; - if (srcX < dstX) { - sign |= 1; - } - if (srcY < dstY) { - sign |= 4; - srcY += (h - 1); - dstY += (h - 1); - } - - /* Set up the blit source row start, end, and skip (in pixels) */ - stop = start = (srcY * pitch) + srcX; - if (srcX < dstX) { - start += (w - 1); - } else { - stop += (w - 1); - } - if (srcY < dstY) { - skip = -pitch; - } else { - skip = pitch; - } - - /* Set up the blit operation */ - if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - Uint32 colorkey; - - blitop = MGADWG_BFCOL | MGADWG_BITBLT | - MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16) | MGADWG_TRANSC; - - colorkey = src->format->colorkey; - switch (dst->format->BytesPerPixel) { - case 1: - colorkey |= (colorkey << 8); - case 2: - colorkey |= (colorkey << 16); - break; - } - mga_wait(2); - mga_out32(MGAREG_FCOL, colorkey); - mga_out32(MGAREG_BCOL, 0xFFFFFFFF); - } else { - blitop = MGADWG_BFCOL | MGADWG_BITBLT | - MGADWG_SHIFTZERO | MGADWG_RSTR | (0x0C << 16); - } - mga_wait(7); - mga_out32(MGAREG_SGN, sign); - mga_out32(MGAREG_AR3, start); - mga_out32(MGAREG_AR0, stop); - mga_out32(MGAREG_AR5, skip); - mga_out32(MGAREG_FXBNDRY, (dstX | ((dstX + w - 1) << 16))); - mga_out32(MGAREG_YDSTLEN, (dstY << 16) | h); - mga_out32(MGAREG_DWGCTL + MGAREG_EXEC, blitop); - - FB_AddBusySurface(src); - FB_AddBusySurface(dst); - - if (dst == this->screen) { - SDL_mutexV(hw_lock); - } - return (0); -} - -static int -CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) -{ - int accelerated; - - /* Set initial acceleration on */ - src->flags |= SDL_HWACCEL; - - /* Set the surface attributes */ - if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { - if (!this->info.blit_hw_A) { - src->flags &= ~SDL_HWACCEL; - } - } - if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - if (!this->info.blit_hw_CC) { - src->flags &= ~SDL_HWACCEL; - } - } - - /* Check to see if final surface blit is accelerated */ - accelerated = !!(src->flags & SDL_HWACCEL); - if (accelerated) { - src->map->hw_blit = HWAccelBlit; - } - return (accelerated); -} - -void -FB_MatroxAccel(_THIS, __u32 card) -{ - /* We have hardware accelerated surface functions */ - this->CheckHWBlit = CheckHWBlit; - wait_vbl = WaitVBL; - wait_idle = WaitIdle; - - /* The Matrox has an accelerated color fill */ - this->info.blit_fill = 1; - this->FillHWRect = FillHWRect; - - /* The Matrox has accelerated normal and colorkey blits. */ - this->info.blit_hw = 1; - /* The Millenium I appears to do the colorkey test a word - at a time, and the transparency is intverted. (?) - */ - if (card != FB_ACCEL_MATROX_MGA2064W) { - this->info.blit_hw_CC = 1; - this->SetHWColorKey = SetHWColorKey; - } -#if 0 /* Not yet implemented? */ - /* The Matrox G200/G400 has an accelerated alpha blit */ - if ((card == FB_ACCEL_MATROX_MGAG200) - || (card == FB_ACCEL_MATROX_MGAG400)) { - this->info.blit_hw_A = 1; - this->SetHWAlpha = SetHWAlpha; - } -#endif -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmatrox.h b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmatrox.h deleted file mode 100644 index b1bfdb142..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmatrox.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Matrox hardware acceleration for the SDL framebuffer console driver */ - -#include "SDL_fbvideo.h" - -/* Set up the driver for Matrox acceleration */ -extern void FB_MatroxAccel(_THIS, __u32 card); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmouse.c b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmouse.c deleted file mode 100644 index 681ddf3bd..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmouse.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_mouse.h" -#include "../../events/SDL_events_c.h" -#include "SDL_fbvideo.h" -#include "SDL_fbmouse_c.h" - - -/* The implementation dependent data for the window manager cursor */ -struct WMcursor -{ - int unused; -}; -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmouse_c.h b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmouse_c.h deleted file mode 100644 index 97f85c711..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbmouse_c.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_fbvideo.h" - -/* Functions to be exported */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbriva.c b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbriva.c deleted file mode 100644 index 06fc60afa..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbriva.c +++ /dev/null @@ -1,231 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" -#include "../SDL_blit.h" -#include "SDL_fbriva.h" -#include "riva_mmio.h" -#include "riva_regs.h" - - -static int FifoEmptyCount = 0; -static int FifoFreeCount = 0; - -/* Wait for vertical retrace */ -static void -WaitVBL(_THIS) -{ - volatile Uint8 *port = (Uint8 *) (mapped_io + PCIO_OFFSET + 0x3DA); - - while ((*port & 0x08)); - while (!(*port & 0x08)); -} - -static void -NV3WaitIdle(_THIS) -{ - RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET); - while ((Rop->FifoFree < FifoEmptyCount) || - (*(mapped_io + PGRAPH_OFFSET + 0x000006B0) & 0x01)); -} - -static void -NV4WaitIdle(_THIS) -{ - RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET); - while ((Rop->FifoFree < FifoEmptyCount) || - (*(mapped_io + PGRAPH_OFFSET + 0x00000700) & 0x01)); -} - -#if 0 /* Not yet implemented? */ -/* Sets video mem colorkey and accelerated blit function */ -static int -SetHWColorKey(_THIS, SDL_Surface * surface, Uint32 key) -{ - return (0); -} - -/* Sets per surface hardware alpha value */ -static int -SetHWAlpha(_THIS, SDL_Surface * surface, Uint8 value) -{ - return (0); -} -#endif /* Not yet implemented */ - -static int -FillHWRect(_THIS, SDL_Surface * dst, SDL_Rect * rect, Uint32 color) -{ - int dstX, dstY; - int dstW, dstH; - RivaBitmap *Bitmap = (RivaBitmap *) (mapped_io + BITMAP_OFFSET); - - /* Don't blit to the display surface when switched away */ - if (switched_away) { - return -2; /* no hardware access */ - } - if (dst == this->screen) { - SDL_mutexP(hw_lock); - } - - /* Set up the X/Y base coordinates */ - dstW = rect->w; - dstH = rect->h; - FB_dst_to_xy(this, dst, &dstX, &dstY); - - /* Adjust for the current rectangle */ - dstX += rect->x; - dstY += rect->y; - - RIVA_FIFO_FREE(Bitmap, 1); - Bitmap->Color1A = color; - - RIVA_FIFO_FREE(Bitmap, 2); - Bitmap->UnclippedRectangle[0].TopLeft = (dstX << 16) | dstY; - Bitmap->UnclippedRectangle[0].WidthHeight = (dstW << 16) | dstH; - - FB_AddBusySurface(dst); - - if (dst == this->screen) { - SDL_mutexV(hw_lock); - } - return (0); -} - -static int -HWAccelBlit(SDL_Surface * src, SDL_Rect * srcrect, - SDL_Surface * dst, SDL_Rect * dstrect) -{ - SDL_VideoDevice *this = current_video; - int srcX, srcY; - int dstX, dstY; - int dstW, dstH; - RivaScreenBlt *Blt = (RivaScreenBlt *) (mapped_io + BLT_OFFSET); - - /* FIXME: For now, only blit to display surface */ - if (dst->pitch != SDL_VideoSurface->pitch) { - return (src->map->sw_blit(src, srcrect, dst, dstrect)); - } - - /* Don't blit to the display surface when switched away */ - if (switched_away) { - return -2; /* no hardware access */ - } - if (dst == this->screen) { - SDL_mutexP(hw_lock); - } - - /* Calculate source and destination base coordinates (in pixels) */ - dstW = dstrect->w; - dstH = dstrect->h; - FB_dst_to_xy(this, src, &srcX, &srcY); - FB_dst_to_xy(this, dst, &dstX, &dstY); - - /* Adjust for the current blit rectangles */ - srcX += srcrect->x; - srcY += srcrect->y; - dstX += dstrect->x; - dstY += dstrect->y; - - RIVA_FIFO_FREE(Blt, 3); - Blt->TopLeftSrc = (srcY << 16) | srcX; - Blt->TopLeftDst = (dstY << 16) | dstX; - Blt->WidthHeight = (dstH << 16) | dstW; - - FB_AddBusySurface(src); - FB_AddBusySurface(dst); - - if (dst == this->screen) { - SDL_mutexV(hw_lock); - } - return (0); -} - -static int -CheckHWBlit(_THIS, SDL_Surface * src, SDL_Surface * dst) -{ - int accelerated; - - /* Set initial acceleration on */ - src->flags |= SDL_HWACCEL; - - /* Set the surface attributes */ - if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) { - if (!this->info.blit_hw_A) { - src->flags &= ~SDL_HWACCEL; - } - } - if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) { - if (!this->info.blit_hw_CC) { - src->flags &= ~SDL_HWACCEL; - } - } - - /* Check to see if final surface blit is accelerated */ - accelerated = !!(src->flags & SDL_HWACCEL); - if (accelerated) { - src->map->hw_blit = HWAccelBlit; - } - return (accelerated); -} - -void -FB_RivaAccel(_THIS, __u32 card) -{ - RivaRop *Rop = (RivaRop *) (mapped_io + ROP_OFFSET); - - /* We have hardware accelerated surface functions */ - this->CheckHWBlit = CheckHWBlit; - wait_vbl = WaitVBL; - switch (card) { - case FB_ACCEL_NV3: - wait_idle = NV3WaitIdle; - break; - case FB_ACCEL_NV4: - wait_idle = NV4WaitIdle; - break; - default: - /* Hmm... FIXME */ - break; - } - FifoEmptyCount = Rop->FifoFree; - - /* The Riva has an accelerated color fill */ - this->info.blit_fill = 1; - this->FillHWRect = FillHWRect; - - /* The Riva has accelerated normal and colorkey blits. */ - this->info.blit_hw = 1; -#if 0 /* Not yet implemented? */ - this->info.blit_hw_CC = 1; - this->SetHWColorKey = SetHWColorKey; -#endif - -#if 0 /* Not yet implemented? */ - /* The Riva has an accelerated alpha blit */ - this->info.blit_hw_A = 1; - this->SetHWAlpha = SetHWAlpha; -#endif -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbvideo.c b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbvideo.c deleted file mode 100644 index c494dd7bf..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbvideo.c +++ /dev/null @@ -1,1815 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Framebuffer console based SDL video driver implementation. -*/ - -#include -#include -#include -#include -#include - -#ifndef HAVE_GETPAGESIZE -#include /* For definition of PAGE_SIZE */ -#endif - -#include - -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" -#include "SDL_fbvideo.h" -#include "SDL_fbmouse_c.h" -#include "SDL_fbevents_c.h" -#include "SDL_fb3dfx.h" -#include "SDL_fbmatrox.h" -#include "SDL_fbriva.h" - -/*#define FBCON_DEBUG*/ - -#if defined(i386) && defined(FB_TYPE_VGA_PLANES) -#define VGA16_FBCON_SUPPORT -#include /* For ioperm() */ -#ifndef FB_AUX_VGA_PLANES_VGA4 -#define FB_AUX_VGA_PLANES_VGA4 0 -#endif -/* -static inline void outb (unsigned char value, unsigned short port) -{ - __asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "Nd" (port)); -} -*/ -#endif /* FB_TYPE_VGA_PLANES */ - -/* A list of video resolutions that we query for (sorted largest to smallest) */ -static const SDL_Rect checkres[] = { - {0, 0, 1600, 1200}, /* 16 bpp: 0x11E, or 286 */ - {0, 0, 1408, 1056}, /* 16 bpp: 0x19A, or 410 */ - {0, 0, 1280, 1024}, /* 16 bpp: 0x11A, or 282 */ - {0, 0, 1152, 864}, /* 16 bpp: 0x192, or 402 */ - {0, 0, 1024, 768}, /* 16 bpp: 0x117, or 279 */ - {0, 0, 960, 720}, /* 16 bpp: 0x18A, or 394 */ - {0, 0, 800, 600}, /* 16 bpp: 0x114, or 276 */ - {0, 0, 768, 576}, /* 16 bpp: 0x182, or 386 */ - {0, 0, 720, 576}, /* PAL */ - {0, 0, 720, 480}, /* NTSC */ - {0, 0, 640, 480}, /* 16 bpp: 0x111, or 273 */ - {0, 0, 640, 400}, /* 8 bpp: 0x100, or 256 */ - {0, 0, 512, 384}, - {0, 0, 320, 240}, - {0, 0, 320, 200} -}; - -static const struct -{ - int xres; - int yres; - int pixclock; - int left; - int right; - int upper; - int lower; - int hslen; - int vslen; - int sync; - int vmode; -} vesa_timings[] = { -#ifdef USE_VESA_TIMINGS /* Only tested on Matrox Millenium I */ - { - 640, 400, 39771, 48, 16, 39, 8, 96, 2, 2, 0}, /* 70 Hz */ - { - 640, 480, 39683, 48, 16, 33, 10, 96, 2, 0, 0}, /* 60 Hz */ - { - 768, 576, 26101, 144, 16, 28, 6, 112, 4, 0, 0}, /* 60 Hz */ - { - 800, 600, 24038, 144, 24, 28, 8, 112, 6, 0, 0}, /* 60 Hz */ - { - 960, 720, 17686, 144, 24, 28, 8, 112, 4, 0, 0}, /* 60 Hz */ - { - 1024, 768, 15386, 160, 32, 30, 4, 128, 4, 0, 0}, /* 60 Hz */ - { - 1152, 864, 12286, 192, 32, 30, 4, 128, 4, 0, 0}, /* 60 Hz */ - { - 1280, 1024, 9369, 224, 32, 32, 4, 136, 4, 0, 0}, /* 60 Hz */ - { - 1408, 1056, 8214, 256, 40, 32, 5, 144, 5, 0, 0}, /* 60 Hz */ - { - 1600, 1200, /*? */ 0, 272, 48, 32, 5, 152, 5, 0, 0}, /* 60 Hz */ -#else - /* You can generate these timings from your XF86Config file using - the 'modeline2fb' perl script included with the fbset package. - These timings were generated for Matrox Millenium I, 15" monitor. - */ - { - 320, 200, 79440, 16, 16, 20, 4, 48, 1, 0, 2}, /* 70 Hz */ - { - 320, 240, 63492, 16, 16, 16, 4, 48, 2, 0, 2}, /* 72 Hz */ - { - 512, 384, 49603, 48, 16, 16, 1, 64, 3, 0, 0}, /* 78 Hz */ - { - 640, 400, 31746, 96, 32, 41, 1, 64, 3, 2, 0}, /* 85 Hz */ - { - 640, 480, 31746, 120, 16, 16, 1, 64, 3, 0, 0}, /* 75 Hz */ - { - 768, 576, 26101, 144, 16, 28, 6, 112, 4, 0, 0}, /* 60 Hz */ - { - 800, 600, 20000, 64, 56, 23, 37, 120, 6, 3, 0}, /* 72 Hz */ - { - 960, 720, 17686, 144, 24, 28, 8, 112, 4, 0, 0}, /* 60 Hz */ - { - 1024, 768, 13333, 144, 24, 29, 3, 136, 6, 0, 0}, /* 70 Hz */ - { - 1152, 864, 12286, 192, 32, 30, 4, 128, 4, 0, 0}, /* 60 Hz */ - { - 1280, 1024, 9369, 224, 32, 32, 4, 136, 4, 0, 0}, /* 60 Hz */ - { - 1408, 1056, 8214, 256, 40, 32, 5, 144, 5, 0, 0}, /* 60 Hz */ - { - 1600, 1200, /*? */ 0, 272, 48, 32, 5, 152, 5, 0, 0}, /* 60 Hz */ -#endif -}; - -/* Initialization/Query functions */ -static int FB_VideoInit(_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **FB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); -static SDL_Surface *FB_SetVideoMode(_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -#ifdef VGA16_FBCON_SUPPORT -static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -#endif -static int FB_SetColors(_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void FB_VideoQuit(_THIS); - -/* Hardware surface functions */ -static int FB_InitHWSurfaces(_THIS, SDL_Surface * screen, char *base, - int size); -static void FB_FreeHWSurfaces(_THIS); -static int FB_AllocHWSurface(_THIS, SDL_Surface * surface); -static int FB_LockHWSurface(_THIS, SDL_Surface * surface); -static void FB_UnlockHWSurface(_THIS, SDL_Surface * surface); -static void FB_FreeHWSurface(_THIS, SDL_Surface * surface); -static void FB_WaitVBL(_THIS); -static void FB_WaitIdle(_THIS); -static int FB_FlipHWSurface(_THIS, SDL_Surface * surface); - -/* Internal palette functions */ -static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, - struct fb_var_screeninfo *vinfo); -static void FB_RestorePalette(_THIS); - -static int -SDL_getpagesize(void) -{ -#ifdef HAVE_GETPAGESIZE - return getpagesize(); -#elif defined(PAGE_SIZE) - return PAGE_SIZE; -#else -#error Can not determine system page size. - /* this is what it USED to be in Linux... */ - return 4096; -#endif -} - - -/* Small wrapper for mmap() so we can play nicely with no-mmu hosts - * (non-mmu hosts disallow the MAP_SHARED flag) */ - -static void * -do_mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset) -{ - void *ret; - ret = mmap(start, length, prot, flags, fd, offset); - if (ret == (char *) -1 && (flags & MAP_SHARED)) { - ret = mmap(start, length, prot, - (flags & ~MAP_SHARED) | MAP_PRIVATE, fd, offset); - } - return ret; -} - -/* FB driver bootstrap functions */ - -static int -FB_Available(void) -{ - int console = -1; - /* Added check for /fb/0 (devfs) */ - /* but - use environment variable first... if it fails, still check defaults */ - int idx = 0; - const char *SDL_fbdevs[4] = { NULL, "/dev/fb0", "/dev/fb/0", NULL }; - - SDL_fbdevs[0] = SDL_getenv("SDL_FBDEV"); - if (!SDL_fbdevs[0]) - idx++; - for (; SDL_fbdevs[idx]; idx++) { - console = open(SDL_fbdevs[idx], O_RDWR, 0); - if (console >= 0) { - close(console); - break; - } - } - return (console >= 0); -} - -static void -FB_DeleteDevice(SDL_VideoDevice * device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_VideoDevice * -FB_CreateDevice(int devindex) -{ - SDL_VideoDevice *this; - - /* Initialize all variables that we clean on shutdown */ - this = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); - if (this) { - SDL_memset(this, 0, (sizeof *this)); - this->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *this->hidden)); - } - if ((this == NULL) || (this->hidden == NULL)) { - SDL_OutOfMemory(); - if (this) { - SDL_free(this); - } - return (0); - } - SDL_memset(this->hidden, 0, (sizeof *this->hidden)); - wait_vbl = FB_WaitVBL; - wait_idle = FB_WaitIdle; - mouse_fd = -1; - keyboard_fd = -1; - - /* Set the function pointers */ - this->VideoInit = FB_VideoInit; - this->ListModes = FB_ListModes; - this->SetVideoMode = FB_SetVideoMode; - this->SetColors = FB_SetColors; - this->UpdateRects = NULL; - this->VideoQuit = FB_VideoQuit; - this->AllocHWSurface = FB_AllocHWSurface; - this->CheckHWBlit = NULL; - this->FillHWRect = NULL; - this->SetHWColorKey = NULL; - this->SetHWAlpha = NULL; - this->LockHWSurface = FB_LockHWSurface; - this->UnlockHWSurface = FB_UnlockHWSurface; - this->FlipHWSurface = FB_FlipHWSurface; - this->FreeHWSurface = FB_FreeHWSurface; - this->SetCaption = NULL; - this->SetIcon = NULL; - this->IconifyWindow = NULL; - this->GrabInput = NULL; - this->GetWMInfo = NULL; - this->InitOSKeymap = FB_InitOSKeymap; - this->PumpEvents = FB_PumpEvents; - - this->free = FB_DeleteDevice; - - return this; -} - -VideoBootStrap FBCON_bootstrap = { - "fbcon", "Linux Framebuffer Console", - FB_Available, FB_CreateDevice -}; - -#define FB_MODES_DB "/etc/fb.modes" - -static int -read_fbmodes_line(FILE * f, char *line, int length) -{ - int blank; - char *c; - int i; - - blank = 0; - /* find a relevant line */ - do { - if (!fgets(line, length, f)) - return 0; - c = line; - while (((*c == '\t') || (*c == ' ')) && (*c != 0)) - c++; - - if ((*c == '\n') || (*c == '#') || (*c == 0)) - blank = 1; - else - blank = 0; - } while (blank); - /* remove whitespace at the begining of the string */ - i = 0; - do { - line[i] = c[i]; - i++; - } while (c[i] != 0); - return 1; -} - -static int -read_fbmodes_mode(FILE * f, struct fb_var_screeninfo *vinfo) -{ - char line[1024]; - char option[256]; - - /* Find a "geometry" */ - do { - if (read_fbmodes_line(f, line, sizeof(line)) == 0) - return 0; - if (SDL_strncmp(line, "geometry", 8) == 0) - break; - } while (1); - - SDL_sscanf(line, "geometry %d %d %d %d %d", &vinfo->xres, &vinfo->yres, - &vinfo->xres_virtual, &vinfo->yres_virtual, - &vinfo->bits_per_pixel); - if (read_fbmodes_line(f, line, sizeof(line)) == 0) - return 0; - - SDL_sscanf(line, "timings %d %d %d %d %d %d %d", &vinfo->pixclock, - &vinfo->left_margin, &vinfo->right_margin, - &vinfo->upper_margin, &vinfo->lower_margin, &vinfo->hsync_len, - &vinfo->vsync_len); - - vinfo->sync = 0; - vinfo->vmode = FB_VMODE_NONINTERLACED; - - /* Parse misc options */ - do { - if (read_fbmodes_line(f, line, sizeof(line)) == 0) - return 0; - - if (SDL_strncmp(line, "hsync", 5) == 0) { - SDL_sscanf(line, "hsync %s", option); - if (SDL_strncmp(option, "high", 4) == 0) - vinfo->sync |= FB_SYNC_HOR_HIGH_ACT; - } else if (SDL_strncmp(line, "vsync", 5) == 0) { - SDL_sscanf(line, "vsync %s", option); - if (SDL_strncmp(option, "high", 4) == 0) - vinfo->sync |= FB_SYNC_VERT_HIGH_ACT; - } else if (SDL_strncmp(line, "csync", 5) == 0) { - SDL_sscanf(line, "csync %s", option); - if (SDL_strncmp(option, "high", 4) == 0) - vinfo->sync |= FB_SYNC_COMP_HIGH_ACT; - } else if (SDL_strncmp(line, "extsync", 5) == 0) { - SDL_sscanf(line, "extsync %s", option); - if (SDL_strncmp(option, "true", 4) == 0) - vinfo->sync |= FB_SYNC_EXT; - } else if (SDL_strncmp(line, "laced", 5) == 0) { - SDL_sscanf(line, "laced %s", option); - if (SDL_strncmp(option, "true", 4) == 0) - vinfo->vmode |= FB_VMODE_INTERLACED; - } else if (SDL_strncmp(line, "double", 6) == 0) { - SDL_sscanf(line, "double %s", option); - if (SDL_strncmp(option, "true", 4) == 0) - vinfo->vmode |= FB_VMODE_DOUBLE; - } - } while (SDL_strncmp(line, "endmode", 7) != 0); - - return 1; -} - -static int -FB_CheckMode(_THIS, struct fb_var_screeninfo *vinfo, - int index, unsigned int *w, unsigned int *h) -{ - int mode_okay; - - mode_okay = 0; - vinfo->bits_per_pixel = (index + 1) * 8; - vinfo->xres = *w; - vinfo->xres_virtual = *w; - vinfo->yres = *h; - vinfo->yres_virtual = *h; - vinfo->activate = FB_ACTIVATE_TEST; - if (ioctl(console_fd, FBIOPUT_VSCREENINFO, vinfo) == 0) { -#ifdef FBCON_DEBUG - fprintf(stderr, - "Checked mode %dx%d at %d bpp, got mode %dx%d at %d bpp\n", - *w, *h, (index + 1) * 8, vinfo->xres, vinfo->yres, - vinfo->bits_per_pixel); -#endif - if ((((vinfo->bits_per_pixel + 7) / 8) - 1) == index) { - *w = vinfo->xres; - *h = vinfo->yres; - mode_okay = 1; - } - } - return mode_okay; -} - -static int -FB_AddMode(_THIS, int index, unsigned int w, unsigned int h, - int check_timings) -{ - SDL_Rect *mode; - int i; - int next_mode; - - /* Check to see if we already have this mode */ - if (SDL_nummodes[index] > 0) { - mode = SDL_modelist[index][SDL_nummodes[index] - 1]; - if ((mode->w == w) && (mode->h == h)) { -#ifdef FBCON_DEBUG - fprintf(stderr, - "We already have mode %dx%d at %d bytes per pixel\n", - w, h, index + 1); -#endif - return (0); - } - } - - /* Only allow a mode if we have a valid timing for it */ - if (check_timings) { - int found_timing = 0; - for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) { - if ((w == vesa_timings[i].xres) && - (h == vesa_timings[i].yres) && vesa_timings[i].pixclock) { - found_timing = 1; - break; - } - } - if (!found_timing) { -#ifdef FBCON_DEBUG - fprintf(stderr, "No valid timing line for mode %dx%d\n", w, h); -#endif - return (0); - } - } - - /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc(sizeof *mode); - if (mode == NULL) { - SDL_OutOfMemory(); - return (-1); - } - mode->x = 0; - mode->y = 0; - mode->w = w; - mode->h = h; -#ifdef FBCON_DEBUG - fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, - index + 1); -#endif - - /* Allocate the new list of modes, and fill in the new mode */ - next_mode = SDL_nummodes[index]; - SDL_modelist[index] = (SDL_Rect **) - SDL_realloc(SDL_modelist[index], - (1 + next_mode + 1) * sizeof(SDL_Rect *)); - if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory(); - SDL_nummodes[index] = 0; - SDL_free(mode); - return (-1); - } - SDL_modelist[index][next_mode] = mode; - SDL_modelist[index][next_mode + 1] = NULL; - SDL_nummodes[index]++; - - return (0); -} - -static int -cmpmodes(const void *va, const void *vb) -{ - const SDL_Rect *a = *(const SDL_Rect **) va; - const SDL_Rect *b = *(const SDL_Rect **) vb; - if (a->h == b->h) - return b->w - a->w; - else - return b->h - a->h; -} - -static void -FB_SortModes(_THIS) -{ - int i; - for (i = 0; i < NUM_MODELISTS; ++i) { - if (SDL_nummodes[i] > 0) { - SDL_qsort(SDL_modelist[i], SDL_nummodes[i], - sizeof *SDL_modelist[i], cmpmodes); - } - } -} - -static int -FB_VideoInit(_THIS, SDL_PixelFormat * vformat) -{ - const int pagesize = SDL_getpagesize(); - struct fb_fix_screeninfo finfo; - struct fb_var_screeninfo vinfo; - int i, j; - int current_index; - unsigned int current_w; - unsigned int current_h; - const char *SDL_fbdev; - FILE *modesdb; - - /* Initialize the library */ - SDL_fbdev = SDL_getenv("SDL_FBDEV"); - if (SDL_fbdev == NULL) { - SDL_fbdev = "/dev/fb0"; - } - console_fd = open(SDL_fbdev, O_RDWR, 0); - if (console_fd < 0) { - SDL_SetError("Unable to open %s", SDL_fbdev); - return (-1); - } -#if !SDL_THREADS_DISABLED - /* Create the hardware surface lock mutex */ - hw_lock = SDL_CreateMutex(); - if (hw_lock == NULL) { - SDL_SetError("Unable to create lock mutex"); - FB_VideoQuit(this); - return (-1); - } -#endif - - /* Get the type of video hardware */ - if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { - SDL_SetError("Couldn't get console hardware info"); - FB_VideoQuit(this); - return (-1); - } - switch (finfo.type) { - case FB_TYPE_PACKED_PIXELS: - /* Supported, no worries.. */ - break; -#ifdef VGA16_FBCON_SUPPORT - case FB_TYPE_VGA_PLANES: - /* VGA16 is supported, but that's it */ - if (finfo.type_aux == FB_AUX_VGA_PLANES_VGA4) { - if (ioperm(0x3b4, 0x3df - 0x3b4 + 1, 1) < 0) { - SDL_SetError("No I/O port permissions"); - FB_VideoQuit(this); - return (-1); - } - this->SetVideoMode = FB_SetVGA16Mode; - break; - } - /* Fall through to unsupported case */ -#endif /* VGA16_FBCON_SUPPORT */ - default: - SDL_SetError("Unsupported console hardware"); - FB_VideoQuit(this); - return (-1); - } - switch (finfo.visual) { - case FB_VISUAL_TRUECOLOR: - case FB_VISUAL_PSEUDOCOLOR: - case FB_VISUAL_STATIC_PSEUDOCOLOR: - case FB_VISUAL_DIRECTCOLOR: - break; - default: - SDL_SetError("Unsupported console hardware"); - FB_VideoQuit(this); - return (-1); - } - - /* Check if the user wants to disable hardware acceleration */ - { - const char *fb_accel; - fb_accel = SDL_getenv("SDL_FBACCEL"); - if (fb_accel) { - finfo.accel = SDL_atoi(fb_accel); - } - } - - /* Memory map the device, compensating for buggy PPC mmap() */ - mapped_offset = (((long) finfo.smem_start) - - (((long) finfo.smem_start) & ~(pagesize - 1))); - mapped_memlen = finfo.smem_len + mapped_offset; - mapped_mem = do_mmap(NULL, mapped_memlen, - PROT_READ | PROT_WRITE, MAP_SHARED, console_fd, 0); - if (mapped_mem == (char *) -1) { - SDL_SetError("Unable to memory map the video hardware"); - mapped_mem = NULL; - FB_VideoQuit(this); - return (-1); - } - - /* Determine the current screen depth */ - if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { - SDL_SetError("Couldn't get console pixel format"); - FB_VideoQuit(this); - return (-1); - } - vformat->BitsPerPixel = vinfo.bits_per_pixel; - if (vformat->BitsPerPixel < 8) { - /* Assuming VGA16, we handle this via a shadow framebuffer */ - vformat->BitsPerPixel = 8; - } - for (i = 0; i < vinfo.red.length; ++i) { - vformat->Rmask <<= 1; - vformat->Rmask |= (0x00000001 << vinfo.red.offset); - } - for (i = 0; i < vinfo.green.length; ++i) { - vformat->Gmask <<= 1; - vformat->Gmask |= (0x00000001 << vinfo.green.offset); - } - for (i = 0; i < vinfo.blue.length; ++i) { - vformat->Bmask <<= 1; - vformat->Bmask |= (0x00000001 << vinfo.blue.offset); - } - saved_vinfo = vinfo; - - /* Save hardware palette, if needed */ - FB_SavePalette(this, &finfo, &vinfo); - - /* If the I/O registers are available, memory map them so we - can take advantage of any supported hardware acceleration. - */ - vinfo.accel_flags = 0; /* Temporarily reserve registers */ - ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo); - if (finfo.accel && finfo.mmio_len) { - mapped_iolen = finfo.mmio_len; - mapped_io = do_mmap(NULL, mapped_iolen, PROT_READ | PROT_WRITE, - MAP_SHARED, console_fd, mapped_memlen); - if (mapped_io == (char *) -1) { - /* Hmm, failed to memory map I/O registers */ - mapped_io = NULL; - } - } - - /* Query for the list of available video modes */ - current_w = vinfo.xres; - current_h = vinfo.yres; - current_index = ((vinfo.bits_per_pixel + 7) / 8) - 1; - modesdb = fopen(FB_MODES_DB, "r"); - for (i = 0; i < NUM_MODELISTS; ++i) { - SDL_nummodes[i] = 0; - SDL_modelist[i] = NULL; - } - if (SDL_getenv("SDL_FB_BROKEN_MODES") != NULL) { - FB_AddMode(this, current_index, current_w, current_h, 0); - } else if (modesdb) { - while (read_fbmodes_mode(modesdb, &vinfo)) { - for (i = 0; i < NUM_MODELISTS; ++i) { - unsigned int w, h; - - /* See if we are querying for the current mode */ - w = vinfo.xres; - h = vinfo.yres; - if (i == current_index) { - if ((current_w > w) || (current_h > h)) { - /* Only check once */ - FB_AddMode(this, i, current_w, current_h, 0); - current_index = -1; - } - } - if (FB_CheckMode(this, &vinfo, i, &w, &h)) { - FB_AddMode(this, i, w, h, 0); - } - } - } - fclose(modesdb); - FB_SortModes(this); - } else { - for (i = 0; i < NUM_MODELISTS; ++i) { - for (j = 0; j < (sizeof(checkres) / sizeof(checkres[0])); ++j) { - unsigned int w, h; - - /* See if we are querying for the current mode */ - w = checkres[j].w; - h = checkres[j].h; - if (i == current_index) { - if ((current_w > w) || (current_h > h)) { - /* Only check once */ - FB_AddMode(this, i, current_w, current_h, 0); - current_index = -1; - } - } - if (FB_CheckMode(this, &vinfo, i, &w, &h)) { - FB_AddMode(this, i, w, h, 1); - } - } - } - } - - /* Fill in our hardware acceleration capabilities */ - this->info.current_w = current_w; - this->info.current_h = current_h; - this->info.wm_available = 0; - this->info.hw_available = 1; - this->info.video_mem = finfo.smem_len / 1024; - if (mapped_io) { - switch (finfo.accel) { - case FB_ACCEL_MATROX_MGA2064W: - case FB_ACCEL_MATROX_MGA1064SG: - case FB_ACCEL_MATROX_MGA2164W: - case FB_ACCEL_MATROX_MGA2164W_AGP: - case FB_ACCEL_MATROX_MGAG100: - /*case FB_ACCEL_MATROX_MGAG200: G200 acceleration broken! */ - case FB_ACCEL_MATROX_MGAG400: -#ifdef FBACCEL_DEBUG - printf("Matrox hardware accelerator!\n"); -#endif - FB_MatroxAccel(this, finfo.accel); - break; - case FB_ACCEL_3DFX_BANSHEE: -#ifdef FBACCEL_DEBUG - printf("3DFX hardware accelerator!\n"); -#endif - FB_3DfxAccel(this, finfo.accel); - break; - case FB_ACCEL_NV3: - case FB_ACCEL_NV4: -#ifdef FBACCEL_DEBUG - printf("NVidia hardware accelerator!\n"); -#endif - FB_RivaAccel(this, finfo.accel); - break; - default: -#ifdef FBACCEL_DEBUG - printf("Unknown hardware accelerator.\n"); -#endif - break; - } - } - - /* Enable mouse and keyboard support */ - if (FB_OpenKeyboard(this) < 0) { - FB_VideoQuit(this); - return (-1); - } - if (FB_OpenMouse(this) < 0) { - const char *sdl_nomouse; - - sdl_nomouse = SDL_getenv("SDL_NOMOUSE"); - if (!sdl_nomouse) { - SDL_SetError("Unable to open mouse"); - FB_VideoQuit(this); - return (-1); - } - } - - /* We're done! */ - return (0); -} - -static SDL_Rect ** -FB_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) -{ - return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); -} - -/* Various screen update functions available */ -static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); -#ifdef VGA16_FBCON_SUPPORT -static void FB_VGA16Update(_THIS, int numrects, SDL_Rect * rects); -#endif - -#ifdef FBCON_DEBUG -static void -print_vinfo(struct fb_var_screeninfo *vinfo) -{ - fprintf(stderr, "Printing vinfo:\n"); - fprintf(stderr, "\txres: %d\n", vinfo->xres); - fprintf(stderr, "\tyres: %d\n", vinfo->yres); - fprintf(stderr, "\txres_virtual: %d\n", vinfo->xres_virtual); - fprintf(stderr, "\tyres_virtual: %d\n", vinfo->yres_virtual); - fprintf(stderr, "\txoffset: %d\n", vinfo->xoffset); - fprintf(stderr, "\tyoffset: %d\n", vinfo->yoffset); - fprintf(stderr, "\tbits_per_pixel: %d\n", vinfo->bits_per_pixel); - fprintf(stderr, "\tgrayscale: %d\n", vinfo->grayscale); - fprintf(stderr, "\tnonstd: %d\n", vinfo->nonstd); - fprintf(stderr, "\tactivate: %d\n", vinfo->activate); - fprintf(stderr, "\theight: %d\n", vinfo->height); - fprintf(stderr, "\twidth: %d\n", vinfo->width); - fprintf(stderr, "\taccel_flags: %d\n", vinfo->accel_flags); - fprintf(stderr, "\tpixclock: %d\n", vinfo->pixclock); - fprintf(stderr, "\tleft_margin: %d\n", vinfo->left_margin); - fprintf(stderr, "\tright_margin: %d\n", vinfo->right_margin); - fprintf(stderr, "\tupper_margin: %d\n", vinfo->upper_margin); - fprintf(stderr, "\tlower_margin: %d\n", vinfo->lower_margin); - fprintf(stderr, "\thsync_len: %d\n", vinfo->hsync_len); - fprintf(stderr, "\tvsync_len: %d\n", vinfo->vsync_len); - fprintf(stderr, "\tsync: %d\n", vinfo->sync); - fprintf(stderr, "\tvmode: %d\n", vinfo->vmode); - fprintf(stderr, "\tred: %d/%d\n", vinfo->red.length, vinfo->red.offset); - fprintf(stderr, "\tgreen: %d/%d\n", vinfo->green.length, - vinfo->green.offset); - fprintf(stderr, "\tblue: %d/%d\n", vinfo->blue.length, - vinfo->blue.offset); - fprintf(stderr, "\talpha: %d/%d\n", vinfo->transp.length, - vinfo->transp.offset); -} - -static void -print_finfo(struct fb_fix_screeninfo *finfo) -{ - fprintf(stderr, "Printing finfo:\n"); - fprintf(stderr, "\tsmem_start = %p\n", (char *) finfo->smem_start); - fprintf(stderr, "\tsmem_len = %d\n", finfo->smem_len); - fprintf(stderr, "\ttype = %d\n", finfo->type); - fprintf(stderr, "\ttype_aux = %d\n", finfo->type_aux); - fprintf(stderr, "\tvisual = %d\n", finfo->visual); - fprintf(stderr, "\txpanstep = %d\n", finfo->xpanstep); - fprintf(stderr, "\typanstep = %d\n", finfo->ypanstep); - fprintf(stderr, "\tywrapstep = %d\n", finfo->ywrapstep); - fprintf(stderr, "\tline_length = %d\n", finfo->line_length); - fprintf(stderr, "\tmmio_start = %p\n", (char *) finfo->mmio_start); - fprintf(stderr, "\tmmio_len = %d\n", finfo->mmio_len); - fprintf(stderr, "\taccel = %d\n", finfo->accel); -} -#endif - -static int -choose_fbmodes_mode(struct fb_var_screeninfo *vinfo) -{ - int matched; - FILE *modesdb; - struct fb_var_screeninfo cinfo; - - matched = 0; - modesdb = fopen(FB_MODES_DB, "r"); - if (modesdb) { - /* Parse the mode definition file */ - while (read_fbmodes_mode(modesdb, &cinfo)) { - if ((vinfo->xres == cinfo.xres && vinfo->yres == cinfo.yres) - && (!matched - || (vinfo->bits_per_pixel == cinfo.bits_per_pixel))) { - vinfo->pixclock = cinfo.pixclock; - vinfo->left_margin = cinfo.left_margin; - vinfo->right_margin = cinfo.right_margin; - vinfo->upper_margin = cinfo.upper_margin; - vinfo->lower_margin = cinfo.lower_margin; - vinfo->hsync_len = cinfo.hsync_len; - vinfo->vsync_len = cinfo.vsync_len; - if (matched) { - break; - } - matched = 1; - } - } - fclose(modesdb); - } - return (matched); -} - -static int -choose_vesa_mode(struct fb_var_screeninfo *vinfo) -{ - int matched; - int i; - - /* Check for VESA timings */ - matched = 0; - for (i = 0; i < (sizeof(vesa_timings) / sizeof(vesa_timings[0])); ++i) { - if ((vinfo->xres == vesa_timings[i].xres) && - (vinfo->yres == vesa_timings[i].yres)) { -#ifdef FBCON_DEBUG - fprintf(stderr, "Using VESA timings for %dx%d\n", - vinfo->xres, vinfo->yres); -#endif - if (vesa_timings[i].pixclock) { - vinfo->pixclock = vesa_timings[i].pixclock; - } - vinfo->left_margin = vesa_timings[i].left; - vinfo->right_margin = vesa_timings[i].right; - vinfo->upper_margin = vesa_timings[i].upper; - vinfo->lower_margin = vesa_timings[i].lower; - vinfo->hsync_len = vesa_timings[i].hslen; - vinfo->vsync_len = vesa_timings[i].vslen; - vinfo->sync = vesa_timings[i].sync; - vinfo->vmode = vesa_timings[i].vmode; - matched = 1; - break; - } - } - return (matched); -} - -#ifdef VGA16_FBCON_SUPPORT -static SDL_Surface * -FB_SetVGA16Mode(_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) -{ - struct fb_fix_screeninfo finfo; - struct fb_var_screeninfo vinfo; - - /* Set the terminal into graphics mode */ - if (FB_EnterGraphicsMode(this) < 0) { - return (NULL); - } - - /* Restore the original palette */ - FB_RestorePalette(this); - - /* Set the video mode and get the final screen format */ - if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { - SDL_SetError("Couldn't get console screen info"); - return (NULL); - } - cache_vinfo = vinfo; -#ifdef FBCON_DEBUG - fprintf(stderr, "Printing actual vinfo:\n"); - print_vinfo(&vinfo); -#endif - if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) { - return (NULL); - } - current->format->palette->ncolors = 16; - - /* Get the fixed information about the console hardware. - This is necessary since finfo.line_length changes. - */ - if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { - SDL_SetError("Couldn't get console hardware info"); - return (NULL); - } -#ifdef FBCON_DEBUG - fprintf(stderr, "Printing actual finfo:\n"); - print_finfo(&finfo); -#endif - - /* Save hardware palette, if needed */ - FB_SavePalette(this, &finfo, &vinfo); - - /* Set up the new mode framebuffer */ - current->flags = SDL_FULLSCREEN; - current->w = vinfo.xres; - current->h = vinfo.yres; - current->pitch = current->w; - current->pixels = SDL_malloc(current->h * current->pitch); - - /* Set the update rectangle function */ - this->UpdateRects = FB_VGA16Update; - - /* We're done */ - return (current); -} -#endif /* VGA16_FBCON_SUPPORT */ - -static SDL_Surface * -FB_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) -{ - struct fb_fix_screeninfo finfo; - struct fb_var_screeninfo vinfo; - int i; - Uint32 Rmask; - Uint32 Gmask; - Uint32 Bmask; - char *surfaces_mem; - int surfaces_len; - - /* Set the terminal into graphics mode */ - if (FB_EnterGraphicsMode(this) < 0) { - return (NULL); - } - - /* Restore the original palette */ - FB_RestorePalette(this); - - /* Set the video mode and get the final screen format */ - if (ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0) { - SDL_SetError("Couldn't get console screen info"); - return (NULL); - } -#ifdef FBCON_DEBUG - fprintf(stderr, "Printing original vinfo:\n"); - print_vinfo(&vinfo); -#endif - if ((vinfo.xres != width) || (vinfo.yres != height) || - (vinfo.bits_per_pixel != bpp) || (flags & SDL_DOUBLEBUF)) { - vinfo.activate = FB_ACTIVATE_NOW; - vinfo.accel_flags = 0; - vinfo.bits_per_pixel = bpp; - vinfo.xres = width; - vinfo.xres_virtual = width; - vinfo.yres = height; - if (flags & SDL_DOUBLEBUF) { - vinfo.yres_virtual = height * 2; - } else { - vinfo.yres_virtual = height; - } - vinfo.xoffset = 0; - vinfo.yoffset = 0; - vinfo.red.length = vinfo.red.offset = 0; - vinfo.green.length = vinfo.green.offset = 0; - vinfo.blue.length = vinfo.blue.offset = 0; - vinfo.transp.length = vinfo.transp.offset = 0; - if (!choose_fbmodes_mode(&vinfo)) { - choose_vesa_mode(&vinfo); - } -#ifdef FBCON_DEBUG - fprintf(stderr, "Printing wanted vinfo:\n"); - print_vinfo(&vinfo); -#endif - if (ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) { - vinfo.yres_virtual = height; - if (ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0) { - SDL_SetError("Couldn't set console screen info"); - return (NULL); - } - } - } else { - int maxheight; - - /* Figure out how much video memory is available */ - if (flags & SDL_DOUBLEBUF) { - maxheight = height * 2; - } else { - maxheight = height; - } - if (vinfo.yres_virtual > maxheight) { - vinfo.yres_virtual = maxheight; - } - } - cache_vinfo = vinfo; -#ifdef FBCON_DEBUG - fprintf(stderr, "Printing actual vinfo:\n"); - print_vinfo(&vinfo); -#endif - Rmask = 0; - for (i = 0; i < vinfo.red.length; ++i) { - Rmask <<= 1; - Rmask |= (0x00000001 << vinfo.red.offset); - } - Gmask = 0; - for (i = 0; i < vinfo.green.length; ++i) { - Gmask <<= 1; - Gmask |= (0x00000001 << vinfo.green.offset); - } - Bmask = 0; - for (i = 0; i < vinfo.blue.length; ++i) { - Bmask <<= 1; - Bmask |= (0x00000001 << vinfo.blue.offset); - } - if (!SDL_ReallocFormat(current, vinfo.bits_per_pixel, - Rmask, Gmask, Bmask, 0)) { - return (NULL); - } - - /* Get the fixed information about the console hardware. - This is necessary since finfo.line_length changes. - */ - if (ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0) { - SDL_SetError("Couldn't get console hardware info"); - return (NULL); - } - - /* Save hardware palette, if needed */ - FB_SavePalette(this, &finfo, &vinfo); - - /* Set up the new mode framebuffer */ - current->flags = (SDL_FULLSCREEN | SDL_HWSURFACE); - current->w = vinfo.xres; - current->h = vinfo.yres; - current->pitch = finfo.line_length; - current->pixels = mapped_mem + mapped_offset; - - /* Set up the information for hardware surfaces */ - surfaces_mem = (char *) current->pixels + - vinfo.yres_virtual * current->pitch; - surfaces_len = (mapped_memlen - (surfaces_mem - mapped_mem)); - FB_FreeHWSurfaces(this); - FB_InitHWSurfaces(this, current, surfaces_mem, surfaces_len); - - /* Let the application know we have a hardware palette */ - switch (finfo.visual) { - case FB_VISUAL_PSEUDOCOLOR: - current->flags |= SDL_HWPALETTE; - break; - default: - break; - } - - /* Update for double-buffering, if we can */ - if (flags & SDL_DOUBLEBUF) { - if (vinfo.yres_virtual == (height * 2)) { - current->flags |= SDL_DOUBLEBUF; - flip_page = 0; - flip_address[0] = (char *) current->pixels; - flip_address[1] = (char *) current->pixels + - current->h * current->pitch; - this->screen = current; - FB_FlipHWSurface(this, current); - this->screen = NULL; - } - } - - /* Set the update rectangle function */ - this->UpdateRects = FB_DirectUpdate; - - /* We're done */ - return (current); -} - -#ifdef FBCON_DEBUG -void -FB_DumpHWSurfaces(_THIS) -{ - vidmem_bucket *bucket; - - printf("Memory left: %d (%d total)\n", surfaces_memleft, - surfaces_memtotal); - printf("\n"); - printf(" Base Size\n"); - for (bucket = &surfaces; bucket; bucket = bucket->next) { - printf("Bucket: %p, %d (%s)\n", bucket->base, bucket->size, - bucket->used ? "used" : "free"); - if (bucket->prev) { - if (bucket->base != bucket->prev->base + bucket->prev->size) { - printf("Warning, corrupt bucket list! (prev)\n"); - } - } else { - if (bucket != &surfaces) { - printf("Warning, corrupt bucket list! (!prev)\n"); - } - } - if (bucket->next) { - if (bucket->next->base != bucket->base + bucket->size) { - printf("Warning, corrupt bucket list! (next)\n"); - } - } - } - printf("\n"); -} -#endif - -static int -FB_InitHWSurfaces(_THIS, SDL_Surface * screen, char *base, int size) -{ - vidmem_bucket *bucket; - - surfaces_memtotal = size; - surfaces_memleft = size; - - if (surfaces_memleft > 0) { - bucket = (vidmem_bucket *) SDL_malloc(sizeof(*bucket)); - if (bucket == NULL) { - SDL_OutOfMemory(); - return (-1); - } - bucket->prev = &surfaces; - bucket->used = 0; - bucket->dirty = 0; - bucket->base = base; - bucket->size = size; - bucket->next = NULL; - } else { - bucket = NULL; - } - - surfaces.prev = NULL; - surfaces.used = 1; - surfaces.dirty = 0; - surfaces.base = screen->pixels; - surfaces.size = (unsigned int) ((long) base - (long) surfaces.base); - surfaces.next = bucket; - screen->hwdata = (struct private_hwdata *) &surfaces; - return (0); -} - -static void -FB_FreeHWSurfaces(_THIS) -{ - vidmem_bucket *bucket, *freeable; - - bucket = surfaces.next; - while (bucket) { - freeable = bucket; - bucket = bucket->next; - SDL_free(freeable); - } - surfaces.next = NULL; -} - -static int -FB_AllocHWSurface(_THIS, SDL_Surface * surface) -{ - vidmem_bucket *bucket; - int size; - int extra; - -/* Temporarily, we only allow surfaces the same width as display. - Some blitters require the pitch between two hardware surfaces - to be the same. Others have interesting alignment restrictions. - Until someone who knows these details looks at the code... -*/ - if (surface->pitch > SDL_VideoSurface->pitch) { - SDL_SetError("Surface requested wider than screen"); - return (-1); - } - surface->pitch = SDL_VideoSurface->pitch; - size = surface->h * surface->pitch; -#ifdef FBCON_DEBUG - fprintf(stderr, "Allocating bucket of %d bytes\n", size); -#endif - - /* Quick check for available mem */ - if (size > surfaces_memleft) { - SDL_SetError("Not enough video memory"); - return (-1); - } - - /* Search for an empty bucket big enough */ - for (bucket = &surfaces; bucket; bucket = bucket->next) { - if (!bucket->used && (size <= bucket->size)) { - break; - } - } - if (bucket == NULL) { - SDL_SetError("Video memory too fragmented"); - return (-1); - } - - /* Create a new bucket for left-over memory */ - extra = (bucket->size - size); - if (extra) { - vidmem_bucket *newbucket; - -#ifdef FBCON_DEBUG - fprintf(stderr, "Adding new free bucket of %d bytes\n", extra); -#endif - newbucket = (vidmem_bucket *) SDL_malloc(sizeof(*newbucket)); - if (newbucket == NULL) { - SDL_OutOfMemory(); - return (-1); - } - newbucket->prev = bucket; - newbucket->used = 0; - newbucket->base = bucket->base + size; - newbucket->size = extra; - newbucket->next = bucket->next; - if (bucket->next) { - bucket->next->prev = newbucket; - } - bucket->next = newbucket; - } - - /* Set the current bucket values and return it! */ - bucket->used = 1; - bucket->size = size; - bucket->dirty = 0; -#ifdef FBCON_DEBUG - fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base); -#endif - surfaces_memleft -= size; - surface->flags |= SDL_HWSURFACE; - surface->pixels = bucket->base; - surface->hwdata = (struct private_hwdata *) bucket; - return (0); -} - -static void -FB_FreeHWSurface(_THIS, SDL_Surface * surface) -{ - vidmem_bucket *bucket, *freeable; - - /* Look for the bucket in the current list */ - for (bucket = &surfaces; bucket; bucket = bucket->next) { - if (bucket == (vidmem_bucket *) surface->hwdata) { - break; - } - } - if (bucket && bucket->used) { - /* Add the memory back to the total */ -#ifdef DGA_DEBUG - printf("Freeing bucket of %d bytes\n", bucket->size); -#endif - surfaces_memleft += bucket->size; - - /* Can we merge the space with surrounding buckets? */ - bucket->used = 0; - if (bucket->next && !bucket->next->used) { -#ifdef DGA_DEBUG - printf("Merging with next bucket, for %d total bytes\n", - bucket->size + bucket->next->size); -#endif - freeable = bucket->next; - bucket->size += bucket->next->size; - bucket->next = bucket->next->next; - if (bucket->next) { - bucket->next->prev = bucket; - } - SDL_free(freeable); - } - if (bucket->prev && !bucket->prev->used) { -#ifdef DGA_DEBUG - printf("Merging with previous bucket, for %d total bytes\n", - bucket->prev->size + bucket->size); -#endif - freeable = bucket; - bucket->prev->size += bucket->size; - bucket->prev->next = bucket->next; - if (bucket->next) { - bucket->next->prev = bucket->prev; - } - SDL_free(freeable); - } - } - surface->pixels = NULL; - surface->hwdata = NULL; -} - -static int -FB_LockHWSurface(_THIS, SDL_Surface * surface) -{ - if (switched_away) { - return -2; /* no hardware access */ - } - if (surface == this->screen) { - SDL_mutexP(hw_lock); - if (FB_IsSurfaceBusy(surface)) { - FB_WaitBusySurfaces(this); - } - } else { - if (FB_IsSurfaceBusy(surface)) { - FB_WaitBusySurfaces(this); - } - } - return (0); -} - -static void -FB_UnlockHWSurface(_THIS, SDL_Surface * surface) -{ - if (surface == this->screen) { - SDL_mutexV(hw_lock); - } -} - -static void -FB_WaitVBL(_THIS) -{ -#ifdef FBIOWAITRETRACE /* Heheh, this didn't make it into the main kernel */ - ioctl(console_fd, FBIOWAITRETRACE, 0); -#endif - return; -} - -static void -FB_WaitIdle(_THIS) -{ - return; -} - -static int -FB_FlipHWSurface(_THIS, SDL_Surface * surface) -{ - if (switched_away) { - return -2; /* no hardware access */ - } - - /* Wait for vertical retrace and then flip display */ - cache_vinfo.yoffset = flip_page * surface->h; - if (FB_IsSurfaceBusy(this->screen)) { - FB_WaitBusySurfaces(this); - } - wait_vbl(this); - if (ioctl(console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0) { - SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed"); - return (-1); - } - flip_page = !flip_page; - - surface->pixels = flip_address[flip_page]; - return (0); -} - -static void -FB_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) -{ - /* The application is already updating the visible video memory */ - return; -} - -#ifdef VGA16_FBCON_SUPPORT -/* Code adapted with thanks from the XFree86 VGA16 driver! :) */ -#define writeGr(index, value) \ -outb(index, 0x3CE); \ -outb(value, 0x3CF); -#define writeSeq(index, value) \ -outb(index, 0x3C4); \ -outb(value, 0x3C5); - -static void -FB_VGA16Update(_THIS, int numrects, SDL_Rect * rects) -{ - SDL_Surface *screen; - int width, height, FBPitch, left, i, j, SRCPitch, phase; - register Uint32 m; - Uint8 s1, s2, s3, s4; - Uint32 *src, *srcPtr; - Uint8 *dst, *dstPtr; - - if (switched_away) { - return; /* no hardware access */ - } - - screen = this->screen; - FBPitch = screen->w >> 3; - SRCPitch = screen->pitch >> 2; - - writeGr(0x03, 0x00); - writeGr(0x05, 0x00); - writeGr(0x01, 0x00); - writeGr(0x08, 0xFF); - - while (numrects--) { - left = rects->x & ~7; - width = (rects->w + 7) >> 3; - height = rects->h; - src = (Uint32 *) screen->pixels + (rects->y * SRCPitch) + (left >> 2); - dst = (Uint8 *) mapped_mem + (rects->y * FBPitch) + (left >> 3); - - if ((phase = (long) dst & 3L)) { - phase = 4 - phase; - if (phase > width) - phase = width; - width -= phase; - } - - while (height--) { - writeSeq(0x02, 1 << 0); - dstPtr = dst; - srcPtr = src; - i = width; - j = phase; - while (j--) { - m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) - << 4); - *dstPtr++ = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3); - srcPtr += 2; - } - while (i >= 4) { - m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) - << 4); - s1 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3); - m = (srcPtr[3] & 0x01010101) | ((srcPtr[2] & 0x01010101) - << 4); - s2 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3); - m = (srcPtr[5] & 0x01010101) | ((srcPtr[4] & 0x01010101) - << 4); - s3 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3); - m = (srcPtr[7] & 0x01010101) | ((srcPtr[6] & 0x01010101) - << 4); - s4 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3); - *((Uint32 *) dstPtr) = - s1 | (s2 << 8) | (s3 << 16) | (s4 << 24); - srcPtr += 8; - dstPtr += 4; - i -= 4; - } - while (i--) { - m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) - << 4); - *dstPtr++ = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3); - srcPtr += 2; - } - - writeSeq(0x02, 1 << 1); - dstPtr = dst; - srcPtr = src; - i = width; - j = phase; - while (j--) { - m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) - << 4); - *dstPtr++ = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2); - srcPtr += 2; - } - while (i >= 4) { - m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) - << 4); - s1 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2); - m = (srcPtr[3] & 0x02020202) | ((srcPtr[2] & 0x02020202) - << 4); - s2 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2); - m = (srcPtr[5] & 0x02020202) | ((srcPtr[4] & 0x02020202) - << 4); - s3 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2); - m = (srcPtr[7] & 0x02020202) | ((srcPtr[6] & 0x02020202) - << 4); - s4 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2); - *((Uint32 *) dstPtr) = - s1 | (s2 << 8) | (s3 << 16) | (s4 << 24); - srcPtr += 8; - dstPtr += 4; - i -= 4; - } - while (i--) { - m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) - << 4); - *dstPtr++ = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2); - srcPtr += 2; - } - - writeSeq(0x02, 1 << 2); - dstPtr = dst; - srcPtr = src; - i = width; - j = phase; - while (j--) { - m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) - << 4); - *dstPtr++ = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1); - srcPtr += 2; - } - while (i >= 4) { - m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) - << 4); - s1 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1); - m = (srcPtr[3] & 0x04040404) | ((srcPtr[2] & 0x04040404) - << 4); - s2 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1); - m = (srcPtr[5] & 0x04040404) | ((srcPtr[4] & 0x04040404) - << 4); - s3 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1); - m = (srcPtr[7] & 0x04040404) | ((srcPtr[6] & 0x04040404) - << 4); - s4 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1); - *((Uint32 *) dstPtr) = - s1 | (s2 << 8) | (s3 << 16) | (s4 << 24); - srcPtr += 8; - dstPtr += 4; - i -= 4; - } - while (i--) { - m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) - << 4); - *dstPtr++ = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1); - srcPtr += 2; - } - - writeSeq(0x02, 1 << 3); - dstPtr = dst; - srcPtr = src; - i = width; - j = phase; - while (j--) { - m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) - << 4); - *dstPtr++ = (m >> 27) | (m >> 18) | (m >> 9) | m; - srcPtr += 2; - } - while (i >= 4) { - m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) - << 4); - s1 = (m >> 27) | (m >> 18) | (m >> 9) | m; - m = (srcPtr[3] & 0x08080808) | ((srcPtr[2] & 0x08080808) - << 4); - s2 = (m >> 27) | (m >> 18) | (m >> 9) | m; - m = (srcPtr[5] & 0x08080808) | ((srcPtr[4] & 0x08080808) - << 4); - s3 = (m >> 27) | (m >> 18) | (m >> 9) | m; - m = (srcPtr[7] & 0x08080808) | ((srcPtr[6] & 0x08080808) - << 4); - s4 = (m >> 27) | (m >> 18) | (m >> 9) | m; - *((Uint32 *) dstPtr) = - s1 | (s2 << 8) | (s3 << 16) | (s4 << 24); - srcPtr += 8; - dstPtr += 4; - i -= 4; - } - while (i--) { - m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) - << 4); - *dstPtr++ = (m >> 27) | (m >> 18) | (m >> 9) | m; - srcPtr += 2; - } - - dst += FBPitch; - src += SRCPitch; - } - rects++; - } -} -#endif /* VGA16_FBCON_SUPPORT */ - -void -FB_SavePaletteTo(_THIS, int palette_len, __u16 * area) -{ - struct fb_cmap cmap; - - cmap.start = 0; - cmap.len = palette_len; - cmap.red = &area[0 * palette_len]; - cmap.green = &area[1 * palette_len]; - cmap.blue = &area[2 * palette_len]; - cmap.transp = NULL; - ioctl(console_fd, FBIOGETCMAP, &cmap); -} - -void -FB_RestorePaletteFrom(_THIS, int palette_len, __u16 * area) -{ - struct fb_cmap cmap; - - cmap.start = 0; - cmap.len = palette_len; - cmap.red = &area[0 * palette_len]; - cmap.green = &area[1 * palette_len]; - cmap.blue = &area[2 * palette_len]; - cmap.transp = NULL; - ioctl(console_fd, FBIOPUTCMAP, &cmap); -} - -static void -FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo, - struct fb_var_screeninfo *vinfo) -{ - int i; - - /* Save hardware palette, if needed */ - if (finfo->visual == FB_VISUAL_PSEUDOCOLOR) { - saved_cmaplen = 1 << vinfo->bits_per_pixel; - saved_cmap = - (__u16 *) SDL_malloc(3 * saved_cmaplen * sizeof(*saved_cmap)); - if (saved_cmap != NULL) { - FB_SavePaletteTo(this, saved_cmaplen, saved_cmap); - } - } - - /* Added support for FB_VISUAL_DIRECTCOLOR. - With this mode pixel information is passed through the palette... - Neat fading and gamma correction effects can be had by simply - fooling around with the palette instead of changing the pixel - values themselves... Very neat! - - Adam Meyerowitz 1/19/2000 - ameyerow@optonline.com - */ - if (finfo->visual == FB_VISUAL_DIRECTCOLOR) { - __u16 new_entries[3 * 256]; - - /* Save the colormap */ - saved_cmaplen = 256; - saved_cmap = - (__u16 *) SDL_malloc(3 * saved_cmaplen * sizeof(*saved_cmap)); - if (saved_cmap != NULL) { - FB_SavePaletteTo(this, saved_cmaplen, saved_cmap); - } - - /* Allocate new identity colormap */ - for (i = 0; i < 256; ++i) { - new_entries[(0 * 256) + i] = - new_entries[(1 * 256) + i] = - new_entries[(2 * 256) + i] = (i << 8) | i; - } - FB_RestorePaletteFrom(this, 256, new_entries); - } -} - -static void -FB_RestorePalette(_THIS) -{ - /* Restore the original palette */ - if (saved_cmap) { - FB_RestorePaletteFrom(this, saved_cmaplen, saved_cmap); - SDL_free(saved_cmap); - saved_cmap = NULL; - } -} - -static int -FB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) -{ - int i; - __u16 r[256]; - __u16 g[256]; - __u16 b[256]; - struct fb_cmap cmap; - - /* Set up the colormap */ - for (i = 0; i < ncolors; i++) { - r[i] = colors[i].r << 8; - g[i] = colors[i].g << 8; - b[i] = colors[i].b << 8; - } - cmap.start = firstcolor; - cmap.len = ncolors; - cmap.red = r; - cmap.green = g; - cmap.blue = b; - cmap.transp = NULL; - - if ((ioctl(console_fd, FBIOPUTCMAP, &cmap) < 0) || - !(this->screen->flags & SDL_HWPALETTE)) { - colors = this->screen->format->palette->colors; - ncolors = this->screen->format->palette->ncolors; - cmap.start = 0; - cmap.len = ncolors; - SDL_memset(r, 0, sizeof(r)); - SDL_memset(g, 0, sizeof(g)); - SDL_memset(b, 0, sizeof(b)); - if (ioctl(console_fd, FBIOGETCMAP, &cmap) == 0) { - for (i = ncolors - 1; i >= 0; --i) { - colors[i].r = (r[i] >> 8); - colors[i].g = (g[i] >> 8); - colors[i].b = (b[i] >> 8); - } - } - return (0); - } - return (1); -} - -/* Note: If we are terminated, this could be called in the middle of - another SDL video routine -- notably UpdateRects. -*/ -static void -FB_VideoQuit(_THIS) -{ - int i, j; - - if (this->screen) { - /* Clear screen and tell SDL not to free the pixels */ - if (this->screen->pixels && FB_InGraphicsMode(this)) { -#if defined(__powerpc__) || defined(__ia64__) /* SIGBUS when using SDL_memset() ?? */ - Uint8 *rowp = (Uint8 *) this->screen->pixels; - int left = this->screen->pitch * this->screen->h; - while (left--) { - *rowp++ = 0; - } -#else - SDL_memset(this->screen->pixels, 0, - this->screen->h * this->screen->pitch); -#endif - } - /* This test fails when using the VGA16 shadow memory */ - if (((char *) this->screen->pixels >= mapped_mem) && - ((char *) this->screen->pixels < (mapped_mem + mapped_memlen))) { - this->screen->pixels = NULL; - } - } - - /* Clear the lock mutex */ - if (hw_lock) { - SDL_DestroyMutex(hw_lock); - hw_lock = NULL; - } - - /* Clean up defined video modes */ - for (i = 0; i < NUM_MODELISTS; ++i) { - if (SDL_modelist[i] != NULL) { - for (j = 0; SDL_modelist[i][j]; ++j) { - SDL_free(SDL_modelist[i][j]); - } - SDL_free(SDL_modelist[i]); - SDL_modelist[i] = NULL; - } - } - - /* Clean up the memory bucket list */ - FB_FreeHWSurfaces(this); - - /* Close console and input file descriptors */ - if (console_fd > 0) { - /* Unmap the video framebuffer and I/O registers */ - if (mapped_mem) { - munmap(mapped_mem, mapped_memlen); - mapped_mem = NULL; - } - if (mapped_io) { - munmap(mapped_io, mapped_iolen); - mapped_io = NULL; - } - - /* Restore the original video mode and palette */ - if (FB_InGraphicsMode(this)) { - FB_RestorePalette(this); - ioctl(console_fd, FBIOPUT_VSCREENINFO, &saved_vinfo); - } - - /* We're all done with the framebuffer */ - close(console_fd); - console_fd = -1; - } - FB_CloseMouse(this); - FB_CloseKeyboard(this); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbvideo.h b/project/jni/sdl-1.3/src/video/fbcon/SDL_fbvideo.h deleted file mode 100644 index 3f27f88f6..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/SDL_fbvideo.h +++ /dev/null @@ -1,189 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_fbvideo_h -#define _SDL_fbvideo_h - -#include -#include -#include - -#include "SDL_mouse.h" -#include "SDL_mutex.h" -#include "../SDL_sysvideo.h" -#if SDL_INPUT_TSLIB -#include "tslib.h" -#endif - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *this - - -/* This is the structure we use to keep track of video memory */ -typedef struct vidmem_bucket -{ - struct vidmem_bucket *prev; - int used; - int dirty; - char *base; - unsigned int size; - struct vidmem_bucket *next; -} vidmem_bucket; - -/* Private display data */ -struct SDL_PrivateVideoData -{ - int console_fd; - struct fb_var_screeninfo cache_vinfo; - struct fb_var_screeninfo saved_vinfo; - int saved_cmaplen; - __u16 *saved_cmap; - - int current_vt; - int saved_vt; - int keyboard_fd; - int saved_kbd_mode; - struct termios saved_kbd_termios; - - int mouse_fd; -#if SDL_INPUT_TSLIB - struct tsdev *ts_dev; -#endif - - char *mapped_mem; - int mapped_memlen; - int mapped_offset; - char *mapped_io; - long mapped_iolen; - int flip_page; - char *flip_address[2]; - -#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ - int SDL_nummodes[NUM_MODELISTS]; - SDL_Rect **SDL_modelist[NUM_MODELISTS]; - - vidmem_bucket surfaces; - int surfaces_memtotal; - int surfaces_memleft; - - SDL_mutex *hw_lock; - int switched_away; - struct fb_var_screeninfo screen_vinfo; - Uint32 screen_arealen; - Uint8 *screen_contents; - __u16 screen_palette[3 * 256]; - - void (*wait_vbl) (_THIS); - void (*wait_idle) (_THIS); -}; -/* Old variable names */ -#define console_fd (this->hidden->console_fd) -#define current_vt (this->hidden->current_vt) -#define saved_vt (this->hidden->saved_vt) -#define keyboard_fd (this->hidden->keyboard_fd) -#define saved_kbd_mode (this->hidden->saved_kbd_mode) -#define saved_kbd_termios (this->hidden->saved_kbd_termios) -#define mouse_fd (this->hidden->mouse_fd) -#if SDL_INPUT_TSLIB -#define ts_dev (this->hidden->ts_dev) -#endif -#define cache_vinfo (this->hidden->cache_vinfo) -#define saved_vinfo (this->hidden->saved_vinfo) -#define saved_cmaplen (this->hidden->saved_cmaplen) -#define saved_cmap (this->hidden->saved_cmap) -#define mapped_mem (this->hidden->mapped_mem) -#define mapped_memlen (this->hidden->mapped_memlen) -#define mapped_offset (this->hidden->mapped_offset) -#define mapped_io (this->hidden->mapped_io) -#define mapped_iolen (this->hidden->mapped_iolen) -#define flip_page (this->hidden->flip_page) -#define flip_address (this->hidden->flip_address) -#define SDL_nummodes (this->hidden->SDL_nummodes) -#define SDL_modelist (this->hidden->SDL_modelist) -#define surfaces (this->hidden->surfaces) -#define surfaces_memtotal (this->hidden->surfaces_memtotal) -#define surfaces_memleft (this->hidden->surfaces_memleft) -#define hw_lock (this->hidden->hw_lock) -#define switched_away (this->hidden->switched_away) -#define screen_vinfo (this->hidden->screen_vinfo) -#define screen_arealen (this->hidden->screen_arealen) -#define screen_contents (this->hidden->screen_contents) -#define screen_palette (this->hidden->screen_palette) -#define wait_vbl (this->hidden->wait_vbl) -#define wait_idle (this->hidden->wait_idle) - -/* Accelerator types that are supported by the driver, but are not - necessarily in the kernel headers on the system we compile on. -*/ -#ifndef FB_ACCEL_MATROX_MGAG400 -#define FB_ACCEL_MATROX_MGAG400 26 /* Matrox G400 */ -#endif -#ifndef FB_ACCEL_3DFX_BANSHEE -#define FB_ACCEL_3DFX_BANSHEE 31 /* 3Dfx Banshee */ -#endif - -/* These functions are defined in SDL_fbvideo.c */ -extern void FB_SavePaletteTo(_THIS, int palette_len, __u16 * area); -extern void FB_RestorePaletteFrom(_THIS, int palette_len, __u16 * area); - -/* These are utility functions for working with video surfaces */ - -static __inline__ void -FB_AddBusySurface(SDL_Surface * surface) -{ - ((vidmem_bucket *) surface->hwdata)->dirty = 1; -} - -static __inline__ int -FB_IsSurfaceBusy(SDL_Surface * surface) -{ - return ((vidmem_bucket *) surface->hwdata)->dirty; -} - -static __inline__ void -FB_WaitBusySurfaces(_THIS) -{ - vidmem_bucket *bucket; - - /* Wait for graphic operations to complete */ - wait_idle(this); - - /* Clear all surface dirty bits */ - for (bucket = &surfaces; bucket; bucket = bucket->next) { - bucket->dirty = 0; - } -} - -static __inline__ void -FB_dst_to_xy(_THIS, SDL_Surface * dst, int *x, int *y) -{ - *x = (long) ((char *) dst->pixels - mapped_mem) % this->screen->pitch; - *y = (long) ((char *) dst->pixels - mapped_mem) / this->screen->pitch; - if (dst == this->screen) { - *x += this->offset_x; - *y += this->offset_y; - } -} - -#endif /* _SDL_fbvideo_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/matrox_mmio.h b/project/jni/sdl-1.3/src/video/fbcon/matrox_mmio.h deleted file mode 100644 index 7079bd4ca..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/matrox_mmio.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* MGA register definitions */ - -#include "matrox_regs.h" - -/* MGA control macros */ - -#define mga_in8(reg) *(volatile Uint8 *)(mapped_io + (reg)) -#define mga_in32(reg) *(volatile Uint32 *)(mapped_io + (reg)) - -#define mga_out8(reg,v) *(volatile Uint8 *)(mapped_io + (reg)) = v; -#define mga_out32(reg,v) *(volatile Uint32 *)(mapped_io + (reg)) = v; - - -/* Wait for fifo space */ -#define mga_wait(space) \ -{ \ - while ( mga_in8(MGAREG_FIFOSTATUS) < space ) \ - ; \ -} - - -/* Wait for idle accelerator */ -#define mga_waitidle() \ -{ \ - while ( mga_in32(MGAREG_STATUS) & 0x10000 ) \ - ; \ -} -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/matrox_regs.h b/project/jni/sdl-1.3/src/video/fbcon/matrox_regs.h deleted file mode 100644 index f05bae731..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/matrox_regs.h +++ /dev/null @@ -1,376 +0,0 @@ - -/* - * MGA Millennium (MGA2064W) functions - * MGA Mystique (MGA1064SG) functions - * - * Copyright 1996 The XFree86 Project, Inc. - * - * Authors - * Dirk Hohndel - * hohndel@XFree86.Org - * David Dawes - * dawes@XFree86.Org - * Contributors: - * Guy DESBIEF, Aix-en-provence, France - * g.desbief@aix.pacwan.net - * MGA1064SG Mystique register file - */ - - -#ifndef _MGA_REG_H_ -#define _MGA_REG_H_ - -#define MGAREG_DWGCTL 0x1c00 -#define MGAREG_MACCESS 0x1c04 -/* the following is a mystique only register */ -#define MGAREG_MCTLWTST 0x1c08 -#define MGAREG_ZORG 0x1c0c - -#define MGAREG_PAT0 0x1c10 -#define MGAREG_PAT1 0x1c14 -#define MGAREG_PLNWT 0x1c1c - -#define MGAREG_BCOL 0x1c20 -#define MGAREG_FCOL 0x1c24 - -#define MGAREG_SRC0 0x1c30 -#define MGAREG_SRC1 0x1c34 -#define MGAREG_SRC2 0x1c38 -#define MGAREG_SRC3 0x1c3c - -#define MGAREG_XYSTRT 0x1c40 -#define MGAREG_XYEND 0x1c44 - -#define MGAREG_SHIFT 0x1c50 -/* the following is a mystique only register */ -#define MGAREG_DMAPAD 0x1c54 -#define MGAREG_SGN 0x1c58 -#define MGAREG_LEN 0x1c5c - -#define MGAREG_AR0 0x1c60 -#define MGAREG_AR1 0x1c64 -#define MGAREG_AR2 0x1c68 -#define MGAREG_AR3 0x1c6c -#define MGAREG_AR4 0x1c70 -#define MGAREG_AR5 0x1c74 -#define MGAREG_AR6 0x1c78 - -#define MGAREG_CXBNDRY 0x1c80 -#define MGAREG_FXBNDRY 0x1c84 -#define MGAREG_YDSTLEN 0x1c88 -#define MGAREG_PITCH 0x1c8c - -#define MGAREG_YDST 0x1c90 -#define MGAREG_YDSTORG 0x1c94 -#define MGAREG_YTOP 0x1c98 -#define MGAREG_YBOT 0x1c9c - -#define MGAREG_CXLEFT 0x1ca0 -#define MGAREG_CXRIGHT 0x1ca4 -#define MGAREG_FXLEFT 0x1ca8 -#define MGAREG_FXRIGHT 0x1cac - -#define MGAREG_XDST 0x1cb0 - -#define MGAREG_DR0 0x1cc0 -#define MGAREG_DR1 0x1cc4 -#define MGAREG_DR2 0x1cc8 -#define MGAREG_DR3 0x1ccc - -#define MGAREG_DR4 0x1cd0 -#define MGAREG_DR5 0x1cd4 -#define MGAREG_DR6 0x1cd8 -#define MGAREG_DR7 0x1cdc - -#define MGAREG_DR8 0x1ce0 -#define MGAREG_DR9 0x1ce4 -#define MGAREG_DR10 0x1ce8 -#define MGAREG_DR11 0x1cec - -#define MGAREG_DR12 0x1cf0 -#define MGAREG_DR13 0x1cf4 -#define MGAREG_DR14 0x1cf8 -#define MGAREG_DR15 0x1cfc - -#define MGAREG_SRCORG 0x2cb4 -#define MGAREG_DSTORG 0x2cb8 - -/* add or or this to one of the previous "power registers" to start - the drawing engine */ - -#define MGAREG_EXEC 0x0100 - -#define MGAREG_FIFOSTATUS 0x1e10 -#define MGAREG_STATUS 0x1e14 -#define MGAREG_ICLEAR 0x1e18 -#define MGAREG_IEN 0x1e1c - -#define MGAREG_VCOUNT 0x1e20 - -#define MGAREG_Reset 0x1e40 - -#define MGAREG_OPMODE 0x1e54 - -/* OPMODE register additives */ - -#define MGAOPM_DMA_GENERAL (0x00 << 2) -#define MGAOPM_DMA_BLIT (0x01 << 2) -#define MGAOPM_DMA_VECTOR (0x10 << 2) - -/* DWGCTL register additives */ - -/* Lines */ - -#define MGADWG_LINE_OPEN 0x00 -#define MGADWG_AUTOLINE_OPEN 0x01 -#define MGADWG_LINE_CLOSE 0x02 -#define MGADWG_AUTOLINE_CLOSE 0x03 - -/* Trapezoids */ -#define MGADWG_TRAP 0x04 -#define MGADWG_TEXTURE_TRAP 0x05 - -/* BitBlts */ - -#define MGADWG_BITBLT 0x08 -#define MGADWG_FBITBLT 0x0c -#define MGADWG_ILOAD 0x09 -#define MGADWG_ILOAD_SCALE 0x0d -#define MGADWG_ILOAD_FILTER 0x0f -#define MGADWG_IDUMP 0x0a - -/* atype access to WRAM */ - -#define MGADWG_RPL ( 0x00 << 4 ) -#define MGADWG_RSTR ( 0x01 << 4 ) -#define MGADWG_ZI ( 0x03 << 4 ) -#define MGADWG_BLK ( 0x04 << 4 ) -#define MGADWG_I ( 0x07 << 4 ) - -/* specifies whether bit blits are linear or xy */ -#define MGADWG_LINEAR ( 0x01 << 7 ) - -/* z drawing mode. use MGADWG_NOZCMP for always */ - -#define MGADWG_NOZCMP ( 0x00 << 8 ) -#define MGADWG_ZE ( 0x02 << 8 ) -#define MGADWG_ZNE ( 0x03 << 8 ) -#define MGADWG_ZLT ( 0x04 << 8 ) -#define MGADWG_ZLTE ( 0x05 << 8 ) -#define MGADWG_GT ( 0x06 << 8 ) -#define MGADWG_GTE ( 0x07 << 8 ) - -/* use this to force colour expansion circuitry to do its stuff */ - -#define MGADWG_SOLID ( 0x01 << 11 ) - -/* ar register at zero */ - -#define MGADWG_ARZERO ( 0x01 << 12 ) - -#define MGADWG_SGNZERO ( 0x01 << 13 ) - -#define MGADWG_SHIFTZERO ( 0x01 << 14 ) - -/* See table on 4-43 for bop ALU operations */ - -/* See table on 4-44 for translucidity masks */ - -#define MGADWG_BMONOLEF ( 0x00 << 25 ) -#define MGADWG_BMONOWF ( 0x04 << 25 ) -#define MGADWG_BPLAN ( 0x01 << 25 ) - -/* note that if bfcol is specified and you're doing a bitblt, it causes - a fbitblt to be performed, so check that you obey the fbitblt rules */ - -#define MGADWG_BFCOL ( 0x02 << 25 ) -#define MGADWG_BUYUV ( 0x0e << 25 ) -#define MGADWG_BU32BGR ( 0x03 << 25 ) -#define MGADWG_BU32RGB ( 0x07 << 25 ) -#define MGADWG_BU24BGR ( 0x0b << 25 ) -#define MGADWG_BU24RGB ( 0x0f << 25 ) - -#define MGADWG_REPLACE 0x000C0000 /* From Linux kernel sources */ -#define MGADWG_PATTERN ( 0x01 << 29 ) -#define MGADWG_TRANSC ( 0x01 << 30 ) -#define MGADWG_NOCLIP ( 0x01 << 31 ) -#define MGAREG_MISC_WRITE 0x3c2 -#define MGAREG_MISC_READ 0x3cc -#define MGAREG_MISC_IOADSEL (0x1 << 0) -#define MGAREG_MISC_RAMMAPEN (0x1 << 1) -#define MGAREG_MISC_CLK_SEL_VGA25 (0x0 << 2) -#define MGAREG_MISC_CLK_SEL_VGA28 (0x1 << 2) -#define MGAREG_MISC_CLK_SEL_MGA_PIX (0x2 << 2) -#define MGAREG_MISC_CLK_SEL_MGA_MSK (0x3 << 2) -#define MGAREG_MISC_VIDEO_DIS (0x1 << 4) -#define MGAREG_MISC_HIGH_PG_SEL (0x1 << 5) - -/* MMIO VGA registers */ -#define MGAREG_CRTC_INDEX 0x1fd4 -#define MGAREG_CRTC_DATA 0x1fd5 -#define MGAREG_CRTCEXT_INDEX 0x1fde -#define MGAREG_CRTCEXT_DATA 0x1fdf - - -/* MGA bits for registers PCI_OPTION_REG */ -#define MGA1064_OPT_SYS_CLK_PCI ( 0x00 << 0 ) -#define MGA1064_OPT_SYS_CLK_PLL ( 0x01 << 0 ) -#define MGA1064_OPT_SYS_CLK_EXT ( 0x02 << 0 ) -#define MGA1064_OPT_SYS_CLK_MSK ( 0x03 << 0 ) - -#define MGA1064_OPT_SYS_CLK_DIS ( 0x01 << 2 ) -#define MGA1064_OPT_G_CLK_DIV_1 ( 0x01 << 3 ) -#define MGA1064_OPT_M_CLK_DIV_1 ( 0x01 << 4 ) - -#define MGA1064_OPT_SYS_PLL_PDN ( 0x01 << 5 ) -#define MGA1064_OPT_VGA_ION ( 0x01 << 8 ) - -/* MGA registers in PCI config space */ -#define PCI_MGA_INDEX 0x44 -#define PCI_MGA_DATA 0x48 -#define PCI_MGA_OPTION2 0x50 -#define PCI_MGA_OPTION3 0x54 - -#define RAMDAC_OFFSET 0x3c00 - -/* TVP3026 direct registers */ - -#define TVP3026_INDEX 0x00 -#define TVP3026_WADR_PAL 0x00 -#define TVP3026_COL_PAL 0x01 -#define TVP3026_PIX_RD_MSK 0x02 -#define TVP3026_RADR_PAL 0x03 -#define TVP3026_CUR_COL_ADDR 0x04 -#define TVP3026_CUR_COL_DATA 0x05 -#define TVP3026_DATA 0x0a -#define TVP3026_CUR_RAM 0x0b -#define TVP3026_CUR_XLOW 0x0c -#define TVP3026_CUR_XHI 0x0d -#define TVP3026_CUR_YLOW 0x0e -#define TVP3026_CUR_YHI 0x0f - -/* TVP3026 indirect registers */ - -#define TVP3026_SILICON_REV 0x01 -#define TVP3026_CURSOR_CTL 0x06 -#define TVP3026_LATCH_CTL 0x0f -#define TVP3026_TRUE_COLOR_CTL 0x18 -#define TVP3026_MUX_CTL 0x19 -#define TVP3026_CLK_SEL 0x1a -#define TVP3026_PAL_PAGE 0x1c -#define TVP3026_GEN_CTL 0x1d -#define TVP3026_MISC_CTL 0x1e -#define TVP3026_GEN_IO_CTL 0x2a -#define TVP3026_GEN_IO_DATA 0x2b -#define TVP3026_PLL_ADDR 0x2c -#define TVP3026_PIX_CLK_DATA 0x2d -#define TVP3026_MEM_CLK_DATA 0x2e -#define TVP3026_LOAD_CLK_DATA 0x2f -#define TVP3026_KEY_RED_LOW 0x32 -#define TVP3026_KEY_RED_HI 0x33 -#define TVP3026_KEY_GREEN_LOW 0x34 -#define TVP3026_KEY_GREEN_HI 0x35 -#define TVP3026_KEY_BLUE_LOW 0x36 -#define TVP3026_KEY_BLUE_HI 0x37 -#define TVP3026_KEY_CTL 0x38 -#define TVP3026_MCLK_CTL 0x39 -#define TVP3026_SENSE_TEST 0x3a -#define TVP3026_TEST_DATA 0x3b -#define TVP3026_CRC_LSB 0x3c -#define TVP3026_CRC_MSB 0x3d -#define TVP3026_CRC_CTL 0x3e -#define TVP3026_ID 0x3f -#define TVP3026_RESET 0xff - - -/* MGA1064 DAC Register file */ -/* MGA1064 direct registers */ - -#define MGA1064_INDEX 0x00 -#define MGA1064_WADR_PAL 0x00 -#define MGA1064_COL_PAL 0x01 -#define MGA1064_PIX_RD_MSK 0x02 -#define MGA1064_RADR_PAL 0x03 -#define MGA1064_DATA 0x0a - -#define MGA1064_CUR_XLOW 0x0c -#define MGA1064_CUR_XHI 0x0d -#define MGA1064_CUR_YLOW 0x0e -#define MGA1064_CUR_YHI 0x0f - -/* MGA1064 indirect registers */ -#define MGA1064_CURSOR_BASE_ADR_LOW 0x04 -#define MGA1064_CURSOR_BASE_ADR_HI 0x05 -#define MGA1064_CURSOR_CTL 0x06 -#define MGA1064_CURSOR_COL0_RED 0x08 -#define MGA1064_CURSOR_COL0_GREEN 0x09 -#define MGA1064_CURSOR_COL0_BLUE 0x0a - -#define MGA1064_CURSOR_COL1_RED 0x0c -#define MGA1064_CURSOR_COL1_GREEN 0x0d -#define MGA1064_CURSOR_COL1_BLUE 0x0e - -#define MGA1064_CURSOR_COL2_RED 0x010 -#define MGA1064_CURSOR_COL2_GREEN 0x011 -#define MGA1064_CURSOR_COL2_BLUE 0x012 - -#define MGA1064_VREF_CTL 0x018 - -#define MGA1064_MUL_CTL 0x19 -#define MGA1064_MUL_CTL_8bits 0x0 -#define MGA1064_MUL_CTL_15bits 0x01 -#define MGA1064_MUL_CTL_16bits 0x02 -#define MGA1064_MUL_CTL_24bits 0x03 -#define MGA1064_MUL_CTL_32bits 0x04 -#define MGA1064_MUL_CTL_2G8V16bits 0x05 -#define MGA1064_MUL_CTL_G16V16bits 0x06 -#define MGA1064_MUL_CTL_32_24bits 0x07 - -#define MGAGDAC_XVREFCTRL 0x18 -#define MGA1064_PIX_CLK_CTL 0x1a -#define MGA1064_PIX_CLK_CTL_CLK_DIS ( 0x01 << 2 ) -#define MGA1064_PIX_CLK_CTL_CLK_POW_DOWN ( 0x01 << 3 ) -#define MGA1064_PIX_CLK_CTL_SEL_PCI ( 0x00 << 0 ) -#define MGA1064_PIX_CLK_CTL_SEL_PLL ( 0x01 << 0 ) -#define MGA1064_PIX_CLK_CTL_SEL_EXT ( 0x02 << 0 ) -#define MGA1064_PIX_CLK_CTL_SEL_MSK ( 0x03 << 0 ) - -#define MGA1064_GEN_CTL 0x1d -#define MGA1064_MISC_CTL 0x1e -#define MGA1064_MISC_CTL_DAC_POW_DN ( 0x01 << 0 ) -#define MGA1064_MISC_CTL_VGA ( 0x01 << 1 ) -#define MGA1064_MISC_CTL_DIS_CON ( 0x03 << 1 ) -#define MGA1064_MISC_CTL_MAFC ( 0x02 << 1 ) -#define MGA1064_MISC_CTL_VGA8 ( 0x01 << 3 ) -#define MGA1064_MISC_CTL_DAC_RAM_CS ( 0x01 << 4 ) - -#define MGA1064_GEN_IO_CTL 0x2a -#define MGA1064_GEN_IO_DATA 0x2b -#define MGA1064_SYS_PLL_M 0x2c -#define MGA1064_SYS_PLL_N 0x2d -#define MGA1064_SYS_PLL_P 0x2e -#define MGA1064_SYS_PLL_STAT 0x2f -#define MGA1064_ZOOM_CTL 0x38 -#define MGA1064_SENSE_TST 0x3a - -#define MGA1064_CRC_LSB 0x3c -#define MGA1064_CRC_MSB 0x3d -#define MGA1064_CRC_CTL 0x3e -#define MGA1064_COL_KEY_MSK_LSB 0x40 -#define MGA1064_COL_KEY_MSK_MSB 0x41 -#define MGA1064_COL_KEY_LSB 0x42 -#define MGA1064_COL_KEY_MSB 0x43 -#define MGA1064_PIX_PLLA_M 0x44 -#define MGA1064_PIX_PLLA_N 0x45 -#define MGA1064_PIX_PLLA_P 0x46 -#define MGA1064_PIX_PLLB_M 0x48 -#define MGA1064_PIX_PLLB_N 0x49 -#define MGA1064_PIX_PLLB_P 0x4a -#define MGA1064_PIX_PLLC_M 0x4c -#define MGA1064_PIX_PLLC_N 0x4d -#define MGA1064_PIX_PLLC_P 0x4e - -#define MGA1064_PIX_PLL_STAT 0x4f - -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/riva_mmio.h b/project/jni/sdl-1.3/src/video/fbcon/riva_mmio.h deleted file mode 100644 index da1d26b68..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/riva_mmio.h +++ /dev/null @@ -1,455 +0,0 @@ -/***************************************************************************\ -|* *| -|* Copyright 1993-1999 NVIDIA, Corporation. All rights reserved. *| -|* *| -|* NOTICE TO USER: The source code is copyrighted under U.S. and *| -|* international laws. Users and possessors of this source code are *| -|* hereby granted a nonexclusive, royalty-free copyright license to *| -|* use this code in individual and commercial software. *| -|* *| -|* Any use of this source code must include, in the user documenta- *| -|* tion and internal comments to the code, notices to the end user *| -|* as follows: *| -|* *| -|* Copyright 1993-1999 NVIDIA, Corporation. All rights reserved. *| -|* *| -|* NVIDIA, CORPORATION MAKES NO REPRESENTATION ABOUT THE SUITABILITY *| -|* OF THIS SOURCE CODE FOR ANY PURPOSE. IT IS PROVIDED "AS IS" *| -|* WITHOUT EXPRESS OR IMPLIED WARRANTY OF ANY KIND. NVIDIA, CORPOR- *| -|* ATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOURCE CODE, *| -|* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGE- *| -|* MENT, AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL *| -|* NVIDIA, CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT, INCI- *| -|* DENTAL, OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES WHATSOEVER RE- *| -|* SULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION *| -|* OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF *| -|* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOURCE CODE. *| -|* *| -|* U.S. Government End Users. This source code is a "commercial *| -|* item," as that term is defined at 48 C.F.R. 2.101 (OCT 1995), *| -|* consisting of "commercial computer software" and "commercial *| -|* computer software documentation," as such terms are used in *| -|* 48 C.F.R. 12.212 (SEPT 1995) and is provided to the U.S. Govern- *| -|* ment only as a commercial end item. Consistent with 48 C.F.R. *| -|* 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (JUNE 1995), *| -|* all U.S. Government End Users acquire the source code with only *| -|* those rights set forth herein. *| -|* *| -\***************************************************************************/ - -#ifndef __RIVA_HW_H__ -#define __RIVA_HW_H__ -#define RIVA_SW_VERSION 0x00010003 - -/* - * Typedefs to force certain sized values. - */ -typedef Uint8 U008; -typedef Uint16 U016; -typedef Uint32 U032; - -/* - * HW access macros. - */ -#define NV_WR08(p,i,d) (((U008 *)(p))[i]=(d)) -#define NV_RD08(p,i) (((U008 *)(p))[i]) -#define NV_WR16(p,i,d) (((U016 *)(p))[(i)/2]=(d)) -#define NV_RD16(p,i) (((U016 *)(p))[(i)/2]) -#define NV_WR32(p,i,d) (((U032 *)(p))[(i)/4]=(d)) -#define NV_RD32(p,i) (((U032 *)(p))[(i)/4]) -#define VGA_WR08(p,i,d) NV_WR08(p,i,d) -#define VGA_RD08(p,i) NV_RD08(p,i) - -/* - * Define supported architectures. - */ -#define NV_ARCH_03 0x03 -#define NV_ARCH_04 0x04 -#define NV_ARCH_10 0x10 -/***************************************************************************\ -* * -* FIFO registers. * -* * -\***************************************************************************/ - -/* - * Raster OPeration. Windows style ROP3. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BB]; - U032 Rop3; -} RivaRop; -/* - * 8X8 Monochrome pattern. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BD]; - U032 Shape; - U032 reserved03[0x001]; - U032 Color0; - U032 Color1; - U032 Monochrome[2]; -} RivaPattern; -/* - * Scissor clip rectangle. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BB]; - U032 TopLeft; - U032 WidthHeight; -} RivaClip; -/* - * 2D filled rectangle. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop[1]; - U032 reserved01[0x0BC]; - U032 Color; - U032 reserved03[0x03E]; - U032 TopLeft; - U032 WidthHeight; -} RivaRectangle; -/* - * 2D screen-screen BLT. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BB]; - U032 TopLeftSrc; - U032 TopLeftDst; - U032 WidthHeight; -} RivaScreenBlt; -/* - * 2D pixel BLT. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop[1]; - U032 reserved01[0x0BC]; - U032 TopLeft; - U032 WidthHeight; - U032 WidthHeightIn; - U032 reserved02[0x03C]; - U032 Pixels; -} RivaPixmap; -/* - * Filled rectangle combined with monochrome expand. Useful for glyphs. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BB]; - U032 reserved03[(0x040) - 1]; - U032 Color1A; - struct - { - U032 TopLeft; - U032 WidthHeight; - } UnclippedRectangle[64]; - U032 reserved04[(0x080) - 3]; - struct - { - U032 TopLeft; - U032 BottomRight; - } ClipB; - U032 Color1B; - struct - { - U032 TopLeft; - U032 BottomRight; - } ClippedRectangle[64]; - U032 reserved05[(0x080) - 5]; - struct - { - U032 TopLeft; - U032 BottomRight; - } ClipC; - U032 Color1C; - U032 WidthHeightC; - U032 PointC; - U032 MonochromeData1C; - U032 reserved06[(0x080) + 121]; - struct - { - U032 TopLeft; - U032 BottomRight; - } ClipD; - U032 Color1D; - U032 WidthHeightInD; - U032 WidthHeightOutD; - U032 PointD; - U032 MonochromeData1D; - U032 reserved07[(0x080) + 120]; - struct - { - U032 TopLeft; - U032 BottomRight; - } ClipE; - U032 Color0E; - U032 Color1E; - U032 WidthHeightInE; - U032 WidthHeightOutE; - U032 PointE; - U032 MonochromeData01E; -} RivaBitmap; -/* - * 3D textured, Z buffered triangle. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BC]; - U032 TextureOffset; - U032 TextureFormat; - U032 TextureFilter; - U032 FogColor; -/* This is a problem on LynxOS */ -#ifdef Control -#undef Control -#endif - U032 Control; - U032 AlphaTest; - U032 reserved02[0x339]; - U032 FogAndIndex; - U032 Color; - float ScreenX; - float ScreenY; - float ScreenZ; - float EyeM; - float TextureS; - float TextureT; -} RivaTexturedTriangle03; -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BB]; - U032 ColorKey; - U032 TextureOffset; - U032 TextureFormat; - U032 TextureFilter; - U032 Blend; -/* This is a problem on LynxOS */ -#ifdef Control -#undef Control -#endif - U032 Control; - U032 FogColor; - U032 reserved02[0x39]; - struct - { - float ScreenX; - float ScreenY; - float ScreenZ; - float EyeM; - U032 Color; - U032 Specular; - float TextureS; - float TextureT; - } Vertex[16]; - U032 DrawTriangle3D; -} RivaTexturedTriangle05; -/* - * 2D line. - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop[1]; - U032 reserved01[0x0BC]; - U032 Color; /* source color 0304-0307 */ - U032 Reserved02[0x03e]; - struct - { /* start aliased methods in array 0400- */ - U032 point0; /* y_x S16_S16 in pixels 0- 3 */ - U032 point1; /* y_x S16_S16 in pixels 4- 7 */ - } Lin[16]; /* end of aliased methods in array -047f */ - struct - { /* start aliased methods in array 0480- */ - U032 point0X; /* in pixels, 0 at left 0- 3 */ - U032 point0Y; /* in pixels, 0 at top 4- 7 */ - U032 point1X; /* in pixels, 0 at left 8- b */ - U032 point1Y; /* in pixels, 0 at top c- f */ - } Lin32[8]; /* end of aliased methods in array -04ff */ - U032 PolyLin[32]; /* y_x S16_S16 in pixels 0500-057f */ - struct - { /* start aliased methods in array 0580- */ - U032 x; /* in pixels, 0 at left 0- 3 */ - U032 y; /* in pixels, 0 at top 4- 7 */ - } PolyLin32[16]; /* end of aliased methods in array -05ff */ - struct - { /* start aliased methods in array 0600- */ - U032 color; /* source color 0- 3 */ - U032 point; /* y_x S16_S16 in pixels 4- 7 */ - } ColorPolyLin[16]; /* end of aliased methods in array -067f */ -} RivaLine; -/* - * 2D/3D surfaces - */ -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BE]; - U032 Offset; -} RivaSurface; -typedef volatile struct -{ - U032 reserved00[4]; - U016 FifoFree; - U016 Nop; - U032 reserved01[0x0BD]; - U032 Pitch; - U032 RenderBufferOffset; - U032 ZBufferOffset; -} RivaSurface3D; - -/***************************************************************************\ -* * -* Virtualized RIVA H/W interface. * -* * -\***************************************************************************/ - -struct _riva_hw_inst; -struct _riva_hw_state; -/* - * Virtialized chip interface. Makes RIVA 128 and TNT look alike. - */ -typedef struct _riva_hw_inst -{ - /* - * Chip specific settings. - */ - U032 Architecture; - U032 Version; - U032 CrystalFreqKHz; - U032 RamAmountKBytes; - U032 MaxVClockFreqKHz; - U032 RamBandwidthKBytesPerSec; - U032 EnableIRQ; - U032 IO; - U032 VBlankBit; - U032 FifoFreeCount; - U032 FifoEmptyCount; - /* - * Non-FIFO registers. - */ - volatile U032 *PCRTC; - volatile U032 *PRAMDAC; - volatile U032 *PFB; - volatile U032 *PFIFO; - volatile U032 *PGRAPH; - volatile U032 *PEXTDEV; - volatile U032 *PTIMER; - volatile U032 *PMC; - volatile U032 *PRAMIN; - volatile U032 *FIFO; - volatile U032 *CURSOR; - volatile U032 *CURSORPOS; - volatile U032 *VBLANKENABLE; - volatile U032 *VBLANK; - volatile U008 *PCIO; - volatile U008 *PVIO; - volatile U008 *PDIO; - /* - * Common chip functions. - */ - int (*Busy) (struct _riva_hw_inst *); - void (*CalcStateExt) (struct _riva_hw_inst *, struct _riva_hw_state *, - int, int, int, int, int, int, int, int, int, int, - int, int, int); - void (*LoadStateExt) (struct _riva_hw_inst *, struct _riva_hw_state *); - void (*UnloadStateExt) (struct _riva_hw_inst *, struct _riva_hw_state *); - void (*SetStartAddress) (struct _riva_hw_inst *, U032); - void (*SetSurfaces2D) (struct _riva_hw_inst *, U032, U032); - void (*SetSurfaces3D) (struct _riva_hw_inst *, U032, U032); - int (*ShowHideCursor) (struct _riva_hw_inst *, int); - void (*LockUnlock) (struct _riva_hw_inst *, int); - /* - * Current extended mode settings. - */ - struct _riva_hw_state *CurrentState; - /* - * FIFO registers. - */ - RivaRop *Rop; - RivaPattern *Patt; - RivaClip *Clip; - RivaPixmap *Pixmap; - RivaScreenBlt *Blt; - RivaBitmap *Bitmap; - RivaLine *Line; - RivaTexturedTriangle03 *Tri03; - RivaTexturedTriangle05 *Tri05; -} RIVA_HW_INST; -/* - * Extended mode state information. - */ -typedef struct _riva_hw_state -{ - U032 bpp; - U032 width; - U032 height; - U032 repaint0; - U032 repaint1; - U032 screen; - U032 pixel; - U032 horiz; - U032 arbitration0; - U032 arbitration1; - U032 vpll; - U032 pllsel; - U032 general; - U032 config; - U032 cursor0; - U032 cursor1; - U032 cursor2; - U032 offset0; - U032 offset1; - U032 offset2; - U032 offset3; - U032 pitch0; - U032 pitch1; - U032 pitch2; - U032 pitch3; -} RIVA_HW_STATE; - -/* - * FIFO Free Count. Should attempt to yield processor if RIVA is busy. - */ - -#define RIVA_FIFO_FREE(hwptr,cnt) \ -{ \ - while (FifoFreeCount < (cnt)) \ - FifoFreeCount = hwptr->FifoFree >> 2; \ - FifoFreeCount -= (cnt); \ -} -#endif /* __RIVA_HW_H__ */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/fbcon/riva_regs.h b/project/jni/sdl-1.3/src/video/fbcon/riva_regs.h deleted file mode 100644 index ad8b51c3c..000000000 --- a/project/jni/sdl-1.3/src/video/fbcon/riva_regs.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _RIVA_REGS_H -#define _RIVA_REGS_H - -/* This information comes from the XFree86 NVidia hardware driver */ - -/* mapped_io register offsets */ -#define PGRAPH_OFFSET 0x00400000 -#define FIFO_OFFSET 0x00800000 -#define ROP_OFFSET FIFO_OFFSET+0x00000000 -#define CLIP_OFFSET FIFO_OFFSET+0x00002000 -#define PATT_OFFSET FIFO_OFFSET+0x00004000 -#define PIXMAP_OFFSET FIFO_OFFSET+0x00006000 -#define BLT_OFFSET FIFO_OFFSET+0x00008000 -#define BITMAP_OFFSET FIFO_OFFSET+0x0000A000 -#define LINE_OFFSET FIFO_OFFSET+0x0000C000 -#define TRI03_OFFSET FIFO_OFFSET+0x0000E000 -#define PCIO_OFFSET 0x00601000 - -#endif /* _RIVA_REGS_H */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/nds/SDL_ndsevents.c b/project/jni/sdl-1.3/src/video/nds/SDL_ndsevents.c index 94db798c8..558eda048 100644 --- a/project/jni/sdl-1.3/src/video/nds/SDL_ndsevents.c +++ b/project/jni/sdl-1.3/src/video/nds/SDL_ndsevents.c @@ -1,34 +1,31 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -/* Being a null driver, there's no event stream. We just define stubs for - most of the API. */ +#if SDL_VIDEO_DRIVER_NDS #include #include #include -#include "../../events/SDL_sysevents.h" #include "../../events/SDL_events_c.h" #include "SDL_ndsvideo.h" @@ -45,10 +42,13 @@ NDS_PumpEvents(_THIS) SDL_SendMouseButton(0, SDL_RELEASED, 0); } if (keysHeld() & KEY_TOUCH) { - touchPosition t = touchReadXY(); - SDL_SendMouseMotion(0, 0, t.px, t.py, 1); /* last arg is pressure, - hardcoded 1 for now */ + touchPosition t; + + touchRead(&t); + SDL_SendMouseMotion(0, 0, t.px, t.py); } } +#endif /* SDL_VIDEO_DRIVER_NDS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/nds/SDL_ndsevents_c.h b/project/jni/sdl-1.3/src/video/nds/SDL_ndsevents_c.h index 36de58fba..3712f2f1d 100644 --- a/project/jni/sdl-1.3/src/video/nds/SDL_ndsevents_c.h +++ b/project/jni/sdl-1.3/src/video/nds/SDL_ndsevents_c.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/nds/SDL_ndsrender.c b/project/jni/sdl-1.3/src/video/nds/SDL_ndsrender.c deleted file mode 100644 index 3ff158372..000000000 --- a/project/jni/sdl-1.3/src/video/nds/SDL_ndsrender.c +++ /dev/null @@ -1,598 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -#include -#include -#include -//#include -//#include -//#include - -#include "SDL_config.h" - -#include "SDL_video.h" -#include "../SDL_sysvideo.h" -#include "../SDL_yuv_sw_c.h" -#include "../SDL_renderer_sw.h" - -/* SDL NDS renderer implementation */ - -static SDL_Renderer *NDS_CreateRenderer(SDL_Window * window, Uint32 flags); -static int NDS_ActivateRenderer(SDL_Renderer * renderer); -static int NDS_DisplayModeChanged(SDL_Renderer * renderer); -static int NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int NDS_QueryTexturePixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int NDS_SetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); -static int NDS_GetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors); -static int NDS_SetTextureColorMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int NDS_SetTextureAlphaMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int NDS_SetTextureBlendMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int NDS_SetTextureScaleMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); -static int NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch); -static void NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, - Uint8 b, Uint8 a, const SDL_Rect * rect); -static int NDS_RenderCopy(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect); -static void NDS_RenderPresent(SDL_Renderer * renderer); -static void NDS_DestroyTexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void NDS_DestroyRenderer(SDL_Renderer * renderer); - - -SDL_RenderDriver NDS_RenderDriver = { - NDS_CreateRenderer, - {"nds", /* char* name */ - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_PRESENTVSYNC), /* u32 flags */ - (SDL_TEXTUREMODULATE_NONE), /* u32 mod_modes */ - (SDL_BLENDMODE_MASK), /* u32 blend_modes */ - (SDL_SCALEMODE_FAST), /* u32 scale_modes */ - 3, /* u32 num_texture_formats */ - { - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_ABGR1555, - SDL_PIXELFORMAT_BGR555, - }, /* u32 texture_formats[20] */ - (256), /* int max_texture_width */ - (256), /* int max_texture_height */ - } -}; - -typedef struct -{ - u8 bg_taken[4]; - OamState *oam; - int sub; -} NDS_RenderData; - -typedef struct -{ - enum - { NDSTX_BG, NDSTX_SPR } type; /* represented in a bg or sprite. */ - int hw_index; /* index of sprite in OAM or bg from libnds */ - int pitch, bpp; /* useful information about the texture */ - struct - { - int x, y; - } scale; /* x/y stretch (24.8 fixed point) */ - struct - { - int x, y; - } scroll; /* x/y offset */ - int rotate; /* -32768 to 32767, texture rotation */ - u16 *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */ - u16 *vram_palette; /* where the palette data is stored if it's indexed. */ - /*int size; */ -} NDS_TextureData; - - - -SDL_Renderer * -NDS_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - SDL_VideoDisplay *display = window->display; - SDL_DisplayMode *displayMode = &display->current_mode; - SDL_Renderer *renderer; - NDS_RenderData *data; - int i, n; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp, - &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown display format"); - return NULL; - } - switch (displayMode->format) { - case SDL_PIXELFORMAT_INDEX8: - case SDL_PIXELFORMAT_ABGR1555: - case SDL_PIXELFORMAT_BGR555: - /* okay */ - break; - case SDL_PIXELFORMAT_RGB555: - case SDL_PIXELFORMAT_RGB565: - case SDL_PIXELFORMAT_ARGB1555: - /* we'll take these too for now */ - break; - default: - SDL_SetError("Warning: wrong display format for NDS!\n"); - break; - } - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (NDS_RenderData *) SDL_malloc(sizeof(*data)); - if (!data) { - NDS_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - SDL_zerop(data); - - renderer->RenderFill = NDS_RenderFill; - renderer->RenderCopy = NDS_RenderCopy; - renderer->RenderPresent = NDS_RenderPresent; - renderer->DestroyRenderer = NDS_DestroyRenderer; - renderer->info.name = NDS_RenderDriver.info.name; - renderer->info.flags = 0; - renderer->window = window; - renderer->driverdata = data; - renderer->CreateTexture = NDS_CreateTexture; - renderer->QueryTexturePixels = NDS_QueryTexturePixels; - renderer->SetTexturePalette = NDS_SetTexturePalette; - renderer->GetTexturePalette = NDS_GetTexturePalette; - renderer->SetTextureColorMod = NDS_SetTextureColorMod; - renderer->SetTextureAlphaMod = NDS_SetTextureAlphaMod; - renderer->SetTextureBlendMode = NDS_SetTextureBlendMode; - renderer->SetTextureScaleMode = NDS_SetTextureScaleMode; - renderer->UpdateTexture = NDS_UpdateTexture; - renderer->LockTexture = NDS_LockTexture; - renderer->UnlockTexture = NDS_UnlockTexture; - renderer->DestroyTexture = NDS_DestroyTexture; - - renderer->info.mod_modes = NDS_RenderDriver.info.mod_modes; - renderer->info.blend_modes = NDS_RenderDriver.info.blend_modes; - renderer->info.scale_modes = NDS_RenderDriver.info.scale_modes; - renderer->info.num_texture_formats = - NDS_RenderDriver.info.num_texture_formats; - SDL_memcpy(renderer->info.texture_formats, - NDS_RenderDriver.info.texture_formats, - sizeof(renderer->info.texture_formats)); - renderer->info.max_texture_width = - NDS_RenderDriver.info.max_texture_width; - renderer->info.max_texture_height = - NDS_RenderDriver.info.max_texture_height; - - data->sub = 0; /* TODO: this is hard-coded to the "main" screen. - figure out how to detect whether to set it to - "sub" screen. window->id, perhaps? */ - data->bg_taken[2] = data->bg_taken[3] = 0; - - return renderer; -} - -static int -NDS_ActivateRenderer(SDL_Renderer * renderer) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - - return 0; -} - -static int -NDS_DisplayModeChanged(SDL_Renderer * renderer) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - - return 0; -} - -static int -NDS_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - NDS_TextureData *txdat = NULL; - int i; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (!SDL_PixelFormatEnumToMasks - (texture->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown texture format"); - return -1; - } - - /* conditional statements on w/h to place it as bg/sprite - depending on which one it fits. */ - if (texture->w <= 64 && texture->h <= 64) { - int whichspr = -1; - printf("NDS_CreateTexture: Tried to make a sprite.\n"); - txdat->type = NDSTX_SPR; -#if 0 - for (i = 0; i < SPRITE_COUNT; ++i) { - if (data->oam_copy.spriteBuffer[i].attribute[0] & ATTR0_DISABLED) { - whichspr = i; - break; - } - } - if (whichspr >= 0) { - SpriteEntry *sprent = &(data->oam_copy.spriteBuffer[whichspr]); - int maxside = texture->w > texture->h ? texture->w : texture->h; - int pitch; - - texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData)); - txdat = (NDS_TextureData *) texture->driverdata; - if (!txdat) { - SDL_OutOfMemory(); - return -1; - } - - sprent->objMode = OBJMODE_BITMAP; - sprent->posX = 0; - sprent->posY = 0; - sprent->colMode = OBJCOLOR_16; /* OBJCOLOR_256 for INDEX8 */ - - /* the first 32 sprites get transformation matrices. - first come, first served */ - if (whichspr < MATRIX_COUNT) { - sprent->isRotoscale = 1; - sprent->rsMatrixIdx = whichspr; - } - - /* containing shape (square or 2:1 rectangles) */ - sprent->objShape = OBJSHAPE_SQUARE; - if (texture->w / 2 >= texture->h) { - sprent->objShape = OBJSHAPE_WIDE; - } else if (texture->h / 2 >= texture->w) { - sprent->objShape = OBJSHAPE_TALL; - } - - /* size in pixels */ - /* FIXME: "pitch" is hardcoded for 2bytes per pixel. */ - sprent->objSize = OBJSIZE_64; - pitch = 128; - if (maxside <= 8) { - sprent->objSize = OBJSIZE_8; - pitch = 16; - } else if (maxside <= 16) { - sprent->objSize = OBJSIZE_16; - pitch = 32; - } else if (maxside <= 32) { - sprent->objSize = OBJSIZE_32; - pitch = 64; - } - - /* FIXME: this is hard-coded and will obviously only work for one - sprite-texture. tells it to look at the beginning of SPRITE_GFX - for its pixels. */ - sprent->tileIdx = 0; - - /* now for the texture data */ - txdat->type = NDSTX_SPR; - txdat->hw_index = whichspr; - txdat->dim.hdx = 0x100; - txdat->dim.hdy = 0; - txdat->dim.vdx = 0; - txdat->dim.vdy = 0x100; - txdat->dim.pitch = pitch; - txdat->dim.bpp = bpp; - txdat->vram_pixels = - (u16 *) (data->sub ? SPRITE_GFX_SUB : SPRITE_GFX); - /* FIXME: use tileIdx*boundary - to point to proper location */ - } else { - SDL_SetError("Out of NDS sprites."); - } -#endif - } else if (texture->w <= 256 && texture->h <= 256) { - int whichbg = -1, base = 0; - if (!data->bg_taken[2]) { - whichbg = 2; - } else if (!data->bg_taken[3]) { - whichbg = 3; - base = 4; - } - if (whichbg >= 0) { - texture->driverdata = SDL_calloc(1, sizeof(NDS_TextureData)); - txdat = (NDS_TextureData *) texture->driverdata; - if (!txdat) { - SDL_OutOfMemory(); - return -1; - } -// hard-coded for 256x256 for now... -// TODO: a series of if-elseif-else's to find the closest but larger size. - if (!data->sub) { - if (bpp == 8) { - txdat->hw_index = - bgInit(whichbg, BgType_Bmp8, BgSize_B8_256x256, 0, 0); - } else { - txdat->hw_index = - bgInit(whichbg, BgType_Bmp16, BgSize_B16_256x256, 0, - 0); - } - } else { - if (bpp == 8) { - txdat->hw_index = - bgInitSub(whichbg, BgType_Bmp8, BgSize_B8_256x256, 0, - 0); - } else { - txdat->hw_index = - bgInitSub(whichbg, BgType_Bmp16, BgSize_B16_256x256, - 0, 0); - } - } - -/* useful functions - bgGetGfxPtr(bg3); - bgSetCenter(bg3, rcX, rcY); - bgSetRotateScale(bg3, angle, scaleX, scaleY); - bgSetScroll(bg3, scrollX, scrollY); - bgUpdate(bg3); -*/ - txdat->type = NDSTX_BG; - txdat->pitch = (texture->w) * (bpp / 8); - txdat->bpp = bpp; - txdat->rotate = 0; - txdat->scale.x = 0x100; - txdat->scale.y = 0x100; - txdat->scroll.x = 0; - txdat->scroll.y = 0; - txdat->vram_pixels = (u16 *) bgGetGfxPtr(txdat->hw_index); - - bgSetCenter(txdat->hw_index, 0, 0); - bgSetRotateScale(txdat->hw_index, txdat->rotate, txdat->scale.x, - txdat->scale.y); - bgSetScroll(txdat->hw_index, txdat->scroll.x, txdat->scroll.y); - bgUpdate(txdat->hw_index); - - data->bg_taken[whichbg] = 1; - /*txdat->size = txdat->dim.pitch * texture->h; */ - } else { - SDL_SetError("Out of NDS backgrounds."); - } - } else { - SDL_SetError("Texture too big for NDS hardware."); - } - - if (!texture->driverdata) { - return -1; - } - - return 0; -} - -static int -NDS_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; - *pixels = txdat->vram_pixels; - *pitch = txdat->pitch; - return 0; -} - -static int -NDS_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - NDS_TextureData *txdat; - Uint8 *src, *dst; - int row; - size_t length; - - txdat = (NDS_TextureData *) texture->driverdata; - - src = (Uint8 *) pixels; - dst = - (Uint8 *) txdat->vram_pixels + rect->y * txdat->pitch + rect->x * - ((txdat->bpp + 1) / 8); - length = rect->w * ((txdat->bpp + 1) / 8); - - if (rect->w == texture->w) { - dmaCopy(src, dst, length * rect->h); - } else { - for (row = 0; row < rect->h; ++row) { - dmaCopy(src, dst, length); - src += pitch; - dst += txdat->pitch; - } - } - - return 0; -} - -static int -NDS_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; - - *pixels = (void *) ((u8 *) txdat->vram_pixels + rect->y * txdat->pitch + - rect->x * ((txdat->bpp + 1) / 8)); - *pitch = txdat->pitch; - - return 0; -} - -static void -NDS_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - /* stub! */ -} - -static int -NDS_RenderFill(SDL_Renderer * renderer, Uint8 r, Uint8 g, Uint8 b, - Uint8 a, const SDL_Rect * rect) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - SDL_Rect real_rect = *rect; - u16 color; - int i, j; - - printf("NDS_RenderFill: stub\n"); - color = RGB8(r, g, b); /* macro in libnds that makes an ARGB1555 pixel */ - /* TODO: make a single-color sprite and stretch it. - calculate the "HDX" width modifier of the sprite by: - let S be the actual sprite's width (like, 32 pixels for example) - let R be the rectangle's width (maybe 50 pixels) - HDX = (R<<8) / S; - (it's fixed point, hence the bit shift. same goes for vertical. - be sure to use 32-bit int's for the bit shift before the division!) - */ - - return 0; -} - -static int -NDS_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - int Bpp = SDL_BYTESPERPIXEL(texture->format); - - if (txdat->type == NDSTX_BG) { - txdat->scroll.x = dstrect->x; - txdat->scroll.y = dstrect->y; - } else { - /* sprites not fully implemented yet */ - printf("NDS_RenderCopy: used sprite!\n"); -// SpriteEntry *spr = &(data->oam_copy.spriteBuffer[txdat->hw_index]); -// spr->posX = dstrect->x; -// spr->posY = dstrect->y; -// if (txdat->hw_index < MATRIX_COUNT && spr->isRotoscale) { -// } - } - - return 0; -} - - -static void -NDS_RenderPresent(SDL_Renderer * renderer) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - - /* update sprites */ -// NDS_OAM_Update(&(data->oam_copy), data->sub); - /* vsync for NDS */ - if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { - swiWaitForVBlank(); - } -} - -static void -NDS_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - NDS_TextureData *txdat = texture->driverdata; - /* free anything else allocated for texture */ - SDL_free(txdat); -} - -static void -NDS_DestroyRenderer(SDL_Renderer * renderer) -{ - NDS_RenderData *data = (NDS_RenderData *) renderer->driverdata; - int i; - - if (data) { - /* free anything else relevant if anything else is allocated. */ - SDL_free(data); - } - SDL_free(renderer); -} - -static int -NDS_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, int ncolors) -{ - NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; - /* set 8-bit modes in the background control registers - for backgrounds, BGn_CR |= BG_256_COLOR */ - - return 0; -} - -static int -NDS_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, int ncolors) -{ - NDS_TextureData *txdat = (NDS_TextureData *) texture->driverdata; - /* stub! */ - return 0; -} - -static int -NDS_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - /* stub! */ - return 0; -} - -static int -NDS_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - /* stub! */ - return 0; -} - -static int -NDS_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - /* stub! */ - return 0; -} - -static int -NDS_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - /* stub! (note: NDS hardware scaling is nearest neighbor.) */ - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/nds/SDL_ndsrender_c.h b/project/jni/sdl-1.3/src/video/nds/SDL_ndsrender_c.h deleted file mode 100644 index 124d95966..000000000 --- a/project/jni/sdl-1.3/src/video/nds/SDL_ndsrender_c.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* SDL surface based renderer implementation */ - -extern SDL_RenderDriver NDS_RenderDriver; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/nds/SDL_ndsvideo.c b/project/jni/sdl-1.3/src/video/nds/SDL_ndsvideo.c index 4411eeeed..98d3d25e8 100644 --- a/project/jni/sdl-1.3/src/video/nds/SDL_ndsvideo.c +++ b/project/jni/sdl-1.3/src/video/nds/SDL_ndsvideo.c @@ -1,94 +1,383 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -/* SDL Nintendo DS video driver implementation - * based on dummy driver: - * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion - * of this was cut-and-pasted from Stephane Peter's work in the AAlib - * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. - */ +#if SDL_VIDEO_DRIVER_NDS + +/* SDL Nintendo DS video driver implementation */ #include #include #include -#include +#include +#include #include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" - #include "SDL_ndsvideo.h" #include "SDL_ndsevents_c.h" -#include "SDL_ndsrender_c.h" +#include "../../render/SDL_sysrender.h" +#include "SDL_log.h" #define NDSVID_DRIVER_NAME "nds" -/* Initialization/Query functions */ -static int NDS_VideoInit(_THIS); -static int NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode); -static void NDS_VideoQuit(_THIS); - - -/* SDL NDS driver bootstrap functions */ -static int -NDS_Available(void) +static SDL_DisplayMode display_modes[] = { - return (1); /* always here */ + /* Only one screen */ + { + .format = SDL_PIXELFORMAT_ABGR1555, + .w = SCREEN_WIDTH, + .h = SCREEN_HEIGHT, + .refresh_rate = 60, + }, + + /* Aggregated display (two screens) with no gap. */ + { + .format = SDL_PIXELFORMAT_ABGR1555, + .w = SCREEN_WIDTH, + .h = 2*SCREEN_HEIGHT+SCREEN_GAP, + .refresh_rate = 60, + }, + + /* Aggregated display (two screens) with a gap. */ + { + .format = SDL_PIXELFORMAT_ABGR1555, + .w = SCREEN_WIDTH, + .h = 2*SCREEN_HEIGHT, + .refresh_rate = 60, + }, + + /* Last entry */ + { + .w = 0, + } +}; + +/* This function must not be optimized nor inlined, else the pointer + * to the message will be in the wrong register, and the emulator won't + * find the string. */ +__attribute__ ((noinline, optimize (0))) +static void NDS_DebugOutput2(const char* message) +{ +#ifdef __thumb__ + asm volatile ("swi #0xfc"); +#else + asm volatile ("swi #0xfc0000"); +#endif } -static void -NDS_DeleteDevice(SDL_VideoDevice * device) +static void NDS_DebugOutput(void *userdata, int category, SDL_LogPriority priority, const char *message) +{ + NDS_DebugOutput2(message); +} + +/* SDL NDS driver bootstrap functions */ +static int NDS_Available(void) +{ + return 1; /* always here */ +} + +#ifndef USE_HW_RENDERER +static int NDS_CreateWindowFramebuffer(_THIS, SDL_Window *window, + Uint32 *format, void **pixels, + int *pitch) +{ + struct NDS_WindowData *wdata; + int bpp; + Uint32 Rmask, Gmask, Bmask, Amask; + const SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + const SDL_DisplayMode *mode = display->driverdata; + const Uint32 fmt = mode->format; + + if (fmt != SDL_PIXELFORMAT_ABGR1555) { + SDL_SetError("Unsupported pixel format (%x)", fmt); + return -1; + } + + if (!SDL_PixelFormatEnumToMasks + (fmt, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { + SDL_SetError("Unknown texture format"); + return -1; + } + + wdata = SDL_calloc(1, sizeof(struct NDS_WindowData)); + if (!wdata) { + SDL_OutOfMemory(); + return -1; + } + + if (bpp == 8) { + wdata->pixels_length = (SCREEN_HEIGHT+SCREEN_GAP+SCREEN_HEIGHT)*SCREEN_WIDTH; + } else { + wdata->pixels_length = (SCREEN_HEIGHT+SCREEN_GAP+SCREEN_HEIGHT)*SCREEN_WIDTH*2; + } + wdata->pixels = SDL_calloc(1, wdata->pixels_length); + if (!wdata->pixels) { + SDL_free(wdata); + SDL_SetError("Not enough memory"); + return -1; + } + + if (bpp == 8) { + wdata->main.bg_id = bgInit(2, BgType_Bmp8, BgSize_B8_256x256, 0, 0); + wdata->sub.bg_id = bgInitSub(3, BgType_Bmp8, BgSize_B8_256x256, 0, 0); + + wdata->main.length = SCREEN_HEIGHT*SCREEN_WIDTH; + wdata->main.pixels = wdata->pixels; + + wdata->sub.length = SCREEN_HEIGHT*SCREEN_WIDTH; + wdata->sub.pixels = (u8 *)wdata->pixels + wdata->main.length; /* or ...+SCREEN_GAP */ + + } else { + wdata->main.bg_id = bgInit(2, BgType_Bmp16, BgSize_B16_256x256, 0, 0); + wdata->sub.bg_id = bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); + + wdata->main.length = SCREEN_HEIGHT*SCREEN_WIDTH*2; + wdata->main.pixels = wdata->pixels; + + wdata->sub.length = SCREEN_HEIGHT*SCREEN_WIDTH*2; + wdata->sub.pixels = (u8 *)wdata->pixels + wdata->main.length; /* or ...+SCREEN_GAP */ + } + + wdata->pitch = (window->w) * ((bpp+1) / 8); + wdata->bpp = bpp; + wdata->rotate = 0; + wdata->scale.x = 0x100; + wdata->scale.y = 0x100; + wdata->scroll.x = 0; + wdata->scroll.y = 0; + + wdata->main.vram_pixels = bgGetGfxPtr(wdata->main.bg_id); + wdata->sub.vram_pixels = bgGetGfxPtr(wdata->sub.bg_id); + +#if 0 + bgSetCenter(wdata->main.bg_id, 0, 0); + bgSetRotateScale(wdata->main.bg_id, wdata->rotate, wdata->scale.x, + wdata->scale.y); + bgSetScroll(wdata->main.bg_id, wdata->scroll.x, wdata->scroll.y); +#endif + +#if 0 + bgSetCenter(wdata->sub.bg_id, 0, 0); + bgSetRotateScale(wdata->sub.bg_id, wdata->rotate, wdata->scale.x, + wdata->scale.y); + bgSetScroll(wdata->sub.bg_id, wdata->scroll.x, wdata->scroll.y); +#endif + + bgUpdate(); + + *format = fmt; + *pixels = wdata->pixels; + *pitch = wdata->pitch; + + window->driverdata = wdata; + + return 0; +} + +static int NDS_UpdateWindowFramebuffer(_THIS, SDL_Window * window, + SDL_Rect * rects, int numrects) +{ + struct NDS_WindowData *wdata = window->driverdata; + + /* Copy everything. TODO: use rects/numrects. */ + DC_FlushRange(wdata->pixels, wdata->pixels_length); + + swiWaitForVBlank(); + + dmaCopy(wdata->main.pixels, wdata->main.vram_pixels, wdata->main.length); + dmaCopy(wdata->sub.pixels, wdata->sub.vram_pixels, wdata->sub.length); + + return 0; +} + +static void NDS_DestroyWindowFramebuffer(_THIS, SDL_Window *window) +{ + struct NDS_WindowData *wdata = window->driverdata; + + SDL_free(wdata->pixels); + SDL_free(wdata); +} +#endif + +#ifdef USE_HW_RENDERER +/* Set up a 2D layer construced of bitmap sprites. This holds the + * image when rendering to the top screen. From libnds example. + */ +static void initSubSprites(void) +{ + oamInit(&oamSub, SpriteMapping_Bmp_2D_256, false); + + int x = 0; + int y = 0; + + int id = 0; + + //set up a 4x3 grid of 64x64 sprites to cover the screen + for(y = 0; y < 3; y++) + for(x = 0; x < 4; x++) + { + oamSub.oamMemory[id].attribute[0] = ATTR0_BMP | ATTR0_SQUARE | (64 * y); + oamSub.oamMemory[id].attribute[1] = ATTR1_SIZE_64 | (64 * x); + oamSub.oamMemory[id].attribute[2] = ATTR2_ALPHA(1) | (8 * 32 * y) | (8 * x); + id++; + } + + swiWaitForVBlank(); + + oamUpdate(&oamSub); +} +#endif + +static int NDS_SetDisplayMode(_THIS, SDL_VideoDisplay *display, SDL_DisplayMode *mode) +{ + display->driverdata = mode->driverdata; + + powerOn(POWER_ALL_2D); + +#ifdef USE_HW_RENDERER + + videoSetMode(MODE_5_3D); + videoSetModeSub(MODE_5_2D); + + /* initialize gl2d */ + glScreen2D(); + glBegin2D(); + + vramSetBankA(VRAM_A_TEXTURE); + vramSetBankB(VRAM_B_TEXTURE ); + vramSetBankC(VRAM_C_SUB_BG_0x06200000); + vramSetBankE(VRAM_E_TEX_PALETTE); + + // sub sprites hold the bottom image when 3D directed to top + initSubSprites(); + + // sub background holds the top image when 3D directed to bottom + bgInitSub(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); +#else + + /* Select mode 5 for both screens. Can do Extended Rotation + * Background on both (BG 2 and 3). */ + videoSetMode(MODE_5_2D); + videoSetModeSub(MODE_5_2D); + + vramSetBankA(VRAM_A_MAIN_BG_0x06000000); + vramSetBankB(VRAM_B_TEXTURE ); + vramSetBankC(VRAM_C_SUB_BG_0x06200000); + vramSetBankE(VRAM_E_TEX_PALETTE); + +#endif + + return 0; +} + +void NDS_GetDisplayModes(_THIS, SDL_VideoDisplay * display) +{ + SDL_DisplayMode *mode; + + for (mode = display_modes; mode->w; mode++) { + mode->driverdata = mode; /* point back to self */ + SDL_AddDisplayMode(display, mode); + } +} + +static int NDS_VideoInit(_THIS) +{ + SDL_VideoDisplay display; + SDL_DisplayMode mode; + + SDL_zero(mode); + + mode.format = SDL_PIXELFORMAT_UNKNOWN; // should be SDL_PIXELFORMAT_ABGR1555; + mode.w = SCREEN_WIDTH; + mode.h = 2*SCREEN_HEIGHT+SCREEN_GAP; + mode.refresh_rate = 60; + + SDL_zero(display); + + display.desktop_mode = mode; + + SDL_AddVideoDisplay(&display); + + return 0; +} + +static void NDS_VideoQuit(_THIS) +{ + videoSetMode(DISPLAY_SCREEN_OFF); + videoSetModeSub(DISPLAY_SCREEN_OFF); + vramSetBankA(VRAM_A_LCD); + vramSetBankB(VRAM_B_LCD); + vramSetBankC(VRAM_C_LCD); + vramSetBankD(VRAM_D_LCD); + vramSetBankE(VRAM_E_LCD); + vramSetBankF(VRAM_F_LCD); + vramSetBankG(VRAM_G_LCD); + vramSetBankH(VRAM_H_LCD); + vramSetBankI(VRAM_I_LCD); +} + +static void NDS_DeleteDevice(SDL_VideoDevice * device) { SDL_free(device); } -static SDL_VideoDevice * -NDS_CreateDevice(int devindex) +static SDL_VideoDevice *NDS_CreateDevice(int devindex) { SDL_VideoDevice *device; + fatInitDefault(); + /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + device = SDL_calloc(1, sizeof(SDL_VideoDevice)); if (!device) { SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } - return (0); + return NULL; + } + + device->driverdata = SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (!device) { + SDL_free(device); + SDL_OutOfMemory(); + return NULL; } /* Set the function pointers */ device->VideoInit = NDS_VideoInit; device->VideoQuit = NDS_VideoQuit; + device->GetDisplayModes = NDS_GetDisplayModes; device->SetDisplayMode = NDS_SetDisplayMode; + device->CreateWindow = NDS_CreateWindow; +#ifndef USE_HW_RENDERER + device->CreateWindowFramebuffer = NDS_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = NDS_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = NDS_DestroyWindowFramebuffer; +#endif device->PumpEvents = NDS_PumpEvents; - - device->num_displays = 2; /* DS = dual screens */ - device->free = NDS_DeleteDevice; + /* Set the debug output. Use only under an emulator. Will crash the DS. */ +#if 0 + SDL_LogSetOutputFunction(NDS_DebugOutput, NULL); +#endif + return device; } @@ -97,74 +386,16 @@ VideoBootStrap NDS_bootstrap = { NDS_Available, NDS_CreateDevice }; -int -NDS_VideoInit(_THIS) +double SDLCALL SDL_pow(double x, double y) { - SDL_DisplayMode mode; - int i; - - /* simple 256x192x16x60 for now */ - mode.w = 256; - mode.h = 192; - mode.format = SDL_PIXELFORMAT_ABGR1555; - mode.refresh_rate = 60; - mode.driverdata = NULL; - - if (SDL_AddBasicVideoDisplay(&mode) < 0) { - return -1; - } - SDL_AddRenderDriver(&_this->displays[0], &NDS_RenderDriver); - - SDL_zero(mode); - SDL_AddDisplayMode(0, &mode); - - powerON(POWER_ALL_2D); - irqInit(); - irqEnable(IRQ_VBLANK); - NDS_SetDisplayMode(_this, &mode); - - return 0; + static int once = 1; + if (once) { + SDL_Log("SDL_pow called but not supported on this platform"); + once = 0; + } + return 0; } -static int -NDS_SetDisplayMode(_THIS, SDL_DisplayMode * mode) -{ - /* right now this function is just hard-coded for 256x192 ABGR1555 */ - videoSetMode(MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_BG_EXT_PALETTE | DISPLAY_SPR_1D_LAYOUT | DISPLAY_SPR_1D_BMP | DISPLAY_SPR_1D_BMP_SIZE_256 | /* (try 128 if 256 is trouble.) */ - DISPLAY_SPR_ACTIVE | DISPLAY_SPR_EXT_PALETTE); /* display on main core - with lots of flags set for - flexibility/capacity to render */ - - /* hopefully these cover all the various things we might need to do */ - vramSetBankA(VRAM_A_MAIN_BG_0x06000000); - vramSetBankB(VRAM_B_MAIN_BG_0x06020000); - vramSetBankC(VRAM_C_SUB_BG_0x06200000); - vramSetBankD(VRAM_D_MAIN_BG_0x06040000); /* not a typo. vram d can't sub */ - vramSetBankE(VRAM_E_MAIN_SPRITE); - vramSetBankF(VRAM_F_OBJ_EXT_PALETTE); - vramSetBankG(VRAM_G_BG_EXT_PALETTE); - vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE); - vramSetBankI(VRAM_I_SUB_SPRITE); - - videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); /* debug text on sub - TODO: this will change - when multi-head is - introduced in render */ - - return 0; -} - -void -NDS_VideoQuit(_THIS) -{ - videoSetMode(DISPLAY_SCREEN_OFF); - videoSetModeSub(DISPLAY_SCREEN_OFF); - vramSetMainBanks(VRAM_A_LCD, VRAM_B_LCD, VRAM_C_LCD, VRAM_D_LCD); - vramSetBankE(VRAM_E_LCD); - vramSetBankF(VRAM_F_LCD); - vramSetBankG(VRAM_G_LCD); - vramSetBankH(VRAM_H_LCD); - vramSetBankI(VRAM_I_LCD); -} +#endif /* SDL_VIDEO_DRIVER_NDS */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/nds/SDL_ndsvideo.h b/project/jni/sdl-1.3/src/video/nds/SDL_ndsvideo.h index 51d719888..ddf3f1fe6 100644 --- a/project/jni/sdl-1.3/src/video/nds/SDL_ndsvideo.h +++ b/project/jni/sdl-1.3/src/video/nds/SDL_ndsvideo.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -26,6 +25,35 @@ #include "../SDL_sysvideo.h" +#include "SDL_ndswindow.h" + +#define SCREEN_GAP 92 /* line-equivalent gap between the 2 screens */ + +/* Per Window information. */ +struct NDS_WindowData { + struct { + int bg_id; + void *vram_pixels; /* where the pixel data is stored (a pointer into VRAM) */ + void *pixels; /* area in user frame buffer */ + int length; + } main, sub; + + int pitch, bpp; /* useful information about the texture */ + struct { + int x, y; + } scale; /* x/y stretch (24.8 fixed point) */ + + struct { + int x, y; + } scroll; /* x/y offset */ + int rotate; /* -32768 to 32767, texture rotation */ + + /* user frame buffer - todo: better way to do double buffering */ + void *pixels; + int pixels_length; +}; + + #endif /* _SDL_ndsvideo_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/nds/SDL_ndswindow.c b/project/jni/sdl-1.3/src/video/nds/SDL_ndswindow.c new file mode 100644 index 000000000..f374a1c08 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/nds/SDL_ndswindow.c @@ -0,0 +1,37 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_NDS + +#include "SDL_ndsvideo.h" + + +int NDS_CreateWindow(_THIS, SDL_Window * window) +{ + /* Nintendo DS windows are always fullscreen */ + window->flags |= SDL_WINDOW_FULLSCREEN; + return 0; +} + +#endif /* SDL_VIDEO_DRIVER_NDS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/nds/SDL_ndswindow.h b/project/jni/sdl-1.3/src/video/nds/SDL_ndswindow.h new file mode 100644 index 000000000..361027459 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/nds/SDL_ndswindow.h @@ -0,0 +1,30 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_ndswindow_h +#define _SDL_ndswindow_h + +extern int NDS_CreateWindow(_THIS, SDL_Window * window); + +#endif /* _SDL_ndswindow_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/pandora/SDL_pandora.c b/project/jni/sdl-1.3/src/video/pandora/SDL_pandora.c index 6b33dac16..880a221f9 100644 --- a/project/jni/sdl-1.3/src/video/pandora/SDL_pandora.c +++ b/project/jni/sdl-1.3/src/video/pandora/SDL_pandora.c @@ -1,31 +1,28 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Open Pandora SDL driver - Copyright (C) 2009 David Carré - (cpasjuste@gmail.com) + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_PANDORA /* SDL internals */ -#include "SDL_config.h" #include "../SDL_sysvideo.h" #include "SDL_version.h" #include "SDL_syswm.h" @@ -417,7 +414,7 @@ PND_gl_createcontext(_THIS, SDL_Window * window) SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; EGLBoolean status; int32_t gfstatus; EGLint configs; @@ -816,7 +813,7 @@ PND_gl_swapwindow(_THIS, SDL_Window * window) SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; if (phdata->egl_initialized != SDL_TRUE) { @@ -868,4 +865,6 @@ PND_gl_deletecontext(_THIS, SDL_GLContext context) return; } +#endif /* SDL_VIDEO_DRIVER_PANDORA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/pandora/SDL_pandora.h b/project/jni/sdl-1.3/src/video/pandora/SDL_pandora.h index 8597baa07..eeacab34f 100644 --- a/project/jni/sdl-1.3/src/video/pandora/SDL_pandora.h +++ b/project/jni/sdl-1.3/src/video/pandora/SDL_pandora.h @@ -1,27 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Open Pandora SDL driver - Copyright (C) 2009 David Carré - (cpasjuste@gmail.com) + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef __SDL_PANDORA_H__ @@ -70,10 +65,6 @@ int PND_videoinit(_THIS); void PND_videoquit(_THIS); void PND_getdisplaymodes(_THIS, SDL_VideoDisplay * display); int PND_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); -int PND_setdisplaypalette(_THIS, SDL_Palette * palette); -int PND_getdisplaypalette(_THIS, SDL_Palette * palette); -int PND_setdisplaygammaramp(_THIS, Uint16 * ramp); -int PND_getdisplaygammaramp(_THIS, Uint16 * ramp); int PND_createwindow(_THIS, SDL_Window * window); int PND_createwindowfrom(_THIS, SDL_Window * window, const void *data); void PND_setwindowtitle(_THIS, SDL_Window * window); diff --git a/project/jni/sdl-1.3/src/video/pandora/SDL_pandora_events.c b/project/jni/sdl-1.3/src/video/pandora/SDL_pandora_events.c index e44899776..c6b22b18e 100644 --- a/project/jni/sdl-1.3/src/video/pandora/SDL_pandora_events.c +++ b/project/jni/sdl-1.3/src/video/pandora/SDL_pandora_events.c @@ -1,30 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_PANDORA + /* Being a null driver, there's no event stream. We just define stubs for most of the API. */ -#include "../../events/SDL_sysevents.h" #include "../../events/SDL_events_c.h" void @@ -33,4 +33,6 @@ PND_PumpEvents(_THIS) /* Not implemented. */ } +#endif /* SDL_VIDEO_DRIVER_PANDORA */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/pandora/SDL_pandora_events.h b/project/jni/sdl-1.3/src/video/pandora/SDL_pandora_events.h index dfbbfe6a4..7c317b042 100644 --- a/project/jni/sdl-1.3/src/video/pandora/SDL_pandora_events.h +++ b/project/jni/sdl-1.3/src/video/pandora/SDL_pandora_events.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon.c b/project/jni/sdl-1.3/src/video/photon/SDL_photon.c deleted file mode 100644 index add29c876..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon.c +++ /dev/null @@ -1,2852 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -/* SDL internals */ -#include "SDL_config.h" -#include "../SDL_sysvideo.h" -#include "SDL_version.h" -#include "SDL_syswm.h" -#include "SDL_loadso.h" -#include "SDL_events.h" -#include "../../events/SDL_mouse_c.h" -#include "../../events/SDL_keyboard_c.h" - -/* Photon declarations */ -#include "SDL_photon.h" - -/* Pixel format conversion routines */ -#include "SDL_photon_pixelfmt.h" - -/* Use GF's pixel format functions for OpenGL ES context creation */ -#if defined(SDL_VIDEO_OPENGL_ES) -#include "../qnxgf/SDL_gf_pixelfmt.h" - -/* If GF driver is not compiled in, include some of usefull functions */ -#if !defined(SDL_VIDEO_DRIVER_QNXGF) -#include "../qnxgf/SDL_gf_pixelfmt.c" -#endif /* SDL_VIDEO_DRIVER_QNXGF */ -#endif /* SDL_VIDEO_OPENGL_ES */ - -/* Use GF's OpenGL ES 1.1 functions emulation */ -#if defined(SDL_VIDEO_OPENGL_ES) -#include "../qnxgf/SDL_gf_opengles.h" - -/* If GF driver is not compiled in, include some of usefull functions */ -#if !defined(SDL_VIDEO_DRIVER_QNXGF) -#include "../qnxgf/SDL_gf_opengles.c" -#endif /* SDL_VIDEO_DRIVER_QNXGF */ -#endif /* SDL_VIDEO_OPENGL_ES */ - -/* Low level device graphics driver names, which they are reporting */ -static const Photon_DeviceCaps photon_devicename[] = { - /* ATI Rage 128 graphics driver (devg-ati_rage128) */ - {"ati_rage128", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Fujitsu Carmine graphics driver (devg-carmine.so) */ - {"carmine", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} - , - /* C&T graphics driver (devg-chips.so) */ - {"chips", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Fujitsu Coral graphics driver (devg-coral.so) */ - {"coral", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} - , - /* Intel integrated graphics driver (devg-extreme2.so) */ - {"extreme2", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} - , - /* Unaccelerated FB driver (devg-flat.so) */ - {"flat", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* NS Geode graphics driver (devg-geode.so) */ - {"geode", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Geode LX graphics driver (devg-geodelx.so) */ - {"geodelx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Intel integrated graphics driver (devg-gma9xx.so) */ - {"gma", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} - , - /* Intel integrated graphics driver (devg-i810.so) */ - {"i810", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Intel integrated graphics driver (devg-i830.so) */ - {"i830", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Geode LX graphics driver (devg-lx800.so) */ - {"lx800", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Matrox Gxx graphics driver (devg-matroxg.so) */ - {"matroxg", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Intel Poulsbo graphics driver (devg-poulsbo.so) */ - {"poulsbo", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} - , - /* ATI Radeon driver (devg-radeon.so) */ - {"radeon", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* ATI Rage driver (devg-rage.so) */ - {"rage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* S3 Savage graphics driver (devg-s3_savage.so) */ - {"s3_savage", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* SiS630 integrated graphics driver (devg-sis630.so) */ - {"sis630", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* PowerVR SGX 535 graphics driver (devg-poulsbo.so) */ - {"sgx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_ACCELERATED_3D} - , - /* SM Voyager GX graphics driver (devg-smi5xx.so) */ - {"smi5xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* Silicon Motion graphics driver (devg-smi7xx.so) */ - {"smi7xx", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* SVGA unaccelerated gfx driver (devg-svga.so) */ - {"svga", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* nVidia TNT graphics driver (devg-tnt.so) */ - {"tnt", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* VIA integrated graphics driver (devg-tvia.so) */ - {"tvia", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* VIA UniChrome graphics driver (devg-unichrome.so) */ - {"unichrome", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* VESA unaccelerated gfx driver (devg-vesabios.so) */ - {"vesa", SDL_PHOTON_UNACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* VmWare graphics driver (devg-volari.so) */ - {"vmware", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* XGI XP10 graphics driver (devg-volari.so), OpenGL 1.5 */ - {"volari", SDL_PHOTON_ACCELERATED | SDL_PHOTON_UNACCELERATED_3D} - , - /* End of list */ - {NULL, 0x00000000} -}; - -static SDL_bool photon_initialized = SDL_FALSE; - -static int -photon_available(void) -{ - int32_t status; - - /* Check if Photon was initialized before */ - if (photon_initialized == SDL_FALSE) { - /* Initialize Photon widget library and open channel to Photon */ - status = PtInit(NULL); - if (status == 0) { - photon_initialized = SDL_TRUE; - return 1; - } else { - photon_initialized = SDL_FALSE; - return 0; - } - } - - return 1; -} - -static void -photon_destroy(SDL_VideoDevice * device) -{ - SDL_VideoData *phdata = (SDL_VideoData *) device->driverdata; - -#if defined(SDL_VIDEO_OPENGL_ES) - if (phdata->gfinitialized != SDL_FALSE) { - gf_dev_detach(phdata->gfdev); - } -#endif /* SDL_VIDEO_OPENGL_ES */ - - if (device->driverdata != NULL) { - device->driverdata = NULL; - } -} - -static SDL_VideoDevice * -photon_create(int devindex) -{ - SDL_VideoDevice *device; - SDL_VideoData *phdata; - int32_t status; - - /* Check if photon could be initialized */ - status = photon_available(); - if (status == 0) { - /* Photon could not be used */ - return NULL; - } - - /* Photon agregates all video devices to one with multiple heads */ - if (devindex != 0) { - /* devindex could be zero only in Photon SDL driver */ - return NULL; - } - - /* Initialize SDL_VideoDevice structure */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { - SDL_OutOfMemory(); - return NULL; - } - - /* Initialize internal photon specific data */ - phdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); - if (phdata == NULL) { - SDL_OutOfMemory(); - SDL_free(device); - return NULL; - } - device->driverdata = phdata; - - /* Get all photon display devices */ - phdata->avail_rids = - PdGetDevices(&phdata->rid[0], SDL_VIDEO_PHOTON_MAX_RIDS); - if (phdata->avail_rids > SDL_VIDEO_PHOTON_MAX_RIDS) { - phdata->avail_rids = SDL_VIDEO_PHOTON_MAX_RIDS; - } -#if defined(SDL_VIDEO_OPENGL_ES) - /* TODO: add real device detection versus multiple heads */ - status = - gf_dev_attach(&phdata->gfdev, GF_DEVICE_INDEX(0), - &phdata->gfdev_info); - if (status != GF_ERR_OK) { - /* Do not fail right now, if GF can't be attached */ - phdata->gfinitialized = SDL_FALSE; - } else { - phdata->gfinitialized = SDL_TRUE; - } -#endif /* SDL_VIDEO_OPENGL_ES */ - - /* Set default target device */ - status = PdSetTargetDevice(NULL, phdata->rid[0]); - if (status == -1) { - SDL_SetError("Photon: Can't set default target device"); -#if defined(SDL_VIDEO_OPENGL_ES) - gf_dev_detach(phdata->gfdev); -#endif /* SDL_VIDEO_OPENGL_ES */ - SDL_free(phdata); - SDL_free(device); - return NULL; - } - phdata->current_device_id = 0; - - /* Setup amount of available displays and current display */ - device->num_displays = 0; - device->current_display = 0; - - /* Set device free function */ - device->free = photon_destroy; - - /* Setup all functions which we can handle */ - device->VideoInit = photon_videoinit; - device->VideoQuit = photon_videoquit; - device->GetDisplayModes = photon_getdisplaymodes; - device->SetDisplayMode = photon_setdisplaymode; - device->CreateWindow = photon_createwindow; - device->CreateWindowFrom = photon_createwindowfrom; - device->SetWindowTitle = photon_setwindowtitle; - device->SetWindowIcon = photon_setwindowicon; - device->SetWindowPosition = photon_setwindowposition; - device->SetWindowSize = photon_setwindowsize; - device->ShowWindow = photon_showwindow; - device->HideWindow = photon_hidewindow; - device->RaiseWindow = photon_raisewindow; - device->MaximizeWindow = photon_maximizewindow; - device->MinimizeWindow = photon_minimizewindow; - device->RestoreWindow = photon_restorewindow; - device->SetWindowGrab = photon_setwindowgrab; - device->DestroyWindow = photon_destroywindow; - device->GetWindowWMInfo = photon_getwindowwminfo; - device->GL_LoadLibrary = photon_gl_loadlibrary; - device->GL_GetProcAddress = photon_gl_getprocaddres; - device->GL_UnloadLibrary = photon_gl_unloadlibrary; - device->GL_CreateContext = photon_gl_createcontext; - device->GL_MakeCurrent = photon_gl_makecurrent; - device->GL_SetSwapInterval = photon_gl_setswapinterval; - device->GL_GetSwapInterval = photon_gl_getswapinterval; - device->GL_SwapWindow = photon_gl_swapwindow; - device->GL_DeleteContext = photon_gl_deletecontext; - device->PumpEvents = photon_pumpevents; - device->SuspendScreenSaver = photon_suspendscreensaver; - - return device; -} - -VideoBootStrap photon_bootstrap = { - "photon", - "SDL QNX Photon video driver", - photon_available, - photon_create -}; - -/*****************************************************************************/ -/* SDL Video and Display initialization/handling functions */ -/*****************************************************************************/ -int -photon_videoinit(_THIS) -{ - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - PgHWCaps_t hwcaps; - PgVideoModeInfo_t modeinfo; - int32_t status; - SDL_VideoDisplay display; - SDL_DisplayMode current_mode; - SDL_DisplayData *didata; - uint32_t it; - uint32_t jt; - char *override; - - /* By default Photon do not uses swap on VSYNC */ -#if defined(SDL_VIDEO_OPENGL_ES) - phdata->swapinterval = 0; -#endif /* SDL_VIDEO_OPENGL_ES */ - - for (it = 0; it < phdata->avail_rids; it++) { - didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); - if (didata == NULL) { - /* memory allocation error */ - SDL_OutOfMemory(); - return -1; - } - - /* Allocate two cursors with SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE size */ - /* and 128 bytes of spare place */ - didata->cursor_size = - ((SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE * 4) >> 3) + 128; - didata->cursor = (PhCursorDef_t *) SDL_calloc(1, didata->cursor_size); - if (didata->cursor == NULL) { - /* memory allocation error */ - SDL_OutOfMemory(); - SDL_free(didata); - return -1; - } - - /* Initialize GF in case of OpenGL ES support is compiled in */ -#if defined(SDL_VIDEO_OPENGL_ES) - /* TODO: add real device detection versus multiple heads */ - if (phdata->gfinitialized == SDL_TRUE) { - status = - gf_display_attach(&didata->display, phdata->gfdev, it, - &didata->display_info); - if (status != GF_ERR_OK) { - /* Just shutdown GF, do not fail */ - gf_dev_detach(phdata->gfdev); - phdata->gfinitialized = SDL_FALSE; - } - } -#endif /* SDL_VIDEO_OPENGL_ES */ - - /* Check if current device is not the same as target */ - if (phdata->current_device_id != it) { - /* Set target device as default for Pd and Pg functions */ - status = PdSetTargetDevice(NULL, phdata->rid[it]); - if (status != 0) { - SDL_SetError("Photon: Can't set default target device\n"); - SDL_free(didata->cursor); - SDL_free(didata); - return -1; - } - phdata->current_device_id = it; - } - - /* Store device id */ - didata->device_id = it; - - /* Query photon about graphics hardware caps and current video mode */ - SDL_memset(&hwcaps, 0x00, sizeof(PgHWCaps_t)); - status = PgGetGraphicsHWCaps(&hwcaps); - if (status != 0) { - PhRect_t extent; - PdOffscreenContext_t* curctx; - - /* If error happens, this also could mean, that photon is working */ - /* under custom (not listed by photon) video mode */ - status=PhWindowQueryVisible(Ph_QUERY_GRAPHICS, 0, 0, &extent); - if (status != 0) { - SDL_SetError("Photon: Can't get graphics driver region"); - SDL_free(didata->cursor); - SDL_free(didata); - return -1; - } - modeinfo.width=extent.lr.x+1; - modeinfo.height=extent.lr.y+1; - /* Hardcode 60Hz, as the base refresh rate frequency */ - hwcaps.current_rrate=60; - /* Clear current video driver name, no way to get it somehow */ - hwcaps.chip_name[0]=0x00; - - /* Create offscreen context from video memory, which is currently */ - /* displayed on the screen */ - curctx=PdCreateOffscreenContext(0, 0, 0, Pg_OSC_MAIN_DISPLAY); - if (curctx==NULL) - { - SDL_SetError("Photon: Can't get display area capabilities"); - SDL_free(didata->cursor); - SDL_free(didata); - return -1; - } - /* Retrieve current bpp */ - modeinfo.type=curctx->format; - PhDCRelease(curctx); - } else { - /* Get current video mode details */ - status = PgGetVideoModeInfo(hwcaps.current_video_mode, &modeinfo); - if (status != 0) { - SDL_SetError("Photon: Can't get current video mode information"); - SDL_free(didata->cursor); - SDL_free(didata); - return -1; - } - - /* Get current video mode 2D capabilities for the renderer */ - didata->mode_2dcaps=0; - if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND) - { - didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND; - } - if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT) - { - didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT; - } - } - - /* Setup current desktop mode for SDL */ - SDL_zero(current_mode); - current_mode.w = modeinfo.width; - current_mode.h = modeinfo.height; - current_mode.refresh_rate = hwcaps.current_rrate; - current_mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); - current_mode.driverdata = NULL; - - /* Copy device name */ - SDL_strlcpy(didata->description, hwcaps.chip_name, - SDL_VIDEO_PHOTON_DEVICENAME_MAX - 1); - - /* Search device capabilities and possible workarounds */ - jt = 0; - do { - if (photon_devicename[jt].name == NULL) { - break; - } - if (SDL_strncmp - (photon_devicename[jt].name, didata->description, - SDL_strlen(photon_devicename[jt].name)) == 0) { - didata->caps = photon_devicename[jt].caps; - } - jt++; - } while (1); - - /* Initialize display structure */ - SDL_zero(display); - display.desktop_mode = current_mode; - display.current_mode = current_mode; - display.fullscreen_mode = current_mode; - display.driverdata = didata; - didata->current_mode = current_mode; - SDL_AddVideoDisplay(&display); - - /* Check for environment variables which could override some SDL settings */ - didata->custom_refresh = 0; - override = SDL_getenv("SDL_VIDEO_PHOTON_REFRESH_RATE"); - if (override != NULL) { - if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) { - didata->custom_refresh = 0; - } - } - } - - /* Add photon input devices */ - status = photon_addinputdevices(_this); - if (status != 0) { - /* SDL error is set by photon_addinputdevices() function */ - return -1; - } - - /* Add photon renderer to SDL */ - photon_addrenderdriver(_this); - - /* video has been initialized successfully */ - return 1; -} - -void -photon_videoquit(_THIS) -{ - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata; - uint32_t it; - - /* SDL will restore our desktop mode on exit */ - for (it = 0; it < _this->num_displays; it++) { - didata = _this->displays[it].driverdata; - - if (didata->cursor != NULL) { - SDL_free(didata->cursor); - } -#if defined(SDL_VIDEO_OPENGL_ES) - if (phdata->gfinitialized == SDL_TRUE) { - /* Detach GF display */ - gf_display_detach(didata->display); - } -#endif /* SDL_VIDEO_OPENGL_ES */ - } -} - -void -photon_getdisplaymodes(_THIS, SDL_VideoDisplay * display) -{ - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - SDL_DisplayMode mode; - PgVideoModes_t modes; - PgVideoModeInfo_t modeinfo; - int32_t status; - uint32_t it; - uint32_t jt; - - /* Check if current device is not the same as target */ - if (phdata->current_device_id != didata->device_id) { - /* Set target device as default for Pd and Pg functions */ - status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); - if (status != 0) { - SDL_SetError("Photon: Can't set default target device\n"); - return; - } - phdata->current_device_id = didata->device_id; - } - - /* Get array of available video modes */ - status = PgGetVideoModeList(&modes); - if (status != 0) { - SDL_SetError("Photon: Can't get video mode list"); - return; - } - - for (it = 0; it < modes.num_modes; it++) { - status = PgGetVideoModeInfo(modes.modes[it], &modeinfo); - if (status != 0) { - /* Maybe something wrong with this particular mode, skip it */ - continue; - } - - jt = 0; - do { - if (modeinfo.refresh_rates[jt] != 0) { - mode.w = modeinfo.width; - mode.h = modeinfo.height; - mode.refresh_rate = modeinfo.refresh_rates[jt]; - mode.format = photon_image_to_sdl_pixelformat(modeinfo.type); - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - - /* If mode is RGBA8888, add the same mode as RGBx888 */ - if (modeinfo.type == Pg_IMAGE_DIRECT_8888) { - mode.w = modeinfo.width; - mode.h = modeinfo.height; - mode.refresh_rate = modeinfo.refresh_rates[jt]; - mode.format = SDL_PIXELFORMAT_RGB888; - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - } - - /* If mode is RGBA1555, add the same mode as RGBx555 */ - if (modeinfo.type == Pg_IMAGE_DIRECT_1555) { - mode.w = modeinfo.width; - mode.h = modeinfo.height; - mode.refresh_rate = modeinfo.refresh_rates[jt]; - mode.format = SDL_PIXELFORMAT_RGB555; - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - } - - jt++; - } else { - break; - } - } while (1); - } -} - -int -photon_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) -{ - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - PgVideoModes_t modes; - PgVideoModeInfo_t modeinfo; - PgDisplaySettings_t modesettings; - uint32_t refresh_rate = 0; - int32_t status; - uint32_t it; - - /* Check if current device is not the same as target */ - if (phdata->current_device_id != didata->device_id) { - /* Set target device as default for Pd and Pg functions */ - status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); - if (status != 0) { - SDL_SetError("Photon: Can't set default target device\n"); - return -1; - } - phdata->current_device_id = didata->device_id; - } - - /* Get array of available video modes */ - status = PgGetVideoModeList(&modes); - if (status != 0) { - SDL_SetError("Photon: Can't get video mode list"); - return -1; - } - - /* Current display dimension and bpp are no more valid */ - didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN; - didata->current_mode.w = 0; - didata->current_mode.h = 0; - - /* Check if custom refresh rate requested */ - if (didata->custom_refresh != 0) { - refresh_rate = didata->custom_refresh; - } else { - refresh_rate = mode->refresh_rate; - } - - /* Check if SDL GF driver needs to find appropriate refresh rate itself */ - if (refresh_rate == 0) { - SDL_DisplayMode tempmode; - - /* Clear display mode structure */ - SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); - tempmode.refresh_rate = 0x0000FFFF; - - /* Check if window width and height matches one of our modes */ - for (it = 0; it < display->num_display_modes; it++) { - if ((display->display_modes[it].w == mode->w) && - (display->display_modes[it].h == mode->h) && - (display->display_modes[it].format == mode->format)) - { - /* Find the lowest refresh rate available */ - if (tempmode.refresh_rate > - display->display_modes[it].refresh_rate) { - tempmode = display->display_modes[it]; - } - } - } - if (tempmode.refresh_rate != 0x0000FFFF) { - refresh_rate = tempmode.refresh_rate; - } else { - /* Let video driver decide what to do with this */ - refresh_rate = 0; - } - } - - /* Check if SDL GF driver needs to check custom refresh rate */ - if (didata->custom_refresh != 0) { - SDL_DisplayMode tempmode; - - /* Clear display mode structure */ - SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); - tempmode.refresh_rate = 0x0000FFFF; - - /* Check if window width and height matches one of our modes */ - for (it = 0; it < display->num_display_modes; it++) { - if ((display->display_modes[it].w == mode->w) && - (display->display_modes[it].h == mode->h) && - (display->display_modes[it].format == mode->format)) - { - /* Find the lowest refresh rate available */ - if (tempmode.refresh_rate > - display->display_modes[it].refresh_rate) { - tempmode = display->display_modes[it]; - } - - /* Check if requested refresh rate found */ - if (refresh_rate == - display->display_modes[it].refresh_rate) { - tempmode = display->display_modes[it]; - break; - } - } - } - if (tempmode.refresh_rate != 0x0000FFFF) { - refresh_rate = tempmode.refresh_rate; - } else { - /* Let video driver decide what to do with this */ - refresh_rate = 0; - } - } - - /* Find photon's video mode number */ - for (it = 0; it < modes.num_modes; it++) { - uint32_t jt; - uint32_t foundrefresh; - - /* Get current video mode details */ - status = PgGetVideoModeInfo(modes.modes[it], &modeinfo); - if (status != 0) { - /* Maybe something wrong with this particular mode, skip it */ - continue; - } - if ((modeinfo.width == mode->w) && (modeinfo.height == mode->h) && - (modeinfo.type == photon_sdl_to_image_pixelformat(mode->format))) - { - /* Mode is found, find requested refresh rate, this case is for */ - /* video drivers, which provide non-generic video modes. */ - jt = 0; - foundrefresh = 0; - do { - if (modeinfo.refresh_rates[jt] != 0) { - if (modeinfo.refresh_rates[jt] == refresh_rate) { - foundrefresh = 1; - break; - } - jt++; - } else { - break; - } - } while (1); - if (foundrefresh != 0) { - break; - } - } - } - - /* Check if video mode has not been found */ - if (it == modes.num_modes) { - SDL_SetError("Photon: Can't find appropriate video mode"); - return -1; - } - - /* Fill mode settings */ - modesettings.flags = 0x00000000; - modesettings.mode = modes.modes[it]; - modesettings.refresh = refresh_rate; - - /* Finally set new video mode */ - status = PgSetVideoMode(&modesettings); - if (status != 0) { - SDL_SetError("Photon: Can't set new video mode"); - return -1; - } - - /* Store new video mode parameters */ - didata->current_mode = *mode; - didata->current_mode.refresh_rate = refresh_rate; - - /* Get current video mode 2D capabilities for the renderer */ - didata->mode_2dcaps=0; - if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_ALPHA_BLEND)==PgVM_MODE_CAP2_ALPHA_BLEND) - { - didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND; - } - if ((modeinfo.mode_capabilities2 & PgVM_MODE_CAP2_SCALED_BLIT)==PgVM_MODE_CAP2_SCALED_BLIT) - { - didata->mode_2dcaps|=SDL_VIDEO_PHOTON_CAP_SCALED_BLIT; - } - - return 0; -} - -int -photon_createwindow(_THIS, SDL_Window * window) -{ - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; - SDL_WindowData *wdata; - PhDim_t winsize; - PhPoint_t winpos; - PtArg_t winargs[32]; - uint32_t winargc = 0; - int32_t status; - PhRegion_t wregion; - - /* Allocate window internal data */ - wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { - SDL_OutOfMemory(); - return -1; - } - - /* Setup driver data for this window */ - window->driverdata = wdata; - - /* Set initial window title */ - if (window->title != NULL) { - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, window->title, 0); - } else { - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_TITLE, "SDL unnamed application", 0); - } - - /* TODO: handle SDL_WINDOW_INPUT_GRABBED */ - - /* Disable default window filling on redraw */ - PtSetArg(&winargs[winargc++], Pt_ARG_BASIC_FLAGS, Pt_TRUE, - Pt_BASIC_PREVENT_FILL); - - /* Reset default managed flags to disabled state */ - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, - Ph_WM_APP_DEF_MANAGED); - /* Set which events we will not handle, let WM to handle them */ - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_TRUE, - Ph_WM_BACKDROP | Ph_WM_TOFRONT | Ph_WM_COLLAPSE | Ph_WM_FFRONT | - Ph_WM_FOCUS | Ph_WM_HELP | Ph_WM_HIDE | Ph_WM_MAX | - Ph_WM_MENU | Ph_WM_MOVE | Ph_WM_RESTORE | Ph_WM_TASKBAR | - Ph_WM_TOBACK | Ph_WM_RESIZE); - - /* Reset default notify events to disable */ - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_FALSE, - Ph_WM_RESIZE | Ph_WM_CLOSE | Ph_WM_HELP); - /* Set which events we will handle */ - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_NOTIFY_FLAGS, Pt_TRUE, - Ph_WM_CLOSE | Ph_WM_COLLAPSE | Ph_WM_FOCUS | Ph_WM_MAX | - Ph_WM_MOVE | Ph_WM_RESIZE | Ph_WM_RESTORE | Ph_WM_HIDE); - - /* Borderless window can't be resizeable */ - if ((window->flags & SDL_WINDOW_BORDERLESS) == SDL_WINDOW_BORDERLESS) { - window->flags &= ~(SDL_WINDOW_RESIZABLE); - } - - /* Reset all default decorations */ - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_FALSE, - Ph_WM_APP_DEF_RENDER); - - /* Fullscreen window has its own decorations */ - if ((window->flags & SDL_WINDOW_FULLSCREEN) == SDL_WINDOW_FULLSCREEN) { - window->flags |= SDL_WINDOW_BORDERLESS; - window->flags &= ~(SDL_WINDOW_RESIZABLE); - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, - Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_TITLE); - } else { - uint32_t decorations = - Ph_WM_RENDER_CLOSE | Ph_WM_RENDER_MENU | Ph_WM_RENDER_MIN | - Ph_WM_RENDER_TITLE | Ph_WM_RENDER_MOVE; - - if ((window->flags & SDL_WINDOW_RESIZABLE) == SDL_WINDOW_RESIZABLE) { - decorations |= - Ph_WM_RENDER_BORDER | Ph_WM_RENDER_RESIZE | Ph_WM_RENDER_MAX; - PtSetArg(&winargs[winargc++], Pt_ARG_RESIZE_FLAGS, Pt_TRUE, - Pt_RESIZE_XY_AS_REQUIRED); - } - if ((window->flags & SDL_WINDOW_BORDERLESS) != SDL_WINDOW_BORDERLESS) { - decorations |= Ph_WM_RENDER_BORDER; - } - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_RENDER_FLAGS, Pt_TRUE, - decorations); - } - - /* Set initial window state */ - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_FALSE, - Ph_WM_STATE_ISFOCUS); - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_STATE, Pt_TRUE, - Ph_WM_STATE_ISALTKEY); - - /* Special case, do not handle maximize events, if window can't be resized */ - if ((window->flags & SDL_WINDOW_RESIZABLE) != SDL_WINDOW_RESIZABLE) - { - PtSetArg(&winargs[winargc++], Pt_ARG_WINDOW_MANAGED_FLAGS, Pt_FALSE, - Ph_WM_MAX | Ph_WM_RESTORE | Ph_WM_RESIZE); - } - - /* Set window dimension */ - winsize.w = window->w; - winsize.h = window->h; - PtSetArg(&winargs[winargc++], Pt_ARG_DIM, &winsize, 0); - - /* Check if upper level requests WM to position window */ - if ((window->x == SDL_WINDOWPOS_UNDEFINED) - && (window->y == SDL_WINDOWPOS_UNDEFINED)) { - /* Do not set widget position, let WM to set it */ - } else { - if (window->x == SDL_WINDOWPOS_UNDEFINED) { - window->x = 0; - } - if (window->y == SDL_WINDOWPOS_UNDEFINED) { - window->y = 0; - } - if (window->x == SDL_WINDOWPOS_CENTERED) { - window->x = (didata->current_mode.w - window->w) / 2; - } - if (window->y == SDL_WINDOWPOS_CENTERED) { - window->y = (didata->current_mode.h - window->h) / 2; - } - - /* Now set window position */ - winpos.x = window->x; - winpos.y = window->y; - PtSetArg(&winargs[winargc++], Pt_ARG_POS, &winpos, 0); - } - - /* Check if window must support OpenGL ES rendering */ - if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { -#if defined(SDL_VIDEO_OPENGL_ES) - EGLBoolean initstatus; - - /* Check if GF was initialized correctly */ - if (phdata->gfinitialized == SDL_FALSE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return -1; - } - - /* Mark this window as OpenGL ES compatible */ - wdata->uses_gles = SDL_TRUE; - - /* Create connection to OpenGL ES */ - if (phdata->egldisplay == EGL_NO_DISPLAY) { - phdata->egldisplay = eglGetDisplay(phdata->gfdev); - if (phdata->egldisplay == EGL_NO_DISPLAY) { - SDL_SetError("Photon: Can't get connection to OpenGL ES"); - return -1; - } - - /* Initialize OpenGL ES library, ignore EGL version */ - initstatus = eglInitialize(phdata->egldisplay, NULL, NULL); - if (initstatus != EGL_TRUE) { - SDL_SetError("Photon: Can't init OpenGL ES library"); - return -1; - } - } - - /* Increment GL ES reference count usage */ - phdata->egl_refcount++; -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ - } - - /* Finally create the window */ - wdata->window = PtCreateWidget(PtWindow, Pt_NO_PARENT, winargc, winargs); - if (wdata->window == NULL) { - SDL_SetError("Photon: Can't create window widget"); - SDL_free(wdata); - return -1; - } - - /* Show widget */ - status = PtRealizeWidget(wdata->window); - if (status != 0) { - SDL_SetError("Photon: Can't realize window widget"); - PtDestroyWidget(wdata->window); - SDL_free(wdata); - return; - } - - /* Just created SDL window always gets focus */ - window->flags |= SDL_WINDOW_INPUT_FOCUS; - - /* Create window-specific cursor after creation */ - if (didata->cursor_visible == SDL_TRUE) { - /* Setup cursor type. shape and default color */ - PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR, - Ph_CURSOR_DEFAULT_COLOR, 0); - PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, 0); - PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, didata->cursor, - didata->cursor->hdr.len + sizeof(PhRegionDataHdr_t)); - } else { - PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, 0); - } - - /* Set window region sensible to mouse motion events */ - status = - PhRegionQuery(PtWidgetRid(wdata->window), &wregion, NULL, NULL, 0); - if (status != 0) { - SDL_SetError - ("Photon: Can't set region sensivity to mouse motion events"); - PtDestroyWidget(wdata->window); - SDL_free(wdata); - return -1; - } - wregion.events_sense |= - Ph_EV_PTR_MOTION_BUTTON | Ph_EV_PTR_MOTION_NOBUTTON; - status = PhRegionChange(Ph_REGION_EV_SENSE, 0, &wregion, NULL, NULL); - if (status < 0) { - SDL_SetError("Photon: Can't change region sensivity"); - PtDestroyWidget(wdata->window); - SDL_free(wdata); - return -1; - } - - /* Flush all widget operations again */ - PtFlush(); - - /* By default last created window got a input focus */ - SDL_SetKeyboardFocus(0, window); - - /* Emit focus gained event, because photon is not sending it */ - SDL_OnWindowFocusGained(window); - - /* Window has been successfully created */ - return 0; -} - -int -photon_createwindowfrom(_THIS, SDL_Window * window, const void *data) -{ - /* TODO: it is possible */ - - /* Failed to create window from another window */ - return -1; -} - -void -photon_setwindowtitle(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - int32_t status; - - /* Set window title */ - if (window->title != NULL) { - status = - PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, window->title, - 0); - } else { - status = PtSetResource(wdata->window, Pt_ARG_WINDOW_TITLE, "", 0); - } - - if (status != 0) { - SDL_SetError("Photon: Can't set window title"); - } - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - int32_t status; - - /* TODO: Use iconify ? */ - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_setwindowposition(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; - PhPoint_t winpos; - int32_t status; - - /* Check if upper level requests WM to position window */ - if ((window->x == SDL_WINDOWPOS_UNDEFINED) - && (window->y == SDL_WINDOWPOS_UNDEFINED)) { - /* Do not set widget position, let WM to set it */ - } else { - if (window->x == SDL_WINDOWPOS_UNDEFINED) { - window->x = 0; - } - if (window->y == SDL_WINDOWPOS_UNDEFINED) { - window->y = 0; - } - if (window->x == SDL_WINDOWPOS_CENTERED) { - window->x = (didata->current_mode.w - window->w) / 2; - } - if (window->y == SDL_WINDOWPOS_CENTERED) { - window->y = (didata->current_mode.h - window->h) / 2; - } - - /* Now set window position */ - winpos.x = window->x; - winpos.y = window->y; - status = PtSetResource(wdata->window, Pt_ARG_POS, &winpos, 0); - if (status != 0) { - SDL_SetError("Photon: Can't set window position"); - } - } - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_setwindowsize(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhDim_t winsize; - int32_t status; - - winsize.w = window->w; - winsize.h = window->h; - - status = PtSetResource(wdata->window, Pt_ARG_DIM, &winsize, 0); - if (status != 0) { - SDL_SetError("Photon: Can't set window size"); - } - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_showwindow(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - int32_t status; - - /* Bring focus to window and put it in front of others */ - PtWindowToFront(wdata->window); - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_hidewindow(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhWindowEvent_t winevent; - int32_t status; - - SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); - winevent.event_f = Ph_WM_HIDE; - winevent.rid = PtWidgetRid(wdata->window); - winevent.event_state = Ph_WM_EVSTATE_HIDE; - - status = PtForwardWindowEvent(&winevent); - if (status != 0) { - SDL_SetError("Photon: Can't hide window"); - } - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_raisewindow(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhWindowEvent_t winevent; - int32_t status; - - SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); - winevent.event_f = Ph_WM_HIDE; - winevent.rid = PtWidgetRid(wdata->window); - winevent.event_state = Ph_WM_EVSTATE_UNHIDE; - - status = PtForwardWindowEvent(&winevent); - if (status != 0) { - SDL_SetError("Photon: Can't hide window"); - } - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_maximizewindow(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhWindowEvent_t winevent; - int32_t status; - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_minimizewindow(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhWindowEvent_t winevent; - int32_t status; - - SDL_memset(&winevent, 0x00, sizeof(PhWindowEvent_t)); - winevent.event_f = Ph_WM_HIDE; - winevent.rid = PtWidgetRid(wdata->window); - winevent.event_state = Ph_WM_EVSTATE_HIDE; - - status = PtForwardWindowEvent(&winevent); - if (status != 0) { - SDL_SetError("Photon: Can't hide window"); - } - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_restorewindow(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhWindowEvent_t winevent; - int32_t status; - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_setwindowgrab(_THIS, SDL_Window * window) -{ - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhWindowEvent_t winevent; - int32_t status; - - /* Flush all widget operations */ - PtFlush(); -} - -void -photon_destroywindow(_THIS, SDL_Window * window) -{ - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - int32_t status; - - if (wdata != NULL) { - status = PtDestroyWidget(wdata->window); - if (status != 0) { - SDL_SetError("Photon: Can't destroy window widget"); - } - wdata->window = NULL; - -#if defined(SDL_VIDEO_OPENGL_ES) - if (phdata->gfinitialized == SDL_TRUE) { - /* Destroy photon handle to GF surface */ - if (wdata->phsurface != NULL) { - PhDCRelease(wdata->phsurface); - wdata->phsurface=NULL; - } - - /* Destroy OpenGL ES surface if it was created */ - if (wdata->gles_surface != EGL_NO_SURFACE) { - eglDestroySurface(phdata->egldisplay, wdata->gles_surface); - } - - /* Free OpenGL ES target surface */ - if (wdata->gfsurface != NULL) { - gf_surface_free(wdata->gfsurface); - wdata->gfsurface=NULL; - } - - phdata->egl_refcount--; - if (phdata->egl_refcount == 0) { - /* Terminate connection to OpenGL ES */ - if (phdata->egldisplay != EGL_NO_DISPLAY) { - eglTerminate(phdata->egldisplay); - phdata->egldisplay = EGL_NO_DISPLAY; - } - } - } -#endif /* SDL_VIDEO_OPENGL_ES */ - } - - /* Flush all widget operations */ - PtFlush(); -} - -/*****************************************************************************/ -/* SDL Window Manager function */ -/*****************************************************************************/ -SDL_bool -photon_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) -{ - if (info->version.major <= SDL_MAJOR_VERSION) { - return SDL_TRUE; - } else { - SDL_SetError("application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); - return SDL_FALSE; - } - - /* Failed to get window manager information */ - return SDL_FALSE; -} - -/*****************************************************************************/ -/* SDL OpenGL/OpenGL ES functions */ -/*****************************************************************************/ -int -photon_gl_loadlibrary(_THIS, const char *path) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - - if (phdata->gfinitialized != SDL_TRUE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return -1; - } - - /* Check if OpenGL ES library is specified for GF driver */ - if (path == NULL) { - path = SDL_getenv("SDL_OPENGL_LIBRARY"); - if (path == NULL) { - path = SDL_getenv("SDL_OPENGLES_LIBRARY"); - } - } - - /* Check if default library loading requested */ - if (path == NULL) { - /* Already linked with GF library which provides egl* subset of */ - /* functions, use Common profile of OpenGL ES library by default */ - path = "/usr/lib/libGLES_CM.so.1"; - } - - /* Load dynamic library */ - _this->gl_config.dll_handle = SDL_LoadObject(path); - if (!_this->gl_config.dll_handle) { - /* Failed to load new GL ES library */ - SDL_SetError("Photon: Failed to locate OpenGL ES library"); - return -1; - } - - /* Store OpenGL ES library path and name */ - SDL_strlcpy(_this->gl_config.driver_path, path, - SDL_arraysize(_this->gl_config.driver_path)); - - /* New OpenGL ES library is loaded */ - return 0; -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -void * -photon_gl_getprocaddres(_THIS, const char *proc) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - void *function_address; - - if (phdata->gfinitialized != SDL_TRUE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return NULL; - } - - /* Try to get function address through the egl interface */ - function_address = eglGetProcAddress(proc); - if (function_address != NULL) { - return function_address; - } - - /* Then try to get function in the OpenGL ES library */ - if (_this->gl_config.dll_handle) { - function_address = - SDL_LoadFunction(_this->gl_config.dll_handle, proc); - if (function_address != NULL) { - return function_address; - } - } - - /* Add emulated OpenGL ES 1.1 functions */ - if (SDL_strcmp(proc, "glTexParameteri") == 0) { - return glTexParameteri; - } - if (SDL_strcmp(proc, "glTexParameteriv") == 0) { - return glTexParameteriv; - } - if (SDL_strcmp(proc, "glColor4ub") == 0) { - return glColor4ub; - } - - /* Failed to get GL ES function address pointer */ - SDL_SetError("Photon: Cannot locate OpenGL ES function name"); - return NULL; -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return NULL; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -void -photon_gl_unloadlibrary(_THIS) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - - if (phdata->gfinitialized == SDL_TRUE) { - /* Unload OpenGL ES library */ - if (_this->gl_config.dll_handle) { - SDL_UnloadObject(_this->gl_config.dll_handle); - _this->gl_config.dll_handle = NULL; - } - } else { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - } -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -SDL_GLContext -photon_gl_createcontext(_THIS, SDL_Window * window) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; - EGLBoolean status; - int32_t gfstatus; - EGLint configs; - uint32_t attr_pos; - EGLint attr_value; - EGLint cit; - - /* Check if GF was initialized */ - if (phdata->gfinitialized != SDL_TRUE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return NULL; - } - - /* Prepare attributes list to pass them to OpenGL ES egl interface */ - attr_pos = 0; - wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; - wdata->gles_attributes[attr_pos++] = - qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); - wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size; - wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size; - wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size; - wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; - - /* Setup alpha size in bits */ - if (_this->gl_config.alpha_size) { - wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size; - } else { - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - /* Setup color buffer size */ - if (_this->gl_config.buffer_size) { - wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size; - } else { - wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - /* Setup depth buffer bits */ - wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; - if (_this->gl_config.depth_size) - { - wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size; - } - else - { - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - /* Setup stencil bits */ - if (_this->gl_config.stencil_size) { - wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.stencil_size; - } else { - wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - /* Set number of samples in multisampling */ - if (_this->gl_config.multisamplesamples) { - wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; - wdata->gles_attributes[attr_pos++] = - _this->gl_config.multisamplesamples; - } - - /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */ - if (_this->gl_config.multisamplebuffers) { - wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; - wdata->gles_attributes[attr_pos++] = - _this->gl_config.multisamplebuffers; - } - - /* Finish attributes list */ - wdata->gles_attributes[attr_pos] = EGL_NONE; - - /* Request first suitable framebuffer configuration */ - status = eglChooseConfig(phdata->egldisplay, wdata->gles_attributes, - wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS, - &configs); - if (status != EGL_TRUE) { - SDL_SetError - ("Photon: Can't find closest configuration for OpenGL ES"); - return NULL; - } - - /* Check if nothing has been found, try "don't care" settings */ - if (configs == 0) { - int32_t it; - int32_t jt; - static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE }; - - for (it = 0; it < 4; it++) { - for (jt = 16; jt >= 0; jt--) { - /* Don't care about color buffer bits, use what exist */ - /* Replace previous set data with EGL_DONT_CARE */ - attr_pos = 0; - wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; - wdata->gles_attributes[attr_pos++] = - qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); - wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - - /* Try to find requested or smallest depth */ - if (_this->gl_config.depth_size) { - wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; - wdata->gles_attributes[attr_pos++] = depthbits[it]; - } else { - wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - if (_this->gl_config.stencil_size) { - wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; - wdata->gles_attributes[attr_pos++] = jt; - } else { - wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos] = EGL_NONE; - - /* Request first suitable framebuffer configuration */ - status = - eglChooseConfig(phdata->egldisplay, - wdata->gles_attributes, - wdata->gles_configs, - SDL_VIDEO_GF_OPENGLES_CONFS, &configs); - if (status != EGL_TRUE) { - SDL_SetError - ("Photon: Can't find closest configuration for OpenGL ES"); - return NULL; - } - if (configs != 0) { - break; - } - } - if (configs != 0) { - break; - } - } - - /* No available configs */ - if (configs == 0) { - SDL_SetError - ("Photon: Can't find any configuration for OpenGL ES"); - return NULL; - } - } - - /* Initialize config index */ - wdata->gles_config = 0; - - /* Now check each configuration to find out the best */ - for (cit = 0; cit < configs; cit++) { - uint32_t stencil_found; - uint32_t depth_found; - EGLint cur_depth; - EGLint cur_stencil; - - stencil_found = 0; - depth_found = 0; - - if (_this->gl_config.stencil_size) { - status = - eglGetConfigAttrib(phdata->egldisplay, - wdata->gles_configs[cit], EGL_STENCIL_SIZE, - &cur_stencil); - if (status == EGL_TRUE) { - if (cur_stencil != 0) { - stencil_found = 1; - } - } - } else { - stencil_found = 1; - } - - if (_this->gl_config.depth_size) { - status = - eglGetConfigAttrib(phdata->egldisplay, - wdata->gles_configs[cit], EGL_DEPTH_SIZE, - &cur_depth); - if (status == EGL_TRUE) { - if (cur_depth != 0) { - depth_found = 1; - } - } - } else { - depth_found = 1; - } - - /* Exit from loop if found appropriate configuration */ - if ((depth_found != 0) && (stencil_found != 0)) { - /* Store last satisfied configuration id */ - wdata->gles_config = cit; - - if (cur_depth==_this->gl_config.depth_size) - { - /* Exact match on depth bits */ - if (!_this->gl_config.stencil_size) - { - /* Stencil is not required */ - break; - } - else - { - if (cur_stencil==_this->gl_config.stencil_size) - { - /* Exact match on stencil bits */ - break; - } - } - } - } - } - - /* If best could not be found, use first or last satisfied */ - if ((cit == configs) && (wdata->gles_config==0)) { - cit = 0; - wdata->gles_config = cit; - } - - /* Create OpenGL ES context */ - wdata->gles_context = - eglCreateContext(phdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_NO_CONTEXT, NULL); - if (wdata->gles_context == EGL_NO_CONTEXT) { - SDL_SetError("Photon: OpenGL ES context creation has been failed"); - return NULL; - } - - /* Check if surface is exist */ - if (wdata->gfsurface != NULL) { - gf_surface_free(wdata->gfsurface); - wdata->gfsurface = NULL; - } - - /* Create GF surface */ - gfstatus = - gf_surface_create(&wdata->gfsurface, phdata->gfdev, window->w, - window->h, - qnxgf_sdl_to_gf_pixelformat(didata->current_mode. - format), NULL, - GF_SURFACE_CREATE_2D_ACCESSIBLE | - GF_SURFACE_CREATE_3D_ACCESSIBLE | - GF_SURFACE_CREATE_SHAREABLE); - if (gfstatus != GF_ERR_OK) { - eglDestroyContext(phdata->egldisplay, wdata->gles_context); - wdata->gles_context = EGL_NO_CONTEXT; - SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus); - return NULL; - } - - /* Create pixmap 3D target surface */ - wdata->gles_surface = - eglCreatePixmapSurface(phdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - wdata->gfsurface, NULL); - if (wdata->gles_surface == EGL_NO_SURFACE) { - gf_surface_free(wdata->gfsurface); - wdata->gfsurface=NULL; - eglDestroyContext(phdata->egldisplay, wdata->gles_context); - wdata->gles_context = EGL_NO_CONTEXT; - SDL_SetError("Photon: Can't create EGL pixmap surface"); - return NULL; - } - - /* Store last used context and surface */ - phdata->lgles_surface=wdata->gles_surface; - phdata->lgles_context=wdata->gles_context; - - /* Make just created context current */ - status = - eglMakeCurrent(phdata->egldisplay, wdata->gles_surface, - wdata->gles_surface, wdata->gles_context); - if (status != EGL_TRUE) { - /* Reset last used context and surface */ - phdata->lgles_surface=EGL_NO_SURFACE; - phdata->lgles_context=EGL_NO_CONTEXT; - - /* Destroy OpenGL ES surface */ - eglDestroySurface(phdata->egldisplay, wdata->gles_surface); - wdata->gles_surface=EGL_NO_SURFACE; - gf_surface_free(wdata->gfsurface); - wdata->gfsurface=NULL; - eglDestroyContext(phdata->egldisplay, wdata->gles_context); - wdata->gles_context = EGL_NO_CONTEXT; - SDL_SetError("Photon: Can't set OpenGL ES context on creation"); - return NULL; - } - - /* Setup into SDL internals state of OpenGL ES: */ - /* it is accelerated or not */ - if ((didata->caps & SDL_PHOTON_ACCELERATED_3D) == - SDL_PHOTON_ACCELERATED_3D) { - _this->gl_config.accelerated = 1; - } else { - _this->gl_config.accelerated = 0; - } - - /* Always clear stereo enable, since OpenGL ES do not supports stereo */ - _this->gl_config.stereo = 0; - - /* Get back samples and samplebuffers configurations. Rest framebuffer */ - /* parameters could be obtained through the OpenGL ES API */ - status = - eglGetConfigAttrib(phdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_SAMPLES, &attr_value); - if (status == EGL_TRUE) { - _this->gl_config.multisamplesamples = attr_value; - } - status = - eglGetConfigAttrib(phdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_SAMPLE_BUFFERS, &attr_value); - if (status == EGL_TRUE) { - _this->gl_config.multisamplebuffers = attr_value; - } - - /* Get back stencil and depth buffer sizes */ - status = - eglGetConfigAttrib(phdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_DEPTH_SIZE, &attr_value); - if (status == EGL_TRUE) { - _this->gl_config.depth_size = attr_value; - } - status = - eglGetConfigAttrib(phdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_STENCIL_SIZE, &attr_value); - if (status == EGL_TRUE) { - _this->gl_config.stencil_size = attr_value; - } - - /* Under Photon OpenGL ES output can't be double buffered */ - _this->gl_config.double_buffer = 0; - - /* Check if current device is not the same as target */ - if (phdata->current_device_id != didata->device_id) { - /* Set target device as default for Pd and Pg functions */ - status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); - if (status != 0) { - /* Destroy OpenGL ES surface */ - eglDestroySurface(phdata->egldisplay, wdata->gles_surface); - wdata->gles_surface=EGL_NO_SURFACE; - gf_surface_free(wdata->gfsurface); - wdata->gfsurface=NULL; - eglDestroyContext(phdata->egldisplay, wdata->gles_context); - wdata->gles_context = EGL_NO_CONTEXT; - SDL_SetError("Photon: Can't set default target device\n"); - return NULL; - } - phdata->current_device_id = didata->device_id; - } - - wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface); - if (wdata->phsurface == NULL) { - /* Destroy OpenGL ES surface */ - eglDestroySurface(phdata->egldisplay, wdata->gles_surface); - wdata->gles_surface=EGL_NO_SURFACE; - gf_surface_free(wdata->gfsurface); - wdata->gfsurface=NULL; - eglDestroyContext(phdata->egldisplay, wdata->gles_context); - wdata->gles_context = EGL_NO_CONTEXT; - SDL_SetError("Photon: Can't bind GF surface to Photon\n"); - return NULL; - } - - /* GL ES context was successfully created */ - return wdata->gles_context; -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return NULL; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -int -photon_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_WindowData *wdata; - EGLBoolean status; - - if (phdata->gfinitialized != SDL_TRUE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return -1; - } - - if ((window == NULL) && (context == NULL)) { - /* Reset last used context and surface */ - phdata->lgles_surface=EGL_NO_SURFACE; - phdata->lgles_context=EGL_NO_CONTEXT; - - /* Unset current context */ - status = - eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT); - if (status != EGL_TRUE) { - /* Failed to set current GL ES context */ - SDL_SetError("Photon: Can't empty current OpenGL ES context"); - return -1; - } - } else { - wdata = (SDL_WindowData *) window->driverdata; - if (wdata->gles_surface == EGL_NO_SURFACE) { - SDL_SetError - ("Photon: OpenGL ES surface is not initialized for this window"); - return -1; - } - if (wdata->gles_context == EGL_NO_CONTEXT) { - SDL_SetError - ("Photon: OpenGL ES context is not initialized for this window"); - return -1; - } - if (wdata->gles_context != context) { - SDL_SetError - ("Photon: OpenGL ES context is not belong to this window"); - return -1; - } - - /* Store last set surface and context */ - phdata->lgles_surface=wdata->gles_surface; - phdata->lgles_context=wdata->gles_context; - - /* Set new current context */ - status = - eglMakeCurrent(phdata->egldisplay, wdata->gles_surface, - wdata->gles_surface, wdata->gles_context); - if (status != EGL_TRUE) { - /* Reset last used context and surface */ - phdata->lgles_surface=EGL_NO_SURFACE; - phdata->lgles_context=EGL_NO_CONTEXT; - /* Failed to set current GL ES context */ - SDL_SetError("Photon: Can't set OpenGL ES context"); - return -1; - } - } - - return 0; -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -int -photon_gl_setswapinterval(_THIS, int interval) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - EGLBoolean status; - - if (phdata->gfinitialized != SDL_TRUE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return -1; - } - - /* Check if OpenGL ES connection has been initialized */ - if (phdata->egldisplay != EGL_NO_DISPLAY) { - /* Set swap OpenGL ES interval */ - status = eglSwapInterval(phdata->egldisplay, interval); - if (status == EGL_TRUE) { - /* Return success to upper level */ - phdata->swapinterval = interval; - return 0; - } - } - - /* Failed to set swap interval */ - SDL_SetError("Photon: Cannot set swap interval"); - return -1; -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -int -photon_gl_getswapinterval(_THIS) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - - if (phdata->gfinitialized != SDL_TRUE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return -1; - } - - /* Return default swap interval value */ - return phdata->swapinterval; -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -void -photon_gl_swapwindow(_THIS, SDL_Window * window) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; - PhRect_t dst_rect; - PhRect_t src_rect; - int32_t status; - - if (phdata->gfinitialized != SDL_TRUE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return; - } - - if (wdata->phsurface==NULL) { - SDL_SetError - ("Photon: Photon OpenGL ES surface is not initialized"); - return; - } - - /* Many applications do not uses glFinish(), so we call it for them */ - glFinish(); - - /* Wait until OpenGL ES rendering is completed */ - eglWaitGL(); - - /* Wait for VSYNC manually, if it was enabled */ - if (phdata->swapinterval != 0) { - /* Wait for VSYNC, we use GF function, since Photon requires */ - /* to enter to the Direct mode to call PgWaitVSync() */ - gf_display_wait_vsync(didata->display); - } - - /* Set blit area */ - dst_rect = *PtGetCanvas(wdata->window); - src_rect.ul.x = 0; - src_rect.ul.y = 0; - src_rect.lr.x = window->w - 1; - src_rect.lr.y = window->h - 1; - - /* Check if current device is not the same as target */ - if (phdata->current_device_id != didata->device_id) { - /* Set target device as default for Pd and Pg functions */ - status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); - if (status != 0) { - SDL_SetError("Photon: Can't set default target device\n"); - return; - } - phdata->current_device_id = didata->device_id; - } - - /* Blit OpenGL ES pixmap surface directly to window region */ - PgFFlush(Ph_START_DRAW); - PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); - PgClearTranslationCx(PgGetGCCx(PhDCGetCurrent())); - PgContextBlit(wdata->phsurface, &src_rect, NULL, &dst_rect); - PgFFlush(Ph_DONE_DRAW); - PgWaitHWIdle(); - - eglSwapBuffers(phdata->egldisplay, wdata->gles_surface); -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -void -photon_gl_deletecontext(_THIS, SDL_GLContext context) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - EGLBoolean status; - - if (phdata->gfinitialized != SDL_TRUE) { - SDL_SetError - ("Photon: GF initialization failed, no OpenGL ES support"); - return; - } - - /* Check if OpenGL ES connection has been initialized */ - if (phdata->egldisplay != EGL_NO_DISPLAY) { - if (context != EGL_NO_CONTEXT) { - /* Check if we are destroying current active context */ - if (phdata->lgles_context==context) { - /* Release current context */ - eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - phdata->lgles_context=EGL_NO_CONTEXT; - phdata->lgles_surface=EGL_NO_SURFACE; - } - status = eglDestroyContext(phdata->egldisplay, context); - if (status != EGL_TRUE) { - /* Error during OpenGL ES context destroying */ - SDL_SetError("Photon: OpenGL ES context destroy error"); - return; - } - } - } - - return; -#else - SDL_SetError("Photon: OpenGL ES support is not compiled in"); - return; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -/* Helper function, which re-creates surface, not an API */ -int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32_t height) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; - SDL_bool makecurrent=SDL_FALSE; - int32_t gfstatus; - - /* Check if context has been initialized */ - if (wdata->gles_context == EGL_NO_CONTEXT) { - /* If no, abort surface re-creating */ - return -1; - } - - /* Check if last used surface the same as one which must be re-created */ - if (phdata->lgles_surface == wdata->gles_surface) { - makecurrent=SDL_TRUE; - /* Flush all current drawings */ - glFinish(); - /* Wait until OpenGL ES rendering is completed */ - eglWaitGL(); - /* Release current context */ - eglMakeCurrent(phdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); - phdata->lgles_surface=EGL_NO_SURFACE; - } - - /* Check if we need to destroy previous surface */ - if (wdata->gles_surface != EGL_NO_SURFACE) { - /* Destroy photon handle to GF surface */ - if (wdata->phsurface != NULL) { - PhDCRelease(wdata->phsurface); - wdata->phsurface=NULL; - } - - /* Destroy previous surface */ - eglDestroySurface(phdata->egldisplay, wdata->gles_surface); - - /* Set surface to uninitialized */ - wdata->gles_surface = EGL_NO_SURFACE; - - if (wdata->gfsurface!=NULL) { - gf_surface_free(wdata->gfsurface); - wdata->gfsurface=NULL; - } - } - - /* Create new GF surface */ - gfstatus = - gf_surface_create(&wdata->gfsurface, phdata->gfdev, width, - height, - qnxgf_sdl_to_gf_pixelformat(didata->current_mode. - format), NULL, - GF_SURFACE_CREATE_2D_ACCESSIBLE | - GF_SURFACE_CREATE_3D_ACCESSIBLE | - GF_SURFACE_CREATE_SHAREABLE); - if (gfstatus != GF_ERR_OK) { - SDL_SetError("Photon: Can't create GF 3D surface (%08X)", gfstatus); - return -1; - } - - /* Create new pixmap 3D target surface */ - wdata->gles_surface = - eglCreatePixmapSurface(phdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - wdata->gfsurface, NULL); - if (wdata->gles_surface == EGL_NO_SURFACE) { - gf_surface_free(wdata->gfsurface); - wdata->gfsurface=NULL; - SDL_SetError("Photon: Can't create EGL pixmap surface"); - return -1; - } - - wdata->phsurface = PdCreateOffscreenContextGF(wdata->gfsurface); - if (wdata->phsurface == NULL) { - /* Destroy OpenGL ES surface */ - eglDestroySurface(phdata->egldisplay, wdata->gles_surface); - wdata->gles_surface=EGL_NO_SURFACE; - gf_surface_free(wdata->gfsurface); - wdata->gfsurface=NULL; - SDL_SetError("Photon: Can't bind GF surface to Photon\n"); - return -1; - } - - /* Check if we need to set this surface and context as current */ - if (makecurrent == SDL_TRUE) { - return photon_gl_makecurrent(_this, window, wdata->gles_context); - } else { - return 0; - } -#else - /* Do nothing, if OpenGL ES support is not compiled in */ - return 0; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -/*****************************************************************************/ -/* SDL Event handling function */ -/*****************************************************************************/ -void -photon_pumpevents(_THIS) -{ - uint8_t eventbuffer[SDL_VIDEO_PHOTON_EVENT_SIZE]; - PhEvent_t *event = (PhEvent_t *) eventbuffer; - int32_t status; - uint32_t finish = 0; - SDL_Window *window; - SDL_WindowData *wdata; - - do { - status = PhEventPeek(event, SDL_VIDEO_PHOTON_EVENT_SIZE); - switch (status) { - case Ph_RESIZE_MSG: - { - SDL_SetError("Photon: Event size too much for buffer"); - return; - } - break; - case Ph_EVENT_MSG: - { - /* Find a window, to which this handle destinated */ - status = 0; - for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) { - SDL_VideoDisplay *display = SDL_GetVideoDisplay(i); - for (j = 0; j < display->num_windows; ++j) { - wdata = (SDL_WindowData *) display->windows[j].driverdata; - - /* Find the proper window */ - if (wdata->window != NULL) { - if (PtWidgetRid(wdata->window) == - event->collector.rid) { - window = (SDL_Window *) &display->windows[it]; - status = 1; - break; - } - } else { - continue; - } - } - } - if (status == 0) { - window = NULL; - wdata = NULL; - } - - /* Event is ready */ - switch (event->type) { - case Ph_EV_BOUNDARY: - { - switch (event->subtype) { - case Ph_EV_PTR_ENTER: - { - /* Mouse cursor over handled window */ - if (window != NULL) { - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_ENTER, - 0, 0); - SDL_SetMouseFocus(0, window); - } - } - break; - case Ph_EV_PTR_LEAVE: - { - /* Mouse cursor out of handled window */ - if (window != NULL) { - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_LEAVE, - 0, 0); - } - } - break; - } - } - break; - case Ph_EV_PTR_MOTION_BUTTON: - case Ph_EV_PTR_MOTION_NOBUTTON: - { - PhPointerEvent_t *pevent = NULL; - PhRect_t *prects = NULL; - - /* Get event data */ - pevent = PhGetData(event); - /* Get associated event rectangles */ - prects = PhGetRects(event); - if ((pevent != NULL) && (prects != NULL)) { - SDL_SendMouseMotion(0, 0, prects->ul.x, - prects->ul.y, 0); - } - } - break; - case Ph_EV_BUT_PRESS: - { - /* Button press event */ - PhPointerEvent_t *pevent = NULL; - uint32_t sdlbutton = 0x00000000; - - /* Get event data */ - pevent = PhGetData(event); - if (pevent != NULL) { - for (it = 0; it < sizeof(pevent->buttons) * 8; - it++) { - if ((pevent->buttons & (0x0001 << it)) == - (0x0001 << it)) { - switch (it) { - case 0: - { - sdlbutton = SDL_BUTTON_RIGHT; - } - break; - case 1: - { - sdlbutton = SDL_BUTTON_MIDDLE; - } - break; - case 2: - { - sdlbutton = SDL_BUTTON_LEFT; - } - break; - default: - { - sdlbutton = it + 1; - } - break; - } - SDL_SendMouseButton(0, SDL_PRESSED, - sdlbutton); - } - } - } - } - break; - case Ph_EV_BUT_RELEASE: - { - /* Button press event */ - PhPointerEvent_t *pevent = NULL; - uint32_t sdlbutton = 0x00000000; - - /* Get event data */ - pevent = PhGetData(event); - if (pevent != NULL) { - for (it = 0; it < sizeof(pevent->buttons) * 8; - it++) { - if ((pevent->buttons & (0x0001 << it)) == - (0x0001 << it)) { - switch (it) { - case 0: - { - sdlbutton = SDL_BUTTON_RIGHT; - } - break; - case 1: - { - sdlbutton = SDL_BUTTON_MIDDLE; - } - break; - case 2: - { - sdlbutton = SDL_BUTTON_LEFT; - } - break; - default: - { - sdlbutton = it + 1; - } - break; - } - } - } - } - - switch (event->subtype) { - case Ph_EV_RELEASE_REAL: - { - /* Real release button event */ - SDL_SendMouseButton(0, SDL_RELEASED, - sdlbutton); - } - break; - case Ph_EV_RELEASE_PHANTOM: - { - /* We will get phantom button release */ - /* event in case if it was unpressed */ - /* outside of window */ - if (window != NULL) { - if ((window-> - flags & SDL_WINDOW_MOUSE_FOCUS) != - SDL_WINDOW_MOUSE_FOCUS) { - /* Send phantom button release */ - SDL_SendMouseButton(0, SDL_RELEASED, - sdlbutton); - } - } - } - break; - } - } - break; - case Ph_EV_EXPOSE: - { - switch (event->subtype) { - case Ph_NORMAL_EXPOSE: - { - PhRect_t *rects = NULL; - - /* Get array of rectangles to be updated */ - rects = PhGetRects(event); - if (rects == NULL) { - break; - } - - /* Check if expose come to one of the our windows */ - if ((wdata != NULL) && (window != NULL)) { - /* Check if window uses OpenGL ES */ - if (wdata->uses_gles == SDL_TRUE) { - #if defined(SDL_VIDEO_OPENGL_ES) - /* Cycle through each rectangle */ - for (it = 0; it < event->num_rects; it++) { - /* Blit OpenGL ES pixmap surface directly to window region */ - PgFFlush(Ph_START_DRAW); - PgSetRegionCx(PhDCGetCurrent(), - PtWidgetRid(wdata-> - window)); - PgClearTranslationCx(PgGetGCCx - (PhDCGetCurrent - ())); - PgContextBlit(wdata->phsurface, - &rects[it], NULL, - &rects[it]); - PgFFlush(Ph_DONE_DRAW); - PgWaitHWIdle(); - } - #endif /* SDL_VIDEO_OPENGL_ES */ - } else { - /* Cycle through each rectangle */ - for (it = 0; it < event->num_rects; - it++) { - /* Blit 2D pixmap surface directly to window region */ - _photon_update_rectangles(window->renderer, &rects[it]); - } - PgFlush(); - PgWaitHWIdle(); - } - } - - /* Flush all blittings */ - PgFlush(); - } - break; - case Ph_CAPTURE_EXPOSE: - { - /* Check if expose come to one of the our windows */ - if ((wdata != NULL) && (window != NULL)) { - /* Check if window uses OpenGL ES */ - if (wdata->uses_gles == SDL_TRUE) { - PhRect_t dst_rect; - PhRect_t src_rect; - - /* Set blit area */ - dst_rect = - *PtGetCanvas(wdata->window); - src_rect.ul.x = 0; - src_rect.ul.y = 0; - src_rect.lr.x = window->w - 1; - src_rect.lr.y = window->h - 1; - - #if defined(SDL_VIDEO_OPENGL_ES) - /* We need to redraw entire window */ - PgFFlush(Ph_START_DRAW); - PgSetRegionCx(PhDCGetCurrent(), - PtWidgetRid(wdata-> - window)); - PgClearTranslationCx(PgGetGCCx - (PhDCGetCurrent - ())); - PgContextBlit(wdata->phsurface, - &src_rect, NULL, - &dst_rect); - PgFFlush(Ph_DONE_DRAW); - PgWaitHWIdle(); - #endif /* SDL_VIDEO_OPENGL_ES */ - } else { - PhRect_t rect; - - /* We need to redraw entire window */ - rect.ul.x = 0; - rect.ul.y = 0; - rect.lr.x = window->w - 1; - rect.lr.y = window->h - 1; - - /* Blit 2D pixmap surface directly to window region */ - PgFFlush(Ph_START_DRAW); - _photon_update_rectangles(window->renderer, &rect); - PgFFlush(Ph_DONE_DRAW); - PgWaitHWIdle(); - } - } - } - break; - case Ph_GRAPHIC_EXPOSE: - { - /* TODO: What this event means ? */ - } - break; - } - } - break; - case Ph_EV_INFO: - { - switch (event->subtype) - { - case Ph_OFFSCREEN_INVALID: - { - uint32_t* type; - - type = PhGetData(event); - switch (*type) - { - case Pg_VIDEO_MODE_SWITCHED: - case Pg_ENTERED_DIRECT: - case Pg_EXITED_DIRECT: - case Pg_DRIVER_STARTED: - { - /* TODO: */ - /* We must tell the renderer, that it have */ - /* to recreate all surfaces */ - } - break; - default: - { - } - break; - } - } - break; - default: - break; - } - } - break; - case Ph_EV_KEY: - { - PhKeyEvent_t *keyevent = NULL; - SDL_scancode scancode = SDL_SCANCODE_UNKNOWN; - SDL_bool pressed = SDL_FALSE; - - keyevent = PhGetData(event); - if (keyevent == NULL) { - break; - } - - /* Check if key is repeated */ - if ((keyevent->key_flags & Pk_KF_Key_Repeat) == - Pk_KF_Key_Repeat) { - /* Ignore such events */ - break; - } - - /* Check if key has its own scancode */ - if ((keyevent->key_flags & Pk_KF_Scan_Valid) == - Pk_KF_Scan_Valid) { - if ((keyevent->key_flags & Pk_KF_Key_Down) == - Pk_KF_Key_Down) { - pressed = SDL_TRUE; - } else { - pressed = SDL_FALSE; - } - scancode = - photon_to_sdl_keymap(keyevent->key_scan); - - /* Add details for the pressed key */ - if ((keyevent->key_flags & Pk_KF_Cap_Valid) == - Pk_KF_Cap_Valid) { - switch (keyevent->key_cap) { - case Pk_Hyper_R: /* Right windows flag key */ - scancode = SDL_SCANCODE_RGUI; - break; - case Pk_Control_R: /* Right Ctrl key */ - scancode = SDL_SCANCODE_RCTRL; - break; - case Pk_Alt_R: /* Right Alt key */ - scancode = SDL_SCANCODE_RALT; - break; - case Pk_Up: /* Up key but with invalid scan */ - if (scancode != SDL_SCANCODE_UP) { - /* This is a mouse wheel event */ - SDL_SendMouseWheel(0, 0, 1); - return; - } - break; - case Pk_KP_8: /* Up arrow or 8 on keypad */ - scancode = SDL_SCANCODE_KP_8; - break; - case Pk_Down: /* Down key but with invalid scan */ - if (scancode != SDL_SCANCODE_DOWN) { - /* This is a mouse wheel event */ - SDL_SendMouseWheel(0, 0, -1); - return; - } - break; - case Pk_KP_2: /* Down arrow or 2 on keypad */ - scancode = SDL_SCANCODE_KP_2; - break; - case Pk_Left: /* Left arrow key */ - scancode = SDL_SCANCODE_LEFT; - break; - case Pk_KP_4: /* Left arrow or 4 on keypad */ - scancode = SDL_SCANCODE_KP_4; - break; - case Pk_Right: /* Right arrow key */ - scancode = SDL_SCANCODE_RIGHT; - break; - case Pk_KP_6: /* Right arrow or 6 on keypad */ - scancode = SDL_SCANCODE_KP_6; - break; - case Pk_Insert: /* Insert key */ - scancode = SDL_SCANCODE_INSERT; - break; - case Pk_KP_0: /* Insert or 0 on keypad */ - scancode = SDL_SCANCODE_KP_0; - break; - case Pk_Home: /* Home key */ - scancode = SDL_SCANCODE_HOME; - break; - case Pk_KP_7: /* Home or 7 on keypad */ - scancode = SDL_SCANCODE_KP_7; - break; - case Pk_Pg_Up: /* PageUp key */ - scancode = SDL_SCANCODE_PAGEUP; - break; - case Pk_KP_9: /* PgUp or 9 on keypad */ - scancode = SDL_SCANCODE_KP_9; - break; - case Pk_Delete: /* Delete key */ - scancode = SDL_SCANCODE_DELETE; - break; - case Pk_KP_Decimal: /* Del or . on keypad */ - scancode = SDL_SCANCODE_KP_PERIOD; - break; - case Pk_End: /* End key */ - scancode = SDL_SCANCODE_END; - break; - case Pk_KP_1: /* End or 1 on keypad */ - scancode = SDL_SCANCODE_KP_1; - break; - case Pk_Pg_Down: /* PageDown key */ - scancode = SDL_SCANCODE_PAGEDOWN; - break; - case Pk_KP_3: /* PgDn or 3 on keypad */ - scancode = SDL_SCANCODE_KP_3; - break; - case Pk_KP_5: /* 5 on keypad */ - scancode = SDL_SCANCODE_KP_5; - break; - case Pk_KP_Enter: - scancode = SDL_SCANCODE_KP_ENTER; - break; - case Pk_KP_Add: - scancode = SDL_SCANCODE_KP_PLUS; - break; - case Pk_KP_Subtract: - scancode = SDL_SCANCODE_KP_MINUS; - break; - case Pk_KP_Multiply: - scancode = SDL_SCANCODE_KP_MULTIPLY; - break; - case Pk_KP_Divide: - scancode = SDL_SCANCODE_KP_DIVIDE; - break; - case Pk_Pause: - scancode = SDL_SCANCODE_PAUSE; - break; - } - } - - /* Finally check if scancode has been decoded */ - if (scancode == SDL_SCANCODE_UNKNOWN) { - /* Something was pressed, which is not supported */ - break; - } - - /* Report pressed/released key to SDL */ - if (pressed == SDL_TRUE) { - SDL_SendKeyboardKey(0, SDL_PRESSED, scancode); - } else { - SDL_SendKeyboardKey(0, SDL_RELEASED, - scancode); - } - - /* Photon doesn't send a release event for PrnScr key */ - if ((scancode == SDL_SCANCODE_PRINTSCREEN) - && (pressed)) { - SDL_SendKeyboardKey(0, SDL_RELEASED, - scancode); - } - - } - - /* Handle UTF-8 text input if requested by caller */ - if (SDL_EventState(SDL_TEXTINPUT, SDL_QUERY)) - { - char text[5]; - - SDL_memset(text, 0x00, 5); - if (PhKeyToMb(text, keyevent)!=-1) - { - SDL_SendKeyboardText(0, text); - } - else - { - /* Just do nothing if it is not a UTF-8 character */ - } - } - } - break; - case Ph_EV_SERVICE: - { - } - break; - case Ph_EV_SYSTEM: - { - } - break; - case Ph_EV_WM: - { - PhWindowEvent_t *wmevent = NULL; - - /* Get associated event data */ - wmevent = PhGetData(event); - if (wmevent == NULL) { - break; - } - - switch (wmevent->event_f) { - case Ph_WM_CLOSE: - { - if (window != NULL) { - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_CLOSE, - 0, 0); - } - } - break; - case Ph_WM_FOCUS: - { - if (wmevent->event_state == - Ph_WM_EVSTATE_FOCUS) { - if (window != NULL) { - PhRegion_t wregion; - - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_FOCUS_GAINED, - 0, 0); - SDL_SetKeyboardFocus(0, window); - - /* Set window region sensible to mouse motion events */ - PhRegionQuery(PtWidgetRid - (wdata->window), - &wregion, NULL, NULL, - 0); - wregion.events_sense |= - Ph_EV_PTR_MOTION_BUTTON | - Ph_EV_PTR_MOTION_NOBUTTON; - PhRegionChange(Ph_REGION_EV_SENSE, 0, - &wregion, NULL, NULL); - - /* If window got a focus, then it is visible */ - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_SHOWN, - 0, 0); - } - } - if (wmevent->event_state == - Ph_WM_EVSTATE_FOCUSLOST) { - if (window != NULL) { - PhRegion_t wregion; - - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_FOCUS_LOST, - 0, 0); - - /* Set window region ignore mouse motion events */ - PhRegionQuery(PtWidgetRid - (wdata->window), - &wregion, NULL, NULL, - 0); - wregion.events_sense &= - ~(Ph_EV_PTR_MOTION_BUTTON | - Ph_EV_PTR_MOTION_NOBUTTON); - PhRegionChange(Ph_REGION_EV_SENSE, 0, - &wregion, NULL, NULL); - } - } - } - break; - case Ph_WM_MOVE: - { - if (window != NULL) { - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_MOVED, - wmevent->pos.x, - wmevent->pos.y); - } - } - break; - case Ph_WM_RESIZE: - { - if (window != NULL) { - /* Set new window position after resize */ - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_MOVED, - wmevent->pos.x, - wmevent->pos.y); - - /* Check if this window uses OpenGL ES */ - if (wdata->uses_gles == SDL_TRUE) { - /* If so, recreate surface with new dimensions */ - photon_gl_recreatesurface(_this, window, wmevent->size.w, wmevent->size.h); - } - - /* Set new window size after resize */ - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_RESIZED, - wmevent->size.w, - wmevent->size.h); - } - } - break; - case Ph_WM_HIDE: - { - if (window != NULL) { - /* Send new window state: minimized */ - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_MINIMIZED, - 0, 0); - /* In case window is minimized, then it is hidden */ - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_HIDDEN, - 0, 0); - } - } - break; - case Ph_WM_MAX: - { - if (window != NULL) { - if ((window->flags & SDL_WINDOW_RESIZABLE)==SDL_WINDOW_RESIZABLE) - { - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_MAXIMIZED, - 0, 0); - } - else - { - /* otherwise ignor the resize events */ - } - } - } - break; - case Ph_WM_RESTORE: - { - if (window != NULL) { - SDL_SendWindowEvent(window, - SDL_WINDOWEVENT_RESTORED, - 0, 0); - } - } - break; - } - } - break; - } - PtEventHandler(event); - } - break; - case 0: - { - /* All events are read */ - finish = 1; - break; - } - case -1: - { - /* Error occured in event reading */ - SDL_SetError("Photon: Can't read event"); - return; - } - break; - } - if (finish != 0) { - break; - } - } while (1); -} - -/*****************************************************************************/ -/* SDL screen saver related functions */ -/*****************************************************************************/ -void -photon_suspendscreensaver(_THIS) -{ - /* There is no screensaver in pure console, it may exist when running */ - /* GF under Photon, but I do not know, how to disable screensaver */ -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon.h b/project/jni/sdl-1.3/src/video/photon/SDL_photon.h deleted file mode 100644 index 4ce555f19..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon.h +++ /dev/null @@ -1,180 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_PHOTON_H__ -#define __SDL_PHOTON_H__ - -/* GF headers must be included first for the Photon GF functions */ -#if defined(SDL_VIDEO_OPENGL_ES) -#include -#include -#endif /* SDL_VIDEO_OPENGL_ES */ - -#include "SDL_config.h" -#include "../SDL_sysvideo.h" - -#include -#include -#include - -/* Maximum display devices, which can handle SDL Photon driver */ -#define SDL_VIDEO_PHOTON_MAX_RIDS 16 - -typedef struct SDL_VideoData -{ - PhRid_t rid[SDL_VIDEO_PHOTON_MAX_RIDS]; - uint32_t avail_rids; - uint32_t current_device_id; -#if defined(SDL_VIDEO_OPENGL_ES) - gf_dev_t gfdev; /* GF device handle */ - gf_dev_info_t gfdev_info; /* GF device information */ - SDL_bool gfinitialized; /* GF device initialization status */ - EGLDisplay egldisplay; /* OpenGL ES display connection */ - uint32_t egl_refcount; /* OpenGL ES reference count */ - uint32_t swapinterval; /* OpenGL ES default swap interval */ - EGLContext lgles_context; /* Last used OpenGL ES context */ - EGLSurface lgles_surface; /* Last used OpenGL ES target surface */ -#endif /* SDL_VIDEO_OPENGL_ES */ -} SDL_VideoData; - -/* This is hardcoded value in photon/Pg.h */ -#define SDL_VIDEO_PHOTON_DEVICENAME_MAX 41 -#define SDL_VIDEO_PHOTON_MAX_CURSOR_SIZE 128 - -/* Maximum event message size with data payload */ -#define SDL_VIDEO_PHOTON_EVENT_SIZE 8192 - -/* Current video mode graphics capabilities */ -#define SDL_VIDEO_PHOTON_CAP_ALPHA_BLEND 0x00000001 -#define SDL_VIDEO_PHOTON_CAP_SCALED_BLIT 0x00000002 - -typedef struct SDL_DisplayData -{ - uint32_t device_id; - uint32_t custom_refresh; /* Custom refresh rate for all modes */ - SDL_DisplayMode current_mode; /* Current video mode */ - uint8_t description[SDL_VIDEO_PHOTON_DEVICENAME_MAX]; - /* Device description */ - uint32_t caps; /* Device capabilities */ - PhCursorDef_t *cursor; /* Global cursor settings */ - SDL_bool cursor_visible; /* SDL_TRUE if cursor visible */ - uint32_t cursor_size; /* Cursor size in memory w/ structure */ - uint32_t mode_2dcaps; /* Current video mode 2D capabilities */ - SDL_bool direct_mode; /* Direct mode state */ -#if defined(SDL_VIDEO_OPENGL_ES) - gf_display_t display; /* GF display handle */ - gf_display_info_t display_info; /* GF display information */ -#endif /* SDL_VIDEO_OPENGL_ES */ -} SDL_DisplayData; - -/* Maximum amount of OpenGL ES framebuffer configurations */ -#define SDL_VIDEO_GF_OPENGLES_CONFS 32 - -typedef struct SDL_WindowData -{ - SDL_bool uses_gles; /* if true window must support OpenGL ES */ - PtWidget_t *window; /* window handle */ -#if defined(SDL_VIDEO_OPENGL_ES) - EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS]; - /* OpenGL ES framebuffer confs */ - EGLint gles_config; /* OpenGL ES configuration index */ - EGLContext gles_context; /* OpenGL ES context */ - EGLint gles_attributes[256]; /* OpenGL ES attributes for context */ - EGLSurface gles_surface; /* OpenGL ES target rendering surface */ - gf_surface_t gfsurface; /* OpenGL ES GF's surface */ - PdOffscreenContext_t *phsurface; /* OpenGL ES Photon's surface */ -#endif /* SDL_VIDEO_OPENGL_ES */ -} SDL_WindowData; - -/****************************************************************************/ -/* Low level Photon graphics driver capabilities */ -/****************************************************************************/ -typedef struct Photon_DeviceCaps -{ - uint8_t *name; - uint32_t caps; -} Photon_DeviceCaps; - -#define SDL_PHOTON_UNACCELERATED 0x00000000 -#define SDL_PHOTON_ACCELERATED 0x00000001 -#define SDL_PHOTON_UNACCELERATED_3D 0x00000000 -#define SDL_PHOTON_ACCELERATED_3D 0x00000004 - -/****************************************************************************/ -/* SDL_VideoDevice functions declaration */ -/****************************************************************************/ - -/* Display and window functions */ -int photon_videoinit(_THIS); -void photon_videoquit(_THIS); -void photon_getdisplaymodes(_THIS); -int photon_setdisplaymode(_THIS, SDL_DisplayMode * mode); -int photon_setdisplaypalette(_THIS, SDL_Palette * palette); -int photon_getdisplaypalette(_THIS, SDL_Palette * palette); -int photon_setdisplaygammaramp(_THIS, Uint16 * ramp); -int photon_getdisplaygammaramp(_THIS, Uint16 * ramp); -int photon_createwindow(_THIS, SDL_Window * window); -int photon_createwindowfrom(_THIS, SDL_Window * window, const void *data); -void photon_setwindowtitle(_THIS, SDL_Window * window); -void photon_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon); -void photon_setwindowposition(_THIS, SDL_Window * window); -void photon_setwindowsize(_THIS, SDL_Window * window); -void photon_showwindow(_THIS, SDL_Window * window); -void photon_hidewindow(_THIS, SDL_Window * window); -void photon_raisewindow(_THIS, SDL_Window * window); -void photon_maximizewindow(_THIS, SDL_Window * window); -void photon_minimizewindow(_THIS, SDL_Window * window); -void photon_restorewindow(_THIS, SDL_Window * window); -void photon_setwindowgrab(_THIS, SDL_Window * window); -void photon_destroywindow(_THIS, SDL_Window * window); - -/* Window manager function */ -SDL_bool photon_getwindowwminfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); - -/* OpenGL/OpenGL ES functions */ -int photon_gl_loadlibrary(_THIS, const char *path); -void *photon_gl_getprocaddres(_THIS, const char *proc); -void photon_gl_unloadlibrary(_THIS); -SDL_GLContext photon_gl_createcontext(_THIS, SDL_Window * window); -int photon_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context); -int photon_gl_setswapinterval(_THIS, int interval); -int photon_gl_getswapinterval(_THIS); -void photon_gl_swapwindow(_THIS, SDL_Window * window); -void photon_gl_deletecontext(_THIS, SDL_GLContext context); - -/* Helper function, which re-creates surface, not an API */ -int photon_gl_recreatesurface(_THIS, SDL_Window * window, uint32_t width, uint32_t height); - -/* Event handling function */ -void photon_pumpevents(_THIS); - -/* Screen saver related function */ -void photon_suspendscreensaver(_THIS); - -#endif /* __SDL_PHOTON_H__ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon_input.c b/project/jni/sdl-1.3/src/video/photon/SDL_photon_input.c deleted file mode 100644 index b12012935..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon_input.c +++ /dev/null @@ -1,726 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_photon_input.h" - -#include "SDL_config.h" -#include "SDL_events.h" -#include "../../events/SDL_mouse_c.h" -#include "../../events/SDL_keyboard_c.h" - -#include "SDL_photon_keycodes.h" - -/* Mouse related functions */ -SDL_Cursor *photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y); -int photon_showcursor(SDL_Cursor * cursor); -void photon_movecursor(SDL_Cursor * cursor); -void photon_freecursor(SDL_Cursor * cursor); -void photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y); -void photon_freemouse(SDL_Mouse * mouse); - -int32_t -photon_addinputdevices(_THIS) -{ - SDL_VideoData *phdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata = NULL; - struct SDL_Mouse photon_mouse; - SDL_MouseData *mdata = NULL; - SDL_Keyboard photon_keyboard; - SDLKey keymap[SDL_NUM_SCANCODES]; - uint32_t it; - - for (it = 0; it < _this->num_displays; it++) { - SDL_VideoDisplay *display = &_this->displays[it]; - - /* Clear SDL mouse structure */ - SDL_memset(&photon_mouse, 0x00, sizeof(struct SDL_Mouse)); - - /* Allocate SDL_MouseData structure */ - mdata = (SDL_MouseData *) SDL_calloc(1, sizeof(SDL_MouseData)); - if (mdata == NULL) { - SDL_OutOfMemory(); - return -1; - } - - /* Mark this mouse with ID 0 */ - photon_mouse.id = it; - photon_mouse.driverdata = (void *) mdata; - photon_mouse.CreateCursor = photon_createcursor; - photon_mouse.ShowCursor = photon_showcursor; - photon_mouse.MoveCursor = photon_movecursor; - photon_mouse.FreeCursor = photon_freecursor; - photon_mouse.WarpMouse = photon_warpmouse; - photon_mouse.FreeMouse = photon_freemouse; - - /* Get display data */ - didata = (SDL_DisplayData *) display->driverdata; - - /* Store SDL_DisplayData pointer in the mouse driver internals */ - mdata->didata = didata; - - /* Register mouse cursor in SDL */ - SDL_AddMouse(&photon_mouse, "Photon mouse cursor", 0, 0, 1); - } - - /* Photon maps all keyboards to one */ - SDL_zero(photon_keyboard); - SDL_AddKeyboard(&photon_keyboard, -1); - - /* Add default scancode to key mapping */ - SDL_GetDefaultKeymap(keymap); - SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES); - - return 0; -} - -int32_t -photon_delinputdevices(_THIS) -{ - /* Destroy all of the mice */ - SDL_MouseQuit(); -} - -/*****************************************************************************/ -/* Photon mouse related functions */ -/*****************************************************************************/ -SDL_Cursor * -photon_createcursor(SDL_Surface * surface, int hot_x, int hot_y) -{ - PhCursorDef_t *internal_cursor; - SDL_Cursor *sdl_cursor; - uint8_t *image0 = NULL; - uint8_t *image1 = NULL; - uint32_t it; - uint32_t jt; - uint32_t shape_color; - - /* SDL converts monochrome cursor shape to 32bpp cursor shape */ - /* and we must convert it back to monochrome, this routine handles */ - /* 24/32bpp surfaces only */ - if ((surface->format->BitsPerPixel != 32) - && (surface->format->BitsPerPixel != 24)) { - SDL_SetError("Photon: Cursor shape is not 24/32bpp."); - return NULL; - } - - /* Checking data parameters */ - if ((surface->w == 0) || (surface->h == 0)) { - SDL_SetError("Photon: Cursor shape dimensions are zero"); - return NULL; - } - - /* Allocate memory for the internal cursor format */ - internal_cursor = (PhCursorDef_t *) SDL_calloc(1, sizeof(PhCursorDef_t) + - ((((surface->w + - 7) >> 3) * - surface->h) * 2) - 1); - if (internal_cursor == NULL) { - SDL_OutOfMemory(); - return NULL; - } - - /* Allocate memory for the SDL cursor */ - sdl_cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(SDL_Cursor)); - if (sdl_cursor == NULL) { - SDL_free(internal_cursor); - SDL_OutOfMemory(); - return NULL; - } - - /* Set driverdata as photon cursor format */ - image0 = (uint8_t *) internal_cursor; - image0 += sizeof(PhCursorDef_t) - 1; - image1 = image0; - image1 += ((surface->w + 7) >> 3) * surface->h; - sdl_cursor->driverdata = (void *) internal_cursor; - internal_cursor->hdr.len = - (sizeof(PhCursorDef_t) - sizeof(PhRegionDataHdr_t)) + - ((((surface->w + 7) >> 3) * surface->h) * 2) - 1; - internal_cursor->hdr.type = Ph_RDATA_CURSOR; - internal_cursor->size1.x = surface->w; - internal_cursor->size1.y = surface->h; - internal_cursor->size2.x = surface->w; - internal_cursor->size2.y = surface->h; - internal_cursor->offset1.x = -hot_x; - internal_cursor->offset1.y = -hot_y; - internal_cursor->offset2.x = -hot_x; - internal_cursor->offset2.y = -hot_y; - internal_cursor->bytesperline1 = ((surface->w + 7) >> 3); - internal_cursor->bytesperline2 = ((surface->w + 7) >> 3); - internal_cursor->color1 = (SDL_PHOTON_MOUSE_COLOR_BLACK) & 0x00FFFFFF; - internal_cursor->color2 = (SDL_PHOTON_MOUSE_COLOR_WHITE) & 0x00FFFFFF; - - /* Convert cursor from 32 bpp */ - for (jt = 0; jt < surface->h; jt++) { - for (it = 0; it < surface->w; it++) { - shape_color = - *((uint32_t *) ((uint8_t *) surface->pixels + - jt * surface->pitch + - it * surface->format->BytesPerPixel)); - switch (shape_color) { - case SDL_PHOTON_MOUSE_COLOR_BLACK: - { - *(image0 + jt * (internal_cursor->bytesperline1) + - (it >> 3)) |= 0x80 >> (it % 8); - *(image1 + jt * (internal_cursor->bytesperline2) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - } - break; - case SDL_PHOTON_MOUSE_COLOR_WHITE: - { - *(image0 + jt * (internal_cursor->bytesperline1) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - *(image1 + jt * (internal_cursor->bytesperline2) + - (it >> 3)) |= 0x80 >> (it % 8); - } - break; - case SDL_PHOTON_MOUSE_COLOR_TRANS: - { - *(image0 + jt * (internal_cursor->bytesperline1) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - *(image1 + jt * (internal_cursor->bytesperline2) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - } - break; - default: - { - /* The same as transparent color, must not happen */ - *(image0 + jt * (internal_cursor->bytesperline1) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - *(image1 + jt * (internal_cursor->bytesperline2) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - } - break; - } - } - } - - return sdl_cursor; -} - -int -photon_showcursor(SDL_Cursor * cursor) -{ - SDL_VideoDisplay *display; - SDL_DisplayData *didata; - SDL_Window *window; - SDL_WindowData *wdata; - PhCursorDef_t *internal_cursor; - int32_t status; - - /* Get current window id */ - window = SDL_GetFocusWindow(); - if (!window) { - SDL_MouseData *mdata = NULL; - - /* If there is no current window, then someone calls this function */ - /* to set global mouse settings during SDL initialization */ - if (cursor != NULL) { - /* Store cursor for future usage */ - mdata = (SDL_MouseData *) cursor->mouse->driverdata; - didata = (SDL_DisplayData *) mdata->didata; - internal_cursor = (PhCursorDef_t *) cursor->driverdata; - - if (didata->cursor_size >= - (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) { - SDL_memcpy(didata->cursor, internal_cursor, - internal_cursor->hdr.len + - sizeof(PhRegionDataHdr_t)); - } else { - /* Partitial cursor image */ - SDL_memcpy(didata->cursor, internal_cursor, - didata->cursor_size); - } - - didata->cursor_visible = SDL_TRUE; - return 0; - } else { - /* We can't get SDL_DisplayData at this point, return fake success */ - return 0; - } - } else { - /* Sanity checks */ - display = window->display; - if (display != NULL) { - didata = (SDL_DisplayData *) display->driverdata; - if (didata != NULL) { - wdata = (SDL_WindowData *) window->driverdata; - if (wdata == NULL) { - return -1; - } - } else { - return -1; - } - } else { - return -1; - } - } - - /* return if window widget has been destroyed already */ - if (wdata->window == NULL) { - return; - } - - /* Check if we need to set new shape or disable cursor shape */ - if (cursor != NULL) { - /* Retrieve photon cursor shape */ - internal_cursor = (PhCursorDef_t *) cursor->driverdata; - if (internal_cursor == NULL) { - SDL_SetError("Photon: Internal cursor data is absent"); - return -1; - } - - /* Setup cursor type */ - status = - PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_BITMAP, - 0); - if (status != 0) { - SDL_SetError("Photon: Failed to set cursor type to bitmap"); - return -1; - } - - /* Setup cursor color to default */ - status = - PtSetResource(wdata->window, Pt_ARG_CURSOR_COLOR, - Ph_CURSOR_DEFAULT_COLOR, 0); - if (status != 0) { - SDL_SetError("Photon: Failed to set cursor color"); - return -1; - } - - /* Setup cursor shape */ - status = - PtSetResource(wdata->window, Pt_ARG_BITMAP_CURSOR, - internal_cursor, - internal_cursor->hdr.len + - sizeof(PhRegionDataHdr_t)); - if (status != 0) { - SDL_SetError("Photon: Failed to set cursor color"); - return -1; - } - - /* Store current cursor for future usage */ - if (didata->cursor_size >= - (internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t))) { - SDL_memcpy(didata->cursor, internal_cursor, - internal_cursor->hdr.len + sizeof(PhRegionDataHdr_t)); - } else { - /* Partitial cursor image */ - SDL_memcpy(didata->cursor, internal_cursor, didata->cursor_size); - } - - /* Set cursor visible */ - didata->cursor_visible = SDL_TRUE; - } else { - /* SDL requests to disable cursor */ - status = - PtSetResource(wdata->window, Pt_ARG_CURSOR_TYPE, Ph_CURSOR_NONE, - 0); - if (status != 0) { - SDL_SetError("Photon: Can't disable cursor"); - return -1; - } - - /* Set cursor invisible */ - didata->cursor_visible = SDL_FALSE; - } - - /* Flush all pending widget data */ - PtFlush(); - - /* New cursor shape is set */ - return 0; -} - -void -photon_movecursor(SDL_Cursor * cursor) -{ - SDL_VideoDisplay *display; - SDL_DisplayData *didata; - SDL_Window *window; - SDL_WindowData *wdata; - SDL_WindowID window_id; - int32_t status; - - /* Get current window id */ - window_id = SDL_GetFocusWindow(); - if (window_id <= 0) { - didata = (SDL_DisplayData *) cursor->mouse->driverdata; - } else { - /* Sanity checks */ - window = SDL_GetWindowFromID(window_id); - if (window != NULL) { - display = window->display; - if (display != NULL) { - didata = (SDL_DisplayData *) display->driverdata; - if (didata != NULL) { - wdata = (SDL_WindowData *) window->driverdata; - if (wdata == NULL) { - return; - } - } else { - return; - } - } else { - return; - } - } else { - return; - } - } - - /* No need to move mouse cursor manually in the photon */ - - return; -} - -void -photon_freecursor(SDL_Cursor * cursor) -{ - PhCursorDef_t *internal_cursor = NULL; - - if (cursor != NULL) { - internal_cursor = (PhCursorDef_t *) cursor->driverdata; - if (internal_cursor != NULL) { - SDL_free(internal_cursor); - cursor->driverdata = NULL; - } - } -} - -void -photon_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y) -{ - SDL_VideoDisplay *display; - SDL_DisplayData *didata; - SDL_WindowData *wdata; - int16_t wx; - int16_t wy; - - /* Sanity checks */ - if (window != NULL) { - display = window->display; - if (display != NULL) { - didata = (SDL_DisplayData *) display->driverdata; - if (didata != NULL) { - wdata = (SDL_WindowData *) window->driverdata; - if (wdata == NULL) { - return; - } - } else { - return; - } - } else { - return; - } - } else { - return; - } - - PtGetAbsPosition(wdata->window, &wx, &wy); - PhMoveCursorAbs(PhInputGroup(NULL), wx + x, wy + y); - - return; -} - -void -photon_freemouse(SDL_Mouse * mouse) -{ - if (mouse->driverdata == NULL) { - return; - } - - /* Mouse framework doesn't deletes automatically our driverdata */ - SDL_free(mouse->driverdata); - mouse->driverdata = NULL; - - return; -} - -SDL_scancode -photon_to_sdl_keymap(uint32_t key) -{ - SDL_scancode scancode = SDL_SCANCODE_UNKNOWN; - - switch (key & 0x0000007F) { - case PHOTON_SCANCODE_ESCAPE: - scancode = SDL_SCANCODE_ESCAPE; - break; - case PHOTON_SCANCODE_F1: - scancode = SDL_SCANCODE_F1; - break; - case PHOTON_SCANCODE_F2: - scancode = SDL_SCANCODE_F2; - break; - case PHOTON_SCANCODE_F3: - scancode = SDL_SCANCODE_F3; - break; - case PHOTON_SCANCODE_F4: - scancode = SDL_SCANCODE_F4; - break; - case PHOTON_SCANCODE_F5: - scancode = SDL_SCANCODE_F5; - break; - case PHOTON_SCANCODE_F6: - scancode = SDL_SCANCODE_F6; - break; - case PHOTON_SCANCODE_F7: - scancode = SDL_SCANCODE_F7; - break; - case PHOTON_SCANCODE_F8: - scancode = SDL_SCANCODE_F8; - break; - case PHOTON_SCANCODE_F9: - scancode = SDL_SCANCODE_F9; - break; - case PHOTON_SCANCODE_F10: - scancode = SDL_SCANCODE_F10; - break; - case PHOTON_SCANCODE_F11: - scancode = SDL_SCANCODE_F11; - break; - case PHOTON_SCANCODE_F12: - scancode = SDL_SCANCODE_F12; - break; - case PHOTON_SCANCODE_BACKQOUTE: - scancode = SDL_SCANCODE_GRAVE; - break; - case PHOTON_SCANCODE_1: - scancode = SDL_SCANCODE_1; - break; - case PHOTON_SCANCODE_2: - scancode = SDL_SCANCODE_2; - break; - case PHOTON_SCANCODE_3: - scancode = SDL_SCANCODE_3; - break; - case PHOTON_SCANCODE_4: - scancode = SDL_SCANCODE_4; - break; - case PHOTON_SCANCODE_5: - scancode = SDL_SCANCODE_5; - break; - case PHOTON_SCANCODE_6: - scancode = SDL_SCANCODE_6; - break; - case PHOTON_SCANCODE_7: - scancode = SDL_SCANCODE_7; - break; - case PHOTON_SCANCODE_8: - scancode = SDL_SCANCODE_8; - break; - case PHOTON_SCANCODE_9: - scancode = SDL_SCANCODE_9; - break; - case PHOTON_SCANCODE_0: - scancode = SDL_SCANCODE_0; - break; - case PHOTON_SCANCODE_MINUS: - scancode = SDL_SCANCODE_MINUS; - break; - case PHOTON_SCANCODE_EQUAL: - scancode = SDL_SCANCODE_EQUALS; - break; - case PHOTON_SCANCODE_BACKSPACE: - scancode = SDL_SCANCODE_BACKSPACE; - break; - case PHOTON_SCANCODE_TAB: - scancode = SDL_SCANCODE_TAB; - break; - case PHOTON_SCANCODE_Q: - scancode = SDL_SCANCODE_Q; - break; - case PHOTON_SCANCODE_W: - scancode = SDL_SCANCODE_W; - break; - case PHOTON_SCANCODE_E: - scancode = SDL_SCANCODE_E; - break; - case PHOTON_SCANCODE_R: - scancode = SDL_SCANCODE_R; - break; - case PHOTON_SCANCODE_T: - scancode = SDL_SCANCODE_T; - break; - case PHOTON_SCANCODE_Y: - scancode = SDL_SCANCODE_Y; - break; - case PHOTON_SCANCODE_U: - scancode = SDL_SCANCODE_U; - break; - case PHOTON_SCANCODE_I: - scancode = SDL_SCANCODE_I; - break; - case PHOTON_SCANCODE_O: - scancode = SDL_SCANCODE_O; - break; - case PHOTON_SCANCODE_P: - scancode = SDL_SCANCODE_P; - break; - case PHOTON_SCANCODE_LEFT_SQ_BR: - scancode = SDL_SCANCODE_LEFTBRACKET; - break; - case PHOTON_SCANCODE_RIGHT_SQ_BR: - scancode = SDL_SCANCODE_RIGHTBRACKET; - break; - case PHOTON_SCANCODE_ENTER: - scancode = SDL_SCANCODE_RETURN; - break; - case PHOTON_SCANCODE_CAPSLOCK: - scancode = SDL_SCANCODE_CAPSLOCK; - break; - case PHOTON_SCANCODE_A: - scancode = SDL_SCANCODE_A; - break; - case PHOTON_SCANCODE_S: - scancode = SDL_SCANCODE_S; - break; - case PHOTON_SCANCODE_D: - scancode = SDL_SCANCODE_D; - break; - case PHOTON_SCANCODE_F: - scancode = SDL_SCANCODE_F; - break; - case PHOTON_SCANCODE_G: - scancode = SDL_SCANCODE_G; - break; - case PHOTON_SCANCODE_H: - scancode = SDL_SCANCODE_H; - break; - case PHOTON_SCANCODE_J: - scancode = SDL_SCANCODE_J; - break; - case PHOTON_SCANCODE_K: - scancode = SDL_SCANCODE_K; - break; - case PHOTON_SCANCODE_L: - scancode = SDL_SCANCODE_L; - break; - case PHOTON_SCANCODE_SEMICOLON: - scancode = SDL_SCANCODE_SEMICOLON; - break; - case PHOTON_SCANCODE_QUOTE: - scancode = SDL_SCANCODE_APOSTROPHE; - break; - case PHOTON_SCANCODE_BACKSLASH: - scancode = SDL_SCANCODE_BACKSLASH; - break; - case PHOTON_SCANCODE_LEFT_SHIFT: - scancode = SDL_SCANCODE_LSHIFT; - break; - case PHOTON_SCANCODE_Z: - scancode = SDL_SCANCODE_Z; - break; - case PHOTON_SCANCODE_X: - scancode = SDL_SCANCODE_X; - break; - case PHOTON_SCANCODE_C: - scancode = SDL_SCANCODE_C; - break; - case PHOTON_SCANCODE_V: - scancode = SDL_SCANCODE_V; - break; - case PHOTON_SCANCODE_B: - scancode = SDL_SCANCODE_B; - break; - case PHOTON_SCANCODE_N: - scancode = SDL_SCANCODE_N; - break; - case PHOTON_SCANCODE_M: - scancode = SDL_SCANCODE_M; - break; - case PHOTON_SCANCODE_COMMA: - scancode = SDL_SCANCODE_COMMA; - break; - case PHOTON_SCANCODE_POINT: - scancode = SDL_SCANCODE_PERIOD; - break; - case PHOTON_SCANCODE_SLASH: - scancode = SDL_SCANCODE_SLASH; - break; - case PHOTON_SCANCODE_RIGHT_SHIFT: - scancode = SDL_SCANCODE_RSHIFT; - break; - case PHOTON_SCANCODE_CTRL: - scancode = SDL_SCANCODE_LCTRL; - break; - case PHOTON_SCANCODE_WFLAG: - scancode = SDL_SCANCODE_LGUI; - break; - case PHOTON_SCANCODE_ALT: - scancode = SDL_SCANCODE_LALT; - break; - case PHOTON_SCANCODE_SPACE: - scancode = SDL_SCANCODE_SPACE; - break; - case PHOTON_SCANCODE_MENU: - scancode = SDL_SCANCODE_MENU; - break; - case PHOTON_SCANCODE_PRNSCR: - scancode = SDL_SCANCODE_PRINTSCREEN; - break; - case PHOTON_SCANCODE_SCROLLLOCK: - scancode = SDL_SCANCODE_SCROLLLOCK; - break; - case PHOTON_SCANCODE_INSERT: - scancode = SDL_SCANCODE_INSERT; - break; - case PHOTON_SCANCODE_HOME: - scancode = SDL_SCANCODE_HOME; - break; - case PHOTON_SCANCODE_PAGEUP: - scancode = SDL_SCANCODE_PAGEUP; - break; - case PHOTON_SCANCODE_DELETE: - scancode = SDL_SCANCODE_DELETE; - break; - case PHOTON_SCANCODE_END: - scancode = SDL_SCANCODE_END; - break; - case PHOTON_SCANCODE_PAGEDOWN: - scancode = SDL_SCANCODE_PAGEDOWN; - break; - case PHOTON_SCANCODE_UP: - scancode = SDL_SCANCODE_UP; - break; - case PHOTON_SCANCODE_DOWN: - scancode = SDL_SCANCODE_DOWN; - break; - case PHOTON_SCANCODE_LEFT: - scancode = SDL_SCANCODE_LEFT; - break; - case PHOTON_SCANCODE_RIGHT: - scancode = SDL_SCANCODE_RIGHT; - break; - case PHOTON_SCANCODE_NUMLOCK: - scancode = SDL_SCANCODE_NUMLOCKCLEAR; - break; - default: - break; - } - - return scancode; -} diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon_input.h b/project/jni/sdl-1.3/src/video/photon/SDL_photon_input.h deleted file mode 100644 index cc1be32c5..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon_input.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_PHOTON_INPUT_H__ -#define __SDL_PHOTON_INPUT_H__ - -#include "SDL_config.h" -#include "SDL_video.h" -#include "../SDL_sysvideo.h" - -#include "SDL_photon.h" - -typedef struct SDL_MouseData -{ - SDL_DisplayData *didata; -} SDL_MouseData; - -int32_t photon_addinputdevices(_THIS); -int32_t photon_delinputdevices(_THIS); - -#define SDL_PHOTON_MOUSE_COLOR_BLACK 0xFF000000 -#define SDL_PHOTON_MOUSE_COLOR_WHITE 0xFFFFFFFF -#define SDL_PHOTON_MOUSE_COLOR_TRANS 0x00000000 - -SDL_scancode photon_to_sdl_keymap(uint32_t key); - -#endif /* __SDL_GF_INPUT_H__ */ diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon_keycodes.h b/project/jni/sdl-1.3/src/video/photon/SDL_photon_keycodes.h deleted file mode 100644 index 3f97376db..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon_keycodes.h +++ /dev/null @@ -1,125 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_PHOTON_KEYCODES_H__ -#define __SDL_PHOTON_KEYCODES_H__ - -#define PHOTON_SCANCODE_ESCAPE 0x01 -#define PHOTON_SCANCODE_F1 0x3B -#define PHOTON_SCANCODE_F2 0x3C -#define PHOTON_SCANCODE_F3 0x3D -#define PHOTON_SCANCODE_F4 0x3E -#define PHOTON_SCANCODE_F5 0x3F -#define PHOTON_SCANCODE_F6 0x40 -#define PHOTON_SCANCODE_F7 0x41 -#define PHOTON_SCANCODE_F8 0x42 -#define PHOTON_SCANCODE_F9 0x43 -#define PHOTON_SCANCODE_F10 0x44 -#define PHOTON_SCANCODE_F11 0x57 -#define PHOTON_SCANCODE_F12 0x58 - -#define PHOTON_SCANCODE_BACKQOUTE 0x29 -#define PHOTON_SCANCODE_1 0x02 -#define PHOTON_SCANCODE_2 0x03 -#define PHOTON_SCANCODE_3 0x04 -#define PHOTON_SCANCODE_4 0x05 -#define PHOTON_SCANCODE_5 0x06 -#define PHOTON_SCANCODE_6 0x07 -#define PHOTON_SCANCODE_7 0x08 -#define PHOTON_SCANCODE_8 0x09 -#define PHOTON_SCANCODE_9 0x0A -#define PHOTON_SCANCODE_0 0x0B -#define PHOTON_SCANCODE_MINUS 0x0C -#define PHOTON_SCANCODE_EQUAL 0x0D -#define PHOTON_SCANCODE_BACKSPACE 0x0E - -#define PHOTON_SCANCODE_TAB 0x0F -#define PHOTON_SCANCODE_Q 0x10 -#define PHOTON_SCANCODE_W 0x11 -#define PHOTON_SCANCODE_E 0x12 -#define PHOTON_SCANCODE_R 0x13 -#define PHOTON_SCANCODE_T 0x14 -#define PHOTON_SCANCODE_Y 0x15 -#define PHOTON_SCANCODE_U 0x16 -#define PHOTON_SCANCODE_I 0x17 -#define PHOTON_SCANCODE_O 0x18 -#define PHOTON_SCANCODE_P 0x19 -#define PHOTON_SCANCODE_LEFT_SQ_BR 0x1A -#define PHOTON_SCANCODE_RIGHT_SQ_BR 0x1B -#define PHOTON_SCANCODE_ENTER 0x1C - -#define PHOTON_SCANCODE_CAPSLOCK 0x3A -#define PHOTON_SCANCODE_A 0x1E -#define PHOTON_SCANCODE_S 0x1F -#define PHOTON_SCANCODE_D 0x20 -#define PHOTON_SCANCODE_F 0x21 -#define PHOTON_SCANCODE_G 0x22 -#define PHOTON_SCANCODE_H 0x23 -#define PHOTON_SCANCODE_J 0x24 -#define PHOTON_SCANCODE_K 0x25 -#define PHOTON_SCANCODE_L 0x26 -#define PHOTON_SCANCODE_SEMICOLON 0x27 -#define PHOTON_SCANCODE_QUOTE 0x28 -#define PHOTON_SCANCODE_BACKSLASH 0x2B - -#define PHOTON_SCANCODE_LEFT_SHIFT 0x2A -#define PHOTON_SCANCODE_Z 0x2C -#define PHOTON_SCANCODE_X 0x2D -#define PHOTON_SCANCODE_C 0x2E -#define PHOTON_SCANCODE_V 0x2F -#define PHOTON_SCANCODE_B 0x30 -#define PHOTON_SCANCODE_N 0x31 -#define PHOTON_SCANCODE_M 0x32 -#define PHOTON_SCANCODE_COMMA 0x33 -#define PHOTON_SCANCODE_POINT 0x34 -#define PHOTON_SCANCODE_SLASH 0x35 -#define PHOTON_SCANCODE_RIGHT_SHIFT 0x36 - -#define PHOTON_SCANCODE_CTRL 0x1D -#define PHOTON_SCANCODE_WFLAG 0x5B -#define PHOTON_SCANCODE_ALT 0x38 -#define PHOTON_SCANCODE_SPACE 0x39 -#define PHOTON_SCANCODE_MENU 0x5D - -#define PHOTON_SCANCODE_PRNSCR 0x54 /* only key pressed event, no release */ -#define PHOTON_SCANCODE_SCROLLLOCK 0x46 -#if 0 /* pause doesn't generates a scancode */ -#define PHOTON_SCANCODE_PAUSE 0x?? -#endif -#define PHOTON_SCANCODE_INSERT 0x52 -#define PHOTON_SCANCODE_HOME 0x47 -#define PHOTON_SCANCODE_PAGEUP 0x49 -#define PHOTON_SCANCODE_DELETE 0x53 -#define PHOTON_SCANCODE_END 0x4F -#define PHOTON_SCANCODE_PAGEDOWN 0x51 -#define PHOTON_SCANCODE_UP 0x48 -#define PHOTON_SCANCODE_DOWN 0x50 -#define PHOTON_SCANCODE_LEFT 0x4B -#define PHOTON_SCANCODE_RIGHT 0x4D - -#define PHOTON_SCANCODE_NUMLOCK 0x45 - -#endif /* __SDL_PHOTON_KEYCODES_H__ */ diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon_pixelfmt.c b/project/jni/sdl-1.3/src/video/photon/SDL_photon_pixelfmt.c deleted file mode 100644 index cfabe9676..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon_pixelfmt.c +++ /dev/null @@ -1,218 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_photon_pixelfmt.h" - -uint32_t -photon_bits_to_sdl_pixelformat(uint32_t pixelfmt) -{ - switch (pixelfmt) { - case 8: - { - return SDL_PIXELFORMAT_INDEX8; - } - break; - case 15: - { - return SDL_PIXELFORMAT_ARGB1555; - } - break; - case 16: - { - return SDL_PIXELFORMAT_RGB565; - } - break; - case 24: - { - return SDL_PIXELFORMAT_RGB888; - } - break; - case 32: - { - return SDL_PIXELFORMAT_ARGB8888; - } - break; - } -} - -uint32_t -photon_sdl_to_bits_pixelformat(uint32_t pixelfmt) -{ - switch (pixelfmt) { - case SDL_PIXELFORMAT_INDEX8: - { - return 8; - } - break; - case SDL_PIXELFORMAT_ARGB1555: - { - return 15; - } - break; - case SDL_PIXELFORMAT_RGB555: - { - return 15; - } - break; - case SDL_PIXELFORMAT_ABGR1555: - { - return 15; - } - break; - case SDL_PIXELFORMAT_RGB565: - { - return 16; - } - break; - case SDL_PIXELFORMAT_RGB24: - { - return 24; - } - break; - case SDL_PIXELFORMAT_RGB888: - { - return 32; - } - break; - case SDL_PIXELFORMAT_BGRA8888: - { - return 32; - } - break; - case SDL_PIXELFORMAT_ARGB8888: - { - return 32; - } - break; - case SDL_PIXELFORMAT_YV12: - { - return 8; - } - break; - case SDL_PIXELFORMAT_YUY2: - { - return 16; - } - break; - case SDL_PIXELFORMAT_UYVY: - { - return 16; - } - break; - case SDL_PIXELFORMAT_YVYU: - { - return 16; - } - break; - } - - return 0; -} - -uint32_t -photon_image_to_sdl_pixelformat(uint32_t pixelfmt) -{ - switch (pixelfmt) { - case Pg_IMAGE_PALETTE_BYTE: - { - return SDL_PIXELFORMAT_INDEX8; - } - break; - case Pg_IMAGE_DIRECT_8888: - { - return SDL_PIXELFORMAT_ARGB8888; - } - break; - case Pg_IMAGE_DIRECT_888: - { - return SDL_PIXELFORMAT_RGB24; - } - break; - case Pg_IMAGE_DIRECT_565: - { - return SDL_PIXELFORMAT_RGB565; - } - break; - case Pg_IMAGE_DIRECT_555: - { - return SDL_PIXELFORMAT_RGB555; - } - break; - case Pg_IMAGE_DIRECT_1555: - { - return SDL_PIXELFORMAT_ARGB1555; - } - break; - } - - return 0; -} - -uint32_t -photon_sdl_to_image_pixelformat(uint32_t pixelfmt) -{ - switch (pixelfmt) { - case SDL_PIXELFORMAT_INDEX8: - { - return Pg_IMAGE_PALETTE_BYTE; - } - break; - case SDL_PIXELFORMAT_ARGB8888: - { - return Pg_IMAGE_DIRECT_8888; - } - break; - case SDL_PIXELFORMAT_RGB888: - { - return Pg_IMAGE_DIRECT_8888; - } - break; - case SDL_PIXELFORMAT_RGB24: - { - return Pg_IMAGE_DIRECT_888; - } - break; - case SDL_PIXELFORMAT_RGB565: - { - return Pg_IMAGE_DIRECT_565; - } - break; - case SDL_PIXELFORMAT_ARGB1555: - { - return Pg_IMAGE_DIRECT_1555; - } - break; - case SDL_PIXELFORMAT_RGB555: - { - return Pg_IMAGE_DIRECT_555; - } - break; - } - - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon_pixelfmt.h b/project/jni/sdl-1.3/src/video/photon/SDL_photon_pixelfmt.h deleted file mode 100644 index 0e6990bfd..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon_pixelfmt.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_config.h" -#include "../SDL_sysvideo.h" - -#include - -#ifndef __SDL_PHOTON_PIXELFMT_H__ -#define __SDL_PHOTON_PIXELFMT_H__ - -uint32_t photon_bits_to_sdl_pixelformat(uint32_t pixelfmt); -uint32_t photon_sdl_to_bits_pixelformat(uint32_t pixelfmt); -uint32_t photon_image_to_sdl_pixelformat(uint32_t pixelfmt); -uint32_t photon_sdl_to_image_pixelformat(uint32_t pixelfmt); - -#endif /* __SDL_PHOTON_PIXELFMT_H__ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon_render.c b/project/jni/sdl-1.3/src/video/photon/SDL_photon_render.c deleted file mode 100644 index 1e4719bcd..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon_render.c +++ /dev/null @@ -1,1690 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_config.h" - -#include "../SDL_pixels_c.h" -#include "../SDL_yuv_sw_c.h" - -#include "SDL_video.h" - -#include "SDL_photon_render.h" -#include "SDL_photon.h" - -#ifndef Pg_OSC_MEM_LINEAR_ACCESSIBLE - /* For QNX 6.3.2 compatibility */ - #define Pg_OSC_MEM_LINEAR_ACCESSIBLE 0 -#endif /* Pg_OSC_MEM_LINEAR_ACCESSIBLE */ - -static SDL_Renderer *photon_createrenderer(SDL_Window * window, Uint32 flags); -static int photon_displaymodechanged(SDL_Renderer * renderer); -static int photon_activaterenderer(SDL_Renderer * renderer); -static int photon_createtexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static int photon_querytexturepixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int photon_settexturepalette(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); -static int photon_gettexturepalette(SDL_Renderer * renderer, - SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors); -static int photon_settexturecolormod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int photon_settexturealphamod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int photon_settextureblendmode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int photon_settexturescalemode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int photon_updatetexture(SDL_Renderer * renderer, - SDL_Texture * texture, const SDL_Rect * rect, - const void *pixels, int pitch); -static int photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch); -static void photon_unlocktexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void photon_dirtytexture(SDL_Renderer * renderer, - SDL_Texture * texture, int numrects, - const SDL_Rect * rects); -static int photon_setdrawcolor(SDL_Renderer * renderer); -static int photon_setdrawblendmode(SDL_Renderer * renderer); -static int photon_renderpoint(SDL_Renderer * renderer, int x, int y); -static int photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, - int y2); -static int photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect); -static int photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_Rect * dstrect); -static int photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch); -static int photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch); -static void photon_renderpresent(SDL_Renderer * renderer); -static void photon_destroytexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void photon_destroyrenderer(SDL_Renderer * renderer); - -static int _photon_recreate_surfaces(SDL_Renderer * renderer); - -SDL_RenderDriver photon_renderdriver = { - photon_createrenderer, - { - "photon", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | - SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND | - SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), - (SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW | SDL_SCALEMODE_FAST), - 10, - {SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB24, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_YUY2, - SDL_PIXELFORMAT_UYVY, - SDL_PIXELFORMAT_YVYU}, - 0, - 0} -}; - -static SDL_Renderer * -photon_createrenderer(SDL_Window * window, Uint32 flags) -{ - SDL_VideoDisplay *display = window->display; - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - SDL_Renderer *renderer = NULL; - SDL_RenderData *rdata = NULL; - - /* Allocate new renderer structure */ - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer)); - if (renderer == NULL) { - SDL_OutOfMemory(); - return NULL; - } - - /* Allocate renderer data */ - rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData)); - if (rdata == NULL) { - SDL_free(renderer); - SDL_OutOfMemory(); - return NULL; - } - - renderer->DisplayModeChanged = photon_displaymodechanged; - renderer->ActivateRenderer = photon_activaterenderer; - renderer->CreateTexture = photon_createtexture; - renderer->QueryTexturePixels = photon_querytexturepixels; - renderer->SetTexturePalette = photon_settexturepalette; - renderer->GetTexturePalette = photon_gettexturepalette; - renderer->SetTextureAlphaMod = photon_settexturealphamod; - renderer->SetTextureColorMod = photon_settexturecolormod; - renderer->SetTextureBlendMode = photon_settextureblendmode; - renderer->SetTextureScaleMode = photon_settexturescalemode; - renderer->UpdateTexture = photon_updatetexture; - renderer->LockTexture = photon_locktexture; - renderer->UnlockTexture = photon_unlocktexture; - renderer->DirtyTexture = photon_dirtytexture; - renderer->SetDrawColor = photon_setdrawcolor; - renderer->SetDrawBlendMode = photon_setdrawblendmode; - renderer->RenderPoint = photon_renderpoint; - renderer->RenderLine = photon_renderline; - renderer->RenderFill = photon_renderfill; - renderer->RenderCopy = photon_rendercopy; - renderer->RenderReadPixels = photon_renderreadpixels; - renderer->RenderWritePixels = photon_renderwritepixels; - renderer->RenderPresent = photon_renderpresent; - renderer->DestroyTexture = photon_destroytexture; - renderer->DestroyRenderer = photon_destroyrenderer; - renderer->info = photon_renderdriver.info; - renderer->window = window; - renderer->driverdata = rdata; - - /* Copy direct_mode status */ - rdata->direct_mode=didata->direct_mode; - - /* Set render acceleration flag in case it is accelerated */ - if ((didata->caps & SDL_PHOTON_ACCELERATED) == SDL_PHOTON_ACCELERATED) { - renderer->info.flags = SDL_RENDERER_ACCELERATED; - } else { - renderer->info.flags = 0; - } - - /* Check if upper level requested synchronization on vsync signal */ - if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) { - if (rdata->direct_mode==SDL_TRUE) - { - /* We can control vsync only in direct mode */ - rdata->enable_vsync = SDL_TRUE; - renderer->info.flags |= SDL_RENDERER_PRESENTVSYNC; - } - else - { - rdata->enable_vsync = SDL_FALSE; - } - } else { - rdata->enable_vsync = SDL_FALSE; - } - - /* Check what buffer copy/flip scheme is requested */ - rdata->surfaces_count = 0; - if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) { - if ((flags & SDL_RENDERER_PRESENTDISCARD) == - SDL_RENDERER_PRESENTDISCARD) { - renderer->info.flags |= - SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD; - } else { - renderer->info.flags |= - SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; - } - rdata->surfaces_count = 1; - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 0; - } else { - if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; - rdata->surfaces_count = 2; - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 1; - } else { - if ((flags & SDL_RENDERER_PRESENTFLIP3) == - SDL_RENDERER_PRESENTFLIP3) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; - rdata->surfaces_count = 3; - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 1; - } else { - renderer->info.flags |= - SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; - rdata->surfaces_count = 1; - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 0; - } - } - } - - /* Create new graphics context for the renderer */ - if (rdata->gc==NULL) - { - rdata->gc=PgCreateGC(0); - PgDefaultGC(rdata->gc); - } - - /* Setup textures supported by current renderer instance */ - renderer->info.num_texture_formats=1; - renderer->info.texture_formats[0]=didata->current_mode.format; - - /* Initialize surfaces */ - _photon_recreate_surfaces(renderer); - - /* Set current scale blitting capabilities */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN) - { - renderer->info.scale_modes=SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW; - if ((didata->mode_2dcaps & SDL_VIDEO_PHOTON_CAP_SCALED_BLIT)==SDL_VIDEO_PHOTON_CAP_SCALED_BLIT) - { - /* This video mode supports hardware scaling */ - renderer->info.scale_modes|=SDL_SCALEMODE_FAST; - } - } - else - { - /* PhImage blit functions do not support scaling */ - renderer->info.scale_modes=SDL_SCALEMODE_NONE; - } - - return renderer; -} - -void -photon_addrenderdriver(_THIS) -{ - uint32_t it; - - for (it = 0; it < _this->num_displays; it++) { - SDL_AddRenderDriver(&_this->displays[it], &photon_renderdriver); - } -} - -/****************************************************************************/ -/* Renderer helper functions */ -/****************************************************************************/ - -static int _photon_recreate_surfaces(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_VideoDisplay *display = NULL; - SDL_DisplayData *didata = NULL; - SDL_Window *window = NULL; - SDL_WindowData *wdata = NULL; - SDL_VideoData *phdata = NULL; - uint32_t allocate_task=SDL_PHOTON_SURFTYPE_UNKNOWN; - int32_t status; - - /* Obtain window and display structures */ - window=SDL_GetWindowFromID(renderer->window); - wdata=(SDL_WindowData*)window->driverdata; - display=window->display; - didata=(SDL_DisplayData *) display->driverdata; - phdata=(SDL_VideoData *) display->device->driverdata; - - /* Check if it is OpenGL ES window */ - if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { - /* If so, do not waste surfaces */ - rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN; - return 0; - } - - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - /* Try to allocate offscreen surfaces */ - allocate_task=SDL_PHOTON_SURFTYPE_OFFSCREEN; - } - else - { - uint32_t it; - - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN) - { - /* Create offscreen surfaces */ - allocate_task=SDL_PHOTON_SURFTYPE_OFFSCREEN; - - /* Before destroying surfaces, be sure, that rendering was completed */ - PgFlush(); - PgWaitHWIdle(); - - /* Destroy current surfaces */ - for (it=0; itosurfaces[it] != NULL) - { - PhDCRelease(rdata->osurfaces[it]); - rdata->osurfaces[it] = NULL; - } - } - } - else - { - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_PHIMAGE) - { - /* Create shared phimage surfaces */ - allocate_task=SDL_PHOTON_SURFTYPE_PHIMAGE; - - /* Destroy current surfaces */ - for (it=0; itpcontexts[it]!=NULL) - { - PmMemReleaseMC(rdata->pcontexts[it]); - rdata->pcontexts[it]=NULL; - } - if (rdata->psurfaces[it]!=NULL) - { - if (rdata->psurfaces[it]->palette!=NULL) - { - SDL_free(rdata->psurfaces[it]->palette); - rdata->psurfaces[it]->palette=NULL; - } - /* Destroy shared memory for PhImage_t */ - PgShmemDestroy(rdata->psurfaces[it]->image); - rdata->psurfaces[it]->image=NULL; - SDL_free(rdata->psurfaces[it]); - rdata->psurfaces[it]=NULL; - } - } - } - } - } - - /* Check if current device is not the same as target */ - if (phdata->current_device_id != didata->device_id) { - /* Set target device as default for Pd and Pg functions */ - status = PdSetTargetDevice(NULL, phdata->rid[didata->device_id]); - if (status != 0) { - SDL_SetError("Photon: Can't set default target device\n"); - return -1; - } - phdata->current_device_id = didata->device_id; - } - - switch (allocate_task) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - { - int32_t it; - int32_t jt; - - /* Try the hardware accelerated offscreen surfaces first */ - for (it=0; itsurfaces_count; it++) - { - rdata->osurfaces[it]=PdCreateOffscreenContext(0, window->w, window->h, - Pg_OSC_MEM_LINEAR_ACCESSIBLE | Pg_OSC_MEM_PAGE_ALIGN | - /* in case if 2D acceleration is available use it */ - Pg_OSC_MEM_2D_WRITABLE | Pg_OSC_MEM_2D_READABLE); - /* If we can't create an offscreen surface, then fallback to software */ - if (rdata->osurfaces[it]==NULL) - { - /* Destroy previously allocated surface(s) */ - for (jt = it - 1; jt > 0; jt--) - { - PhDCRelease(rdata->osurfaces[jt]); - rdata->osurfaces[jt] = NULL; - } - break; - } - } - - /* Check if all required surfaces have been created */ - if (rdata->osurfaces[0]!=NULL) - { - rdata->surfaces_type=SDL_PHOTON_SURFTYPE_OFFSCREEN; - /* exit from switch if surfaces have been created */ - break; - } - else - { - /* else fall through to software phimage surface allocation */ - } - } - /* fall through */ - case SDL_PHOTON_SURFTYPE_PHIMAGE: - { - int32_t it; - int32_t jt; - uint32_t image_pfmt=photon_sdl_to_image_pixelformat(didata->current_mode.format); - - /* Try to allocate the software surfaces in shared memory */ - for (it=0; itsurfaces_count; it++) - { - /* If this surface with palette, create a palette space */ - if (image_pfmt==Pg_IMAGE_PALETTE_BYTE) - { - rdata->psurfaces[it]=PhCreateImage(NULL, window->w, window->h, - image_pfmt, NULL, 256, 1); - } - else - { - rdata->psurfaces[it]=PhCreateImage(NULL, window->w, window->h, - image_pfmt, NULL, 0, 1); - } - - if (rdata->psurfaces[it]!=NULL) - { - PhPoint_t translation={0, 0}; - PhDim_t dimension={window->w, window->h}; - - /* Create memory context for PhImage_t */ - rdata->pcontexts[it]=PmMemCreateMC(rdata->psurfaces[it], &dimension, &translation); - } - - if ((rdata->psurfaces[it]==NULL) || (rdata->pcontexts[it]==NULL)) - { - /* Destroy previously allocated surface(s) */ - for (jt = it - 1; jt > 0; jt--) - { - if (rdata->pcontexts[jt]!=NULL) - { - PmMemReleaseMC(rdata->pcontexts[it]); - rdata->pcontexts[jt]=NULL; - } - if (rdata->psurfaces[jt]!=NULL) - { - if (rdata->psurfaces[jt]->palette!=NULL) - { - SDL_free(rdata->psurfaces[jt]->palette); - rdata->psurfaces[jt]->palette=NULL; - } - /* Destroy shared memory for PhImage_t */ - PgShmemDestroy(rdata->psurfaces[jt]->image); - rdata->psurfaces[jt]->image=NULL; - SDL_free(rdata->psurfaces[jt]); - rdata->psurfaces[jt] = NULL; - } - } - break; - } - } - - /* Check if all required surfaces have been created */ - if (rdata->psurfaces[0]!=NULL) - { - rdata->surfaces_type=SDL_PHOTON_SURFTYPE_PHIMAGE; - } - else - { - rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN; - } - } - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - { - /* do nothing with surface allocation */ - rdata->surfaces_type=SDL_PHOTON_SURFTYPE_UNKNOWN; - } - break; - } - - /* Check if one of two allocation scheme was successful */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: primary surface(s) allocation failure"); - return -1; - } - - /* Store current surface dimensions */ - rdata->window_width=window->w; - rdata->window_height=window->h; - - /* If current copy/flip scheme is single buffer, then set initial parameters */ - if ((renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)==SDL_RENDERER_SINGLEBUFFER) - { - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 0; - } - - /* If current copy/flip scheme is double buffer, then set initial parameters */ - if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2)==SDL_RENDERER_PRESENTFLIP2) - { - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 1; - } - - /* If current copy/flip scheme is triple buffer, then set initial parameters */ - if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3)==SDL_RENDERER_PRESENTFLIP3) - { - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 1; - } - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgSetGCCx(rdata->osurfaces[rdata->surface_render_idx], rdata->gc); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PgSetGCCx(rdata->pcontexts[rdata->surface_render_idx], rdata->gc); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - break; - } - - return 0; -} - -int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_Window *window = window=SDL_GetWindowFromID(renderer->window); - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhPoint_t src_point; - - /* If currently single buffer is in use, we have to flush all data */ - if (rdata->surface_render_idx==rdata->surface_visible_idx) - { - /* Flush all undrawn graphics data to surface */ - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgFlushCx(rdata->osurfaces[rdata->surface_visible_idx]); - PgWaitHWIdle(); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PmMemFlush(rdata->pcontexts[rdata->surface_visible_idx], rdata->psurfaces[rdata->surface_visible_idx]); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - return; - } - } - - PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); - - src_point.x = rect->ul.x; - src_point.y = rect->ul.y; - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgContextBlit(rdata->osurfaces[rdata->surface_visible_idx], rect, NULL, rect); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PgDrawPhImageRectv(&src_point, rdata->psurfaces[rdata->surface_visible_idx], rect, 0); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - break; - } -} - -int _photon_set_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t globalalpha, uint32_t blendsource) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Switch on requested graphics context modifiers */ - switch (blendmode) - { - case SDL_BLENDMODE_MASK: - /* Enable and set chroma key */ - if (blendsource==SDL_PHOTON_TEXTURE_BLEND) - { - PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); - PgChromaOnCx(rdata->gc); - } - break; - case SDL_BLENDMODE_BLEND: - /* Enable and set chroma key and alpha blending */ - if (blendsource==SDL_PHOTON_TEXTURE_BLEND) - { - PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); - PgChromaOnCx(rdata->gc); - } - PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1mAs, NULL, NULL, globalalpha, 0); - PgAlphaOnCx(rdata->gc); - break; - case SDL_BLENDMODE_ADD: - /* Enable and set chroma key and alpha blending */ - if (blendsource==SDL_PHOTON_TEXTURE_BLEND) - { - PgSetChromaCx(rdata->gc, PgRGB(255, 255, 255), Pg_CHROMA_SRC_MATCH | Pg_CHROMA_NODRAW); - PgChromaOnCx(rdata->gc); - } - PgSetAlphaCx(rdata->gc, Pg_ALPHA_OP_SRC_GLOBAL | Pg_BLEND_SRC_As | Pg_BLEND_DST_1, NULL, NULL, globalalpha, 0); - PgAlphaOnCx(rdata->gc); - break; - case SDL_BLENDMODE_MOD: - /* Enable and set alpha blending */ - PgSetAlphaCx(rdata->gc, Pg_BLEND_SRC_0 | Pg_BLEND_DST_S, NULL, NULL, 0, 0); - PgAlphaOnCx(rdata->gc); - break; - case SDL_BLENDMODE_NONE: - /* Do nothing */ - break; - default: - return -1; - } - - return 0; -} - -int _photon_reset_blending(SDL_Renderer* renderer, uint32_t blendmode, uint32_t blendsource) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Switch off graphics context modifiers */ - switch (blendmode) - { - case SDL_BLENDMODE_MASK: - /* Disable chroma key */ - if (blendsource==SDL_PHOTON_TEXTURE_BLEND) - { - PgChromaOffCx(rdata->gc); - } - break; - case SDL_BLENDMODE_BLEND: - /* Disable chroma key and alpha blending */ - if (blendsource==SDL_PHOTON_TEXTURE_BLEND) - { - PgChromaOffCx(rdata->gc); - } - PgAlphaOffCx(rdata->gc); - break; - case SDL_BLENDMODE_ADD: - /* Disable chroma key and alpha blending */ - if (blendsource==SDL_PHOTON_TEXTURE_BLEND) - { - PgChromaOffCx(rdata->gc); - } - PgAlphaOffCx(rdata->gc); - break; - case SDL_BLENDMODE_MOD: - /* Disable chroma key and alpha blending */ - PgAlphaOffCx(rdata->gc); - break; - case SDL_BLENDMODE_NONE: - /* Do nothing */ - break; - default: - return -1; - } - - return 0; -} - -/****************************************************************************/ -/* SDL render interface */ -/****************************************************************************/ - -static int -photon_activaterenderer(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata; - - if ((rdata->window_width!=window->w) || (rdata->window_height!=window->h)) - { - return _photon_recreate_surfaces(renderer); - } - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgSetGCCx(rdata->osurfaces[rdata->surface_render_idx], rdata->gc); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PgSetGCCx(rdata->pcontexts[rdata->surface_render_idx], rdata->gc); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - break; - } - - return 0; -} - -static int -photon_displaymodechanged(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = window->display; - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - - /* Copy direct_mode status */ - rdata->direct_mode=didata->direct_mode; - - /* Update the surfaces */ - return _photon_recreate_surfaces(renderer); -} - -static int -photon_createtexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = window->display; - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - SDL_TextureData *tdata = NULL; - uint32_t it; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't create texture for OpenGL ES window"); - return -1; - } - - /* Check if requested texture format is supported */ - for (it=0; itinfo.num_texture_formats; it++) - { - if (renderer->info.texture_formats[it]==texture->format) - { - break; - } - } - if (it==renderer->info.num_texture_formats) - { - SDL_SetError("Photon: requested texture format is not supported"); - return -1; - } - - /* Allocate texture driver data */ - tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData)); - if (tdata == NULL) { - SDL_OutOfMemory(); - return -1; - } - - /* Set texture driver data */ - texture->driverdata = tdata; - - /* Try offscreen allocation only in case if displayable buffers are also offscreen */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_OFFSCREEN) - { - /* Try to allocate offscreen memory first */ - tdata->osurface=PdCreateOffscreenContext(0, texture->w, texture->h, - Pg_OSC_MEM_LINEAR_ACCESSIBLE | Pg_OSC_MEM_PAGE_ALIGN | - /* in case if 2D acceleration is available use it */ - Pg_OSC_MEM_2D_WRITABLE | Pg_OSC_MEM_2D_READABLE); - } - - /* Check if offscreen allocation has been failed or not performed */ - if (tdata->osurface==NULL) - { - PhPoint_t translation={0, 0}; - PhDim_t dimension={texture->w, texture->h}; - uint32_t image_pfmt=photon_sdl_to_image_pixelformat(didata->current_mode.format); - - /* Allocate photon image */ - if (image_pfmt==Pg_IMAGE_PALETTE_BYTE) - { - tdata->psurface=PhCreateImage(NULL, texture->w, texture->h, - image_pfmt, NULL, 256, 1); - } - else - { - tdata->psurface=PhCreateImage(NULL, texture->w, texture->h, - image_pfmt, NULL, 0, 1); - } - - if (tdata->psurface==NULL) - { - return -1; - } - - /* Create memory context for PhImage_t */ - tdata->pcontext=PmMemCreateMC(tdata->psurface, &dimension, &translation); - if (tdata->pcontext==NULL) - { - /* Destroy PhImage */ - if (tdata->psurface!=NULL) - { - if (tdata->psurface->palette!=NULL) - { - SDL_free(tdata->psurface->palette); - tdata->psurface->palette=NULL; - } - /* Destroy shared memory for PhImage_t */ - PgShmemDestroy(tdata->psurface->image); - tdata->psurface->image=NULL; - SDL_free(tdata->psurface); - tdata->psurface=NULL; - } - } - tdata->surface_type=SDL_PHOTON_SURFTYPE_PHIMAGE; - } - else - { - tdata->surface_type=SDL_PHOTON_SURFTYPE_OFFSCREEN; - } - - return 0; -} - -static int -photon_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't query texture pixels for OpenGL ES window"); - return -1; - } - - /* Clear outcoming parameters */ - *pixels=NULL; - *pitch=0; - - switch (tdata->surface_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - *pixels=(void*)PdGetOffscreenContextPtr(tdata->osurface); - *pitch=tdata->osurface->pitch; - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - *pixels=(void*)tdata->psurface->image; - *pitch=tdata->psurface->bpl; - break; - default: - break; - } - - return 0; -} - -static int -photon_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't set texture palette for OpenGL ES window"); - return -1; - } - - if (texture->format!=SDL_PIXELFORMAT_INDEX8) - { - SDL_SetError("Photon: can't set palette for non-paletted texture"); - return -1; - } - - SDL_Unsupported(); - return -1; -} - -static int -photon_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, int ncolors) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't return texture palette for OpenGL ES window"); - return -1; - } - - if (texture->format!=SDL_PIXELFORMAT_INDEX8) - { - SDL_SetError("Photon: can't return palette for non-paletted texture"); - return -1; - } - - SDL_Unsupported(); - return -1; -} - -static int -photon_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_Unsupported(); - return -1; -} - -static int -photon_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window"); - return -1; - } - - /* Check if current renderer instance supports alpha modulation */ - if ((renderer->info.mod_modes & SDL_TEXTUREMODULATE_ALPHA)!=SDL_TEXTUREMODULATE_ALPHA) - { - SDL_Unsupported(); - return -1; - } - - return 0; -} - -static int -photon_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window"); - return -1; - } - - switch (texture->blendMode) - { - case SDL_BLENDMODE_NONE: - case SDL_BLENDMODE_MASK: - case SDL_BLENDMODE_BLEND: - case SDL_BLENDMODE_ADD: - case SDL_BLENDMODE_MOD: - return 0; - default: - SDL_Unsupported(); - texture->blendMode = SDL_BLENDMODE_NONE; - return -1; - } -} - -static int -photon_settexturescalemode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - switch (texture->scaleMode) - { - case SDL_SCALEMODE_NONE: - return 0; - case SDL_SCALEMODE_FAST: - if ((renderer->info.scale_modes & SDL_SCALEMODE_FAST)==SDL_SCALEMODE_FAST) - { - return 0; - } - else - { - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_FAST; - return -1; - } - break; - case SDL_SCALEMODE_SLOW: - if ((renderer->info.scale_modes & SDL_SCALEMODE_SLOW)==SDL_SCALEMODE_SLOW) - { - return 0; - } - else - { - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_SLOW; - return -1; - } - break; - case SDL_SCALEMODE_BEST: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_SLOW; - return -1; - default: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_NONE; - return -1; - } - - SDL_Unsupported(); - return -1; -} - -static int -photon_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; - - uint8_t* src=(uint8_t*)pixels; - uint8_t* dst; - uint32_t dst_pitch; - uint32_t it; - uint32_t copy_length; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't update texture for OpenGL ES window"); - return -1; - } - - switch (tdata->surface_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - dst=(uint8_t*)PdGetOffscreenContextPtr(tdata->osurface); - dst_pitch=tdata->osurface->pitch; - if (dst==NULL) - { - SDL_SetError("Photon: can't get pointer to texture surface"); - return -1; - } - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - dst=(uint8_t*)tdata->psurface->image; - dst_pitch=tdata->psurface->bpl; - if (dst==NULL) - { - SDL_SetError("Photon: can't get pointer to texture surface"); - return -1; - } - break; - default: - SDL_SetError("Photon: invalid internal surface type"); - return -1; - } - - dst+=rect->y * dst_pitch + rect->x * SDL_BYTESPERPIXEL(texture->format); - copy_length=rect->w * SDL_BYTESPERPIXEL(texture->format); - for (it = 0; it < rect->h; it++) - { - SDL_memcpy(dst, src, copy_length); - src+=pitch; - dst+=dst_pitch; - } - - return 0; -} - -static int -photon_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't lock texture for OpenGL ES window"); - return -1; - } - - /* Clear outcoming parameters */ - *pixels=NULL; - *pitch=0; - - switch (tdata->surface_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - *pixels=(void*)((uint8_t*)PdGetOffscreenContextPtr(tdata->osurface) + - rect->y * tdata->osurface->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch=tdata->osurface->pitch; - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - *pixels=(void*)((uint8_t*)tdata->psurface->image + - rect->y * tdata->osurface->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch=tdata->psurface->bpl; - break; - default: - break; - } - - return 0; -} - -static void -photon_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't unlock texture for OpenGL ES window"); - return; - } -} - -static void -photon_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't update dirty texture for OpenGL ES window"); - return; - } -} - -static int -photon_setdrawcolor(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't set draw color for OpenGL ES window"); - return -1; - } - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PgSetFillColorCx(rdata->gc, PgRGB(renderer->r, renderer->g, renderer->b)); - PgSetStrokeColorCx(rdata->gc, PgRGB(renderer->r, renderer->g, renderer->b)); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - break; - } - - return 0; -} - -static int -photon_setdrawblendmode(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't set texture blend mode for OpenGL ES window"); - return -1; - } - - switch (renderer->blendMode) - { - case SDL_BLENDMODE_NONE: - case SDL_BLENDMODE_MASK: - case SDL_BLENDMODE_BLEND: - case SDL_BLENDMODE_ADD: - case SDL_BLENDMODE_MOD: - return 0; - default: - SDL_Unsupported(); - renderer->blendMode = SDL_BLENDMODE_NONE; - return -1; - } - - return 0; -} - -static int -photon_renderpoint(SDL_Renderer * renderer, int x, int y) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't render point in OpenGL ES window"); - return -1; - } - - /* Enable blending, if requested */ - _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND); - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgDrawIPixelCx(rdata->osurfaces[rdata->surface_render_idx], x, y); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PgDrawIPixelCx(rdata->pcontexts[rdata->surface_render_idx], x, y); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - break; - } - - /* Disable blending, if it was enabled */ - _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND); - - return 0; -} - -static int -photon_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't render line in OpenGL ES window"); - return -1; - } - - /* Enable blending, if requested */ - _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND); - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgDrawILineCx(rdata->osurfaces[rdata->surface_render_idx], x1, y1, x2, y2); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PgDrawILineCx(rdata->pcontexts[rdata->surface_render_idx], x1, y1, x2, y2); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - break; - } - - /* Disable blending, if it was enabled */ - _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND); - - return 0; -} - -static int -photon_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't render filled box in OpenGL ES window"); - return -1; - } - - /* Enable blending, if requested */ - _photon_set_blending(renderer, renderer->blendMode, renderer->a, SDL_PHOTON_DRAW_BLEND); - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgDrawIRectCx(rdata->osurfaces[rdata->surface_render_idx], rect->x, rect->y, rect->w+rect->x-1, rect->h+rect->y-1, Pg_DRAW_FILL); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PgDrawIRectCx(rdata->pcontexts[rdata->surface_render_idx], rect->x, rect->y, rect->w+rect->x-1, rect->h+rect->y-1, Pg_DRAW_FILL); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - break; - } - - /* Disable blending, if it was enabled */ - _photon_reset_blending(renderer, renderer->blendMode, SDL_PHOTON_DRAW_BLEND); - - return 0; -} - -static int -photon_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; - - PhRect_t src_rect; - PhRect_t dst_rect; - PhPoint_t dst_point; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't blit textures in OpenGL ES window"); - return -1; - } - - _photon_set_blending(renderer, texture->blendMode, texture->a, SDL_PHOTON_TEXTURE_BLEND); - - /* Set source blit area */ - src_rect.ul.x = srcrect->x; - src_rect.ul.y = srcrect->y; - src_rect.lr.x = srcrect->x + srcrect->w - 1; - src_rect.lr.y = srcrect->y + srcrect->h - 1; - - /* Set destination blit area */ - dst_rect.ul.x = dstrect->x; - dst_rect.ul.y = dstrect->y; - dst_rect.lr.x = dstrect->x + dstrect->w - 1; - dst_rect.lr.y = dstrect->y + dstrect->h - 1; - - /* Set destination point */ - dst_point.x = dstrect->x; - dst_point.y = dstrect->y; - - /* Do blit */ - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - /* two possible combinations */ - switch (tdata->surface_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - /* easiest full accelerated combination: offscreen->offscreen */ - PgContextBlitCx(rdata->osurfaces[rdata->surface_render_idx], tdata->osurface, - &src_rect, rdata->osurfaces[rdata->surface_render_idx], &dst_rect); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - /* not accelerated combination: PhImage->offscreen */ - /* scaling is not supported in this method */ - PgDrawPhImageRectCxv(rdata->osurfaces[rdata->surface_render_idx], &dst_point, - tdata->psurface, &src_rect, 0); - break; - default: - break; - } - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - /* two possible combinations */ - switch (tdata->surface_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - /* not supported combination: offscreen->PhImage */ - return -1; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - /* not accelerated combination, but fast: PhImage->PhImage */ - /* scaling is not supported in this method */ - PgDrawPhImageRectCxv(rdata->pcontexts[rdata->surface_render_idx], &dst_point, tdata->psurface, &src_rect, 0); - break; - default: - break; - } - break; - } - - _photon_reset_blending(renderer, texture->blendMode, SDL_PHOTON_TEXTURE_BLEND); - - return 0; -} - -static void -photon_renderpresent(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_Window *window = window=SDL_GetWindowFromID(renderer->window); - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - PhRect_t src_rect; - PhPoint_t src_point; - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't render present for OpenGL ES window"); - return; - } - - /* Flush all undrawn graphics data to surface */ - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]); - PgWaitHWIdle(); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - return; - } - - PgFFlush(Ph_START_DRAW); - PgSetRegionCx(PhDCGetCurrent(), PtWidgetRid(wdata->window)); - - /* Set blit area */ - src_rect.ul.x = 0; - src_rect.ul.y = 0; - src_rect.lr.x = rdata->window_width - 1; - src_rect.lr.y = rdata->window_height - 1; - - src_point.x = 0; - src_point.y = 0; - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgContextBlit(rdata->osurfaces[rdata->surface_render_idx], &src_rect, NULL, &src_rect); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PgDrawPhImagev(&src_point, rdata->psurfaces[rdata->surface_render_idx], 0); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - break; - } - - /* finish blit */ - PgFFlush(Ph_DONE_DRAW); - PgWaitHWIdle(); - - /* Check if we are using double buffering */ - if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) - { - rdata->surface_visible_idx=rdata->surface_render_idx; - rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 2; - } - - /* Check if we are using triple buffering */ - if ((renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) == SDL_RENDERER_PRESENTFLIP3) - { - rdata->surface_visible_idx=rdata->surface_render_idx; - rdata->surface_render_idx=(rdata->surface_render_idx + 1) % 3; - } -} - -static void -photon_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_TextureData* tdata=(SDL_TextureData*)texture->driverdata; - - /* Check if partially created texture must be destroyed */ - if (tdata==NULL) - { - return; - } - - /* Check, if it is not initialized */ - if (rdata->surfaces_type==SDL_PHOTON_SURFTYPE_UNKNOWN) - { - SDL_SetError("Photon: can't destroy texture for OpenGL ES window"); - return; - } - - switch (tdata->surface_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - if (tdata->osurface!=NULL) - { - PhDCRelease(tdata->osurface); - tdata->osurface = NULL; - } - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - if (tdata->pcontext!=NULL) - { - PmMemReleaseMC(tdata->pcontext); - tdata->pcontext=NULL; - } - - if (tdata->psurface!=NULL) - { - if (tdata->psurface->palette!=NULL) - { - SDL_free(tdata->psurface->palette); - tdata->psurface->palette=NULL; - } - /* Destroy shared memory for PhImage_t */ - PgShmemDestroy(tdata->psurface->image); - tdata->psurface->image=NULL; - SDL_free(tdata->psurface); - tdata->psurface=NULL; - } - break; - default: - break; - } -} - -static void -photon_destroyrenderer(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_WindowData *wdata = (SDL_WindowData *)window->driverdata; - uint32_t it; - - /* Before destroying the renderer, be sure, that rendering was completed */ - PgFlush(); - PgWaitHWIdle(); - - /* Destroy graphics context */ - if (rdata->gc!=NULL) - { - PgDestroyGC(rdata->gc); - rdata->gc=NULL; - } - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - { - /* Destroy current surfaces */ - for (it=0; itosurfaces[it] != NULL) - { - PhDCRelease(rdata->osurfaces[it]); - rdata->osurfaces[it] = NULL; - } - } - } - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - { - /* Destroy current surfaces */ - for (it=0; itpcontexts[it]!=NULL) - { - PmMemReleaseMC(rdata->pcontexts[it]); - rdata->pcontexts[it]=NULL; - } - if (rdata->psurfaces[it]!=NULL) - { - if (rdata->psurfaces[it]->palette!=NULL) - { - SDL_free(rdata->psurfaces[it]->palette); - rdata->psurfaces[it]->palette=NULL; - } - /* Destroy shared memory for PhImage_t */ - PgShmemDestroy(rdata->psurfaces[it]->image); - rdata->psurfaces[it]->image=NULL; - SDL_free(rdata->psurfaces[it]); - rdata->psurfaces[it]=NULL; - } - } - } - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - { - /* nothing to do */ - } - break; - } -} - -static int -photon_renderreadpixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) -{ - SDL_RenderData *rdata = (SDL_RenderData *)renderer->driverdata; - Uint32 sformat=0; - uint8_t* spixels=NULL; - unsigned int spitch=0; - - /* Flush all undrawn graphics data to surface */ - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]); - PgWaitHWIdle(); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - return; - } - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format); - spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]); - spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch; - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type); - spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image; - spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl; - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - SDL_SetError("Photon: surfaces are not initialized"); - return -1; - } - - /* Adjust surface pixels pointer to the rectangle coordinates */ - spixels+=rect->y*spitch + rect->x*SDL_BYTESPERPIXEL(sformat); - - SDL_ConvertPixels(rect->w, rect->h, - sformat, spixels, spitch, - format, pixels, pitch); - - return 0; -} - -static int -photon_renderwritepixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch) -{ - SDL_RenderData *rdata = (SDL_RenderData *)renderer->driverdata; - Uint32 sformat=0; - uint8_t* spixels=NULL; - unsigned int spitch=0; - - /* Flush all undrawn graphics data to surface */ - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - PgFlushCx(rdata->osurfaces[rdata->surface_render_idx]); - PgWaitHWIdle(); - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - PmMemFlush(rdata->pcontexts[rdata->surface_render_idx], rdata->psurfaces[rdata->surface_render_idx]); - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - return; - } - - switch (rdata->surfaces_type) - { - case SDL_PHOTON_SURFTYPE_OFFSCREEN: - sformat=photon_image_to_sdl_pixelformat(rdata->osurfaces[rdata->surface_render_idx]->format); - spixels=(uint8_t*)PdGetOffscreenContextPtr(rdata->osurfaces[rdata->surface_render_idx]); - spitch=rdata->osurfaces[rdata->surface_render_idx]->pitch; - break; - case SDL_PHOTON_SURFTYPE_PHIMAGE: - sformat=photon_image_to_sdl_pixelformat(rdata->psurfaces[rdata->surface_render_idx]->type); - spixels=(uint8_t*)rdata->psurfaces[rdata->surface_render_idx]->image; - spitch=rdata->psurfaces[rdata->surface_render_idx]->bpl; - break; - case SDL_PHOTON_SURFTYPE_UNKNOWN: - default: - SDL_SetError("Photon: surfaces are not initialized"); - return -1; - } - - /* Adjust surface pixels pointer to the rectangle coordinates */ - spixels+=rect->y*spitch + rect->x*SDL_BYTESPERPIXEL(sformat); - - SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch, - sformat, spixels, spitch); - - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/photon/SDL_photon_render.h b/project/jni/sdl-1.3/src/video/photon/SDL_photon_render.h deleted file mode 100644 index b277c6c7f..000000000 --- a/project/jni/sdl-1.3/src/video/photon/SDL_photon_render.h +++ /dev/null @@ -1,76 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Photon GUI SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_PHOTON_RENDER_H__ -#define __SDL_PHOTON_RENDER_H__ - -#include "../SDL_sysvideo.h" - -#include -#include - -#define SDL_PHOTON_MAX_SURFACES 3 - -#define SDL_PHOTON_SURFTYPE_UNKNOWN 0x00000000 -#define SDL_PHOTON_SURFTYPE_OFFSCREEN 0x00000001 -#define SDL_PHOTON_SURFTYPE_PHIMAGE 0x00000002 - -#define SDL_PHOTON_UNKNOWN_BLEND 0x00000000 -#define SDL_PHOTON_DRAW_BLEND 0x00000001 -#define SDL_PHOTON_TEXTURE_BLEND 0x00000002 - -typedef struct SDL_RenderData -{ - SDL_bool enable_vsync; /* VSYNC flip synchronization enable */ - uint32_t surface_visible_idx; /* Index of visible surface */ - uint32_t surface_render_idx; /* Index of render surface */ - uint32_t surfaces_count; /* Amount of allocated surfaces */ - uint32_t surfaces_type; /* Type of allocated surfaces */ - uint32_t window_width; /* Last active window width */ - uint32_t window_height; /* Last active window height */ - PhGC_t* gc; /* Graphics context */ - SDL_bool direct_mode; /* Direct Mode state */ - PdOffscreenContext_t* osurfaces[SDL_PHOTON_MAX_SURFACES]; - PhImage_t* psurfaces[SDL_PHOTON_MAX_SURFACES]; - PmMemoryContext_t* pcontexts[SDL_PHOTON_MAX_SURFACES]; -} SDL_RenderData; - -typedef struct SDL_TextureData -{ - uint32_t surface_type; - PdOffscreenContext_t* osurface; - PhImage_t* psurface; - PmMemoryContext_t* pcontext; -} SDL_TextureData; - -extern void photon_addrenderdriver(_THIS); - -/* Helper function, which redraws the backbuffer */ -int _photon_update_rectangles(SDL_Renderer* renderer, PhRect_t* rect); - -#endif /* __SDL_PHOTON_RENDER_H__ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3events.c b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3events.c deleted file mode 100644 index 6b9f080c4..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3events.c +++ /dev/null @@ -1,36 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" - -#include "SDL_ps3video.h" -#include "SDL_ps3events_c.h" - -void -PS3_PumpEvents(_THIS) -{ - /* do nothing. */ -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3events_c.h b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3events_c.h deleted file mode 100644 index 2fe3b4c36..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3events_c.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_ps3video.h" - -extern void PS3_PumpEvents(_THIS); - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3modes.c b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3modes.c deleted file mode 100644 index 7e81bc785..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3modes.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_ps3video.h" - -void -PS3_InitModes(_THIS) -{ - deprintf(1, "+PS3_InitModes()\n"); - SDL_VideoDisplay display; - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_DisplayMode mode; - PS3_DisplayModeData *modedata; - unsigned long vid = 0; - - modedata = (PS3_DisplayModeData *) SDL_malloc(sizeof(*modedata)); - if (!modedata) { - return; - } - - /* Setting up the DisplayMode based on current settings */ - struct ps3fb_ioctl_res res; - if (ioctl(data->fbdev, PS3FB_IOCTL_SCREENINFO, &res)) { - SDL_SetError("Can't get PS3FB_IOCTL_SCREENINFO"); - } - mode.format = SDL_PIXELFORMAT_RGB888; - mode.refresh_rate = 0; - mode.w = res.xres; - mode.h = res.yres; - - /* Setting up driver specific mode data, - * Get the current ps3 specific videmode number */ - if (ioctl(data->fbdev, PS3FB_IOCTL_GETMODE, (unsigned long)&vid)) { - SDL_SetError("Can't get PS3FB_IOCTL_GETMODE"); - } - deprintf(2, "PS3FB_IOCTL_GETMODE = %u\n", vid); - modedata->mode = vid; - mode.driverdata = modedata; - - /* Set display's videomode and add it */ - SDL_zero(display); - display.desktop_mode = mode; - display.current_mode = mode; - - SDL_AddVideoDisplay(&display); - deprintf(1, "-PS3_InitModes()\n"); -} - -/* DisplayModes available on the PS3 */ -static SDL_DisplayMode ps3fb_modedb[] = { - /* VESA */ - {SDL_PIXELFORMAT_RGB888, 1280, 768, 0, NULL}, // WXGA - {SDL_PIXELFORMAT_RGB888, 1280, 1024, 0, NULL}, // SXGA - {SDL_PIXELFORMAT_RGB888, 1920, 1200, 0, NULL}, // WUXGA - /* Native resolutions (progressive, "fullscreen") */ - {SDL_PIXELFORMAT_RGB888, 720, 480, 0, NULL}, // 480p - {SDL_PIXELFORMAT_RGB888, 1280, 720, 0, NULL}, // 720p - {SDL_PIXELFORMAT_RGB888, 1920, 1080, 0, NULL} // 1080p -}; - -/* PS3 videomode number according to ps3fb_modedb */ -static PS3_DisplayModeData ps3fb_data[] = { - {11}, {12}, {13}, {130}, {131}, {133}, -}; - -void -PS3_GetDisplayModes(_THIS, SDL_VideoDisplay * display) -{ - deprintf(1, "+PS3_GetDisplayModes()\n"); - SDL_DisplayMode mode; - unsigned int nummodes; - - nummodes = sizeof(ps3fb_modedb) / sizeof(SDL_DisplayMode); - - int n; - for (n=0; ndriverdata; - PS3_DisplayModeData *dispdata = (PS3_DisplayModeData *) mode->driverdata; - - /* Set the new DisplayMode */ - deprintf(2, "Setting PS3FB_MODE to %u\n", dispdata->mode); - if (ioctl(data->fbdev, PS3FB_IOCTL_SETMODE, (unsigned long)&dispdata->mode)) { - deprintf(2, "Could not set PS3FB_MODE\n"); - SDL_SetError("Could not set PS3FB_MODE\n"); - return -1; - } - - deprintf(1, "-PS3_SetDisplayMode()\n"); - return 0; -} - -void -PS3_QuitModes(_THIS) -{ - deprintf(1, "+PS3_QuitModes()\n"); - - /* There was no mem allocated for driverdata */ - int i, j; - for (i = 0; i < SDL_GetNumVideoDisplays(); ++i) { - SDL_VideoDisplay *display = SDL_GetVideoDisplay(i); - for (j = display->num_display_modes; j--;) { - display->display_modes[j].driverdata = NULL; - } - } - - deprintf(1, "-PS3_QuitModes()\n"); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3modes_c.h b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3modes_c.h deleted file mode 100644 index 4d7cf4caf..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3modes_c.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_ps3modes_h -#define _SDL_ps3modes_h - -extern void PS3_InitModes(_THIS); -extern void PS3_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -extern int PS3_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); -extern void PS3_QuitModes(_THIS); - -#endif /* SDL_ps3modes_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3render.c b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3render.c deleted file mode 100644 index d30a943db..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3render.c +++ /dev/null @@ -1,747 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" -#include "../SDL_sysvideo.h" -#include "../SDL_yuv_sw_c.h" -#include "../SDL_renderer_sw.h" - -#include "SDL_ps3video.h" -#include "SDL_ps3spe_c.h" - -#include -#include -#include -#include -#include -#include -#include - - -/* Stores the executable name */ -extern spe_program_handle_t yuv2rgb_spu; -extern spe_program_handle_t bilin_scaler_spu; - -/* SDL surface based renderer implementation */ -static SDL_Renderer *SDL_PS3_CreateRenderer(SDL_Window * window, - Uint32 flags); -static int SDL_PS3_DisplayModeChanged(SDL_Renderer * renderer); -static int SDL_PS3_ActivateRenderer(SDL_Renderer * renderer); -static int SDL_PS3_RenderPoint(SDL_Renderer * renderer, int x, int y); -static int SDL_PS3_RenderLine(SDL_Renderer * renderer, int x1, int y1, - int x2, int y2); -static int SDL_PS3_RenderFill(SDL_Renderer * renderer, - const SDL_Rect * rect); -static int SDL_PS3_RenderCopy(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_Rect * dstrect); -static void SDL_PS3_RenderPresent(SDL_Renderer * renderer); -static void SDL_PS3_DestroyRenderer(SDL_Renderer * renderer); - -/* Texture */ -static int PS3_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int PS3_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, void **pixels, int *pitch); -static int PS3_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, int pitch); -static int PS3_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, int markDirty, void **pixels, int *pitch); -static void PS3_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static void PS3_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture); - - -SDL_RenderDriver SDL_PS3_RenderDriver = { - SDL_PS3_CreateRenderer, - { - "ps3", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTVSYNC | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTDISCARD | - SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE), - (SDL_BLENDMODE_NONE), - /* We use bilinear scaling on the SPE for YV12 & IYUV - * (width and height % 8 = 0) */ - (SDL_SCALEMODE_SLOW) - } -}; - -typedef struct -{ - int current_screen; - SDL_Surface *screen; - SDL_VideoDisplay *display; - /* adress of the centered image in the framebuffer (double buffered) */ - uint8_t *center[2]; - - /* width of input (bounded by writeable width) */ - unsigned int bounded_width; - /* height of input (bounded by writeable height) */ - unsigned int bounded_height; - /* offset from the left side (used for centering) */ - unsigned int offset_left; - /* offset from the upper side (used for centering) */ - unsigned int offset_top; - /* width of screen which is writeable */ - unsigned int wr_width; - /* width of screen which is writeable */ - unsigned int wr_height; - /* size of a screen line: width * bpp/8 */ - unsigned int line_length; - - /* Is the kernels fb size bigger than ~12MB - * double buffering will work for 1080p */ - unsigned int double_buffering; - - /* SPE threading stuff */ - spu_data_t *converter_thread_data; - spu_data_t *scaler_thread_data; - - /* YUV converting transfer data */ - volatile struct yuv2rgb_parms_t * converter_parms __attribute__((aligned(128))); - /* Scaler transfer data */ - volatile struct scale_parms_t * scaler_parms __attribute__((aligned(128))); -} SDL_PS3_RenderData; - -typedef struct -{ - int pitch; - /* Image data */ - volatile void *pixels; - /* Use software renderer for not supported formats */ - SDL_SW_YUVTexture *yuv; -} PS3_TextureData; - -SDL_Renderer * -SDL_PS3_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - deprintf(1, "+SDL_PS3_CreateRenderer()\n"); - SDL_VideoDisplay *display = window->display; - SDL_DisplayMode *displayMode = &display->current_mode; - SDL_VideoData *devdata = display->device->driverdata; - SDL_Renderer *renderer; - SDL_PS3_RenderData *data; - struct ps3fb_ioctl_res res; - int i, n; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (!SDL_PixelFormatEnumToMasks - (displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown display format"); - return NULL; - } - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (SDL_PS3_RenderData *) SDL_malloc(sizeof(*data)); - if (!data) { - SDL_PS3_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - SDL_zerop(data); - - renderer->CreateTexture = PS3_CreateTexture; - renderer->DestroyTexture = PS3_DestroyTexture; - renderer->QueryTexturePixels = PS3_QueryTexturePixels; - renderer->UpdateTexture = PS3_UpdateTexture; - renderer->LockTexture = PS3_LockTexture; - renderer->UnlockTexture = PS3_UnlockTexture; - renderer->ActivateRenderer = SDL_PS3_ActivateRenderer; - renderer->DisplayModeChanged = SDL_PS3_DisplayModeChanged; - renderer->RenderPoint = SDL_PS3_RenderPoint; - renderer->RenderLine = SDL_PS3_RenderLine; - renderer->RenderFill = SDL_PS3_RenderFill; - renderer->RenderCopy = SDL_PS3_RenderCopy; - renderer->RenderPresent = SDL_PS3_RenderPresent; - renderer->DestroyRenderer = SDL_PS3_DestroyRenderer; - renderer->info.name = SDL_PS3_RenderDriver.info.name; - renderer->info.flags = 0; - renderer->window = window; - renderer->driverdata = data; - - deprintf(1, "window->w = %u\n", window->w); - deprintf(1, "window->h = %u\n", window->h); - - data->double_buffering = 0; - - /* Get ps3 screeninfo */ - if (ioctl(devdata->fbdev, PS3FB_IOCTL_SCREENINFO, (unsigned long)&res) < 0) { - SDL_SetError("[PS3] PS3FB_IOCTL_SCREENINFO failed"); - } - deprintf(2, "res.num_frames = %d\n", res.num_frames); - - /* Only use double buffering if enough fb memory is available */ - if (res.num_frames > 1) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; - n = 2; - data->double_buffering = 1; - } else { - renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; - n = 1; - } - - data->screen = - SDL_CreateRGBSurface(0, window->w, window->h, bpp, Rmask, Gmask, - Bmask, Amask); - if (!data->screen) { - SDL_PS3_DestroyRenderer(renderer); - return NULL; - } - /* Allocate aligned memory for pixels */ - SDL_free(data->screen->pixels); - data->screen->pixels = (void *)memalign(16, data->screen->h * data->screen->pitch); - if (!data->screen->pixels) { - SDL_FreeSurface(data->screen); - SDL_OutOfMemory(); - return NULL; - } - SDL_memset(data->screen->pixels, 0, data->screen->h * data->screen->pitch); - SDL_SetSurfacePalette(data->screen, display->palette); - - data->current_screen = 0; - - /* Create SPU parms structure */ - data->converter_parms = (struct yuv2rgb_parms_t *) memalign(16, sizeof(struct yuv2rgb_parms_t)); - data->scaler_parms = (struct scale_parms_t *) memalign(16, sizeof(struct scale_parms_t)); - if (data->converter_parms == NULL || data->scaler_parms == NULL) { - SDL_PS3_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - - /* Set up the SPE threading data */ - data->converter_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t)); - data->scaler_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t)); - if (data->converter_thread_data == NULL || data->scaler_thread_data == NULL) { - SDL_PS3_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - - /* Set up the SPE scaler (booted) */ - data->scaler_thread_data->program = bilin_scaler_spu; - data->scaler_thread_data->program_name = "bilin_scaler_spu"; - data->scaler_thread_data->keepalive = 0; - data->scaler_thread_data->booted = 0; - - /* Set up the SPE converter (always running) */ - data->converter_thread_data->program = yuv2rgb_spu; - data->converter_thread_data->program_name = "yuv2rgb_spu"; - data->converter_thread_data->keepalive = 1; - data->converter_thread_data->booted = 0; - - SPE_Start(data->converter_thread_data); - - deprintf(1, "-SDL_PS3_CreateRenderer()\n"); - return renderer; -} - -static int -SDL_PS3_ActivateRenderer(SDL_Renderer * renderer) -{ - deprintf(1, "+PS3_ActivateRenderer()\n"); - SDL_PS3_RenderData *data = (SDL_PS3_RenderData *) renderer->driverdata; - - deprintf(1, "-PS3_ActivateRenderer()\n"); - return 0; -} - -static int SDL_PS3_DisplayModeChanged(SDL_Renderer * renderer) { - deprintf(1, "+PS3_DisplayModeChanged()\n"); - SDL_PS3_RenderData *data = (SDL_PS3_RenderData *) renderer->driverdata; - - deprintf(1, "-PS3_DisplayModeChanged()\n"); - return 0; -} - -static int -PS3_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) { - deprintf(1, "+PS3_CreateTexture()\n"); - PS3_TextureData *data; - data = (PS3_TextureData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - SDL_OutOfMemory(); - return -1; - } - data->pitch = (texture->w * SDL_BYTESPERPIXEL(texture->format)); - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - /* Use SDLs SW_YUVTexture */ - data->yuv = - SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); - if (!data->yuv) { - SDL_OutOfMemory(); - return -1; - } - /* but align pixels */ - SDL_free(data->yuv->pixels); - data->yuv->pixels = (Uint8 *)memalign(16, texture->w * texture->h * 2); - if (!data->yuv->pixels) { - SDL_OutOfMemory(); - return -1; - } - - /* Redo: Find the pitch and offset values for the overlay */ - SDL_SW_YUVTexture *swdata = (SDL_SW_YUVTexture *) data->yuv; - switch (texture->format) { - case SDL_PIXELFORMAT_YV12: - case SDL_PIXELFORMAT_IYUV: - swdata->pitches[0] = texture->w; - swdata->pitches[1] = swdata->pitches[0] / 2; - swdata->pitches[2] = swdata->pitches[0] / 2; - swdata->planes[0] = swdata->pixels; - swdata->planes[1] = swdata->planes[0] + swdata->pitches[0] * texture->h; - swdata->planes[2] = swdata->planes[1] + swdata->pitches[1] * texture->h / 2; - break; - case SDL_PIXELFORMAT_YUY2: - case SDL_PIXELFORMAT_UYVY: - case SDL_PIXELFORMAT_YVYU: - swdata->pitches[0] = texture->w * 2; - swdata->planes[0] = swdata->pixels; - break; - default: - /* We should never get here (caught above) */ - break; - } - } else { - data->pixels = NULL; - data->pixels = SDL_malloc(texture->h * data->pitch); - if (!data->pixels) { - PS3_DestroyTexture(renderer, texture); - SDL_OutOfMemory(); - return -1; - } - } - texture->driverdata = data; - deprintf(1, "-PS3_CreateTexture()\n"); - return 0; -} - -static int -PS3_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - deprintf(1, "+PS3_QueryTexturePixels()\n"); - PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); - } else { - *pixels = (void *)data->pixels; - *pitch = data->pitch; - } - - deprintf(1, "-PS3_QueryTexturePixels()\n"); - return 0; -} - -static int -PS3_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - deprintf(1, "+PS3_UpdateTexture()\n"); - PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - return SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch); - } else { - Uint8 *src, *dst; - int row; - size_t length; - Uint8 *dstpixels; - - src = (Uint8 *) pixels; - dst = (Uint8 *) dstpixels + rect->y * data->pitch + rect->x - * SDL_BYTESPERPIXEL(texture->format); - length = rect->w * SDL_BYTESPERPIXEL(texture->format); - /* Update the texture */ - for (row = 0; row < rect->h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += data->pitch; - } - } - deprintf(1, "-PS3_UpdateTexture()\n"); - return 0; -} - -static int -PS3_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - deprintf(1, "+PS3_LockTexture()\n"); - PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - deprintf(1, "-PS3_LockTexture()\n"); - return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, pitch); - } else { - *pixels = - (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch = data->pitch; - deprintf(1, "-PS3_LockTexture()\n"); - return 0; - } -} - -static void -PS3_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - deprintf(1, "+PS3_UnlockTexture()\n"); - PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - SDL_SW_UnlockYUVTexture(data->yuv); - } - deprintf(1, "-PS3_UnlockTexture()\n"); -} - -static void -PS3_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - deprintf(1, "+PS3_DestroyTexture()\n"); - PS3_TextureData *data = (PS3_TextureData *) texture->driverdata; - - if (!data) { - return; - } - if (data->yuv) { - SDL_SW_DestroyYUVTexture(data->yuv); - } - if (data->pixels) { - SDL_free((void *)data->pixels); - } - deprintf(1, "-PS3_DestroyTexture()\n"); -} - -static int -SDL_PS3_RenderPoint(SDL_Renderer * renderer, int x, int y) -{ - SDL_PS3_RenderData *data = - (SDL_PS3_RenderData *) renderer->driverdata; - SDL_Surface *target = data->screen; - int status; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - Uint32 color = - SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, - renderer->a); - - status = SDL_DrawPoint(target, x, y, color); - } else { - status = - SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r, - renderer->g, renderer->b, renderer->a); - } - return status; -} - -static int -SDL_PS3_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) -{ - SDL_PS3_RenderData *data = - (SDL_PS3_RenderData *) renderer->driverdata; - SDL_Surface *target = data->screen; - int status; - - if (renderer->blendMode == SDL_BLENDMODE_NONE || - renderer->blendMode == SDL_BLENDMODE_MASK) { - Uint32 color = - SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, - renderer->a); - - status = SDL_DrawLine(target, x1, y1, x2, y2, color); - } else { - status = - SDL_BlendLine(target, x1, y1, x2, y2, renderer->blendMode, - renderer->r, renderer->g, renderer->b, renderer->a); - } - return status; -} - -static int -SDL_PS3_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) -{ - deprintf(1, "SDL_PS3_RenderFill()\n"); - SDL_PS3_RenderData *data = - (SDL_PS3_RenderData *) renderer->driverdata; - SDL_Surface *target = data->screen; - SDL_Rect real_rect = *rect; - int status; - - if (renderer->blendMode == SDL_BLENDMODE_NONE) { - Uint32 color = - SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b, - renderer->a); - - status = SDL_FillRect(target, &real_rect, color); - } else { - status = - SDL_BlendFillRect(target, &real_rect, renderer->blendMode, - renderer->r, renderer->g, renderer->b, - renderer->a); - } - return status; -} - -static int -SDL_PS3_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - deprintf(1, "+SDL_PS3_RenderCopy()\n"); - SDL_PS3_RenderData *data = - (SDL_PS3_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = window->display; - PS3_TextureData *txdata = (PS3_TextureData *) texture->driverdata; - SDL_VideoData *devdata = display->device->driverdata; - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - deprintf(1, "Texture is in a FOURCC format\n"); - if ((texture->format == SDL_PIXELFORMAT_YV12 || texture->format == SDL_PIXELFORMAT_IYUV) - && texture->w % 8 == 0 && texture->h % 8 == 0 - && dstrect->w % 8 == 0 && dstrect->h % 8 == 0) { - deprintf(1, "Use SPE for scaling/converting\n"); - - SDL_SW_YUVTexture *swdata = (SDL_SW_YUVTexture *) txdata->yuv; - Uint8 *lum, *Cr, *Cb; - Uint8 *scaler_out = NULL; - Uint8 *dstpixels; - switch (texture->format) { - case SDL_PIXELFORMAT_YV12: - lum = swdata->planes[0]; - Cr = swdata->planes[1]; - Cb = swdata->planes[2]; - break; - case SDL_PIXELFORMAT_IYUV: - lum = swdata->planes[0]; - Cr = swdata->planes[2]; - Cb = swdata->planes[1]; - break; - default: - /* We should never get here (caught above) */ - return -1; - } - - if (srcrect->w != dstrect->w || srcrect->h != dstrect->h) { - deprintf(1, "We need to scale the texture from %u x %u to %u x %u\n", - srcrect->w, srcrect->h, dstrect->w, dstrect->h); - /* Alloc mem for scaled YUV picture */ - scaler_out = (Uint8 *) memalign(16, dstrect->w * dstrect->h + ((dstrect->w * dstrect->h) >> 1)); - if (scaler_out == NULL) { - SDL_OutOfMemory(); - return -1; - } - - /* Set parms for scaling */ - data->scaler_parms->src_pixel_width = srcrect->w; - data->scaler_parms->src_pixel_height = srcrect->h; - data->scaler_parms->dst_pixel_width = dstrect->w; - data->scaler_parms->dst_pixel_height = dstrect->h; - data->scaler_parms->y_plane = lum; - data->scaler_parms->v_plane = Cr; - data->scaler_parms->u_plane = Cb; - data->scaler_parms->dstBuffer = scaler_out; - data->scaler_thread_data->argp = (void *)data->scaler_parms; - - /* Scale the YUV overlay to given size */ - SPE_Start(data->scaler_thread_data); - SPE_Stop(data->scaler_thread_data); - - /* Set parms for converting after scaling */ - data->converter_parms->y_plane = scaler_out; - data->converter_parms->v_plane = scaler_out + dstrect->w * dstrect->h; - data->converter_parms->u_plane = scaler_out + dstrect->w * dstrect->h + ((dstrect->w * dstrect->h) >> 2); - } else { - data->converter_parms->y_plane = lum; - data->converter_parms->v_plane = Cr; - data->converter_parms->u_plane = Cb; - } - - dstpixels = (Uint8 *) data->screen->pixels + dstrect->y * data->screen->pitch + dstrect->x - * SDL_BYTESPERPIXEL(texture->format); - data->converter_parms->src_pixel_width = dstrect->w; - data->converter_parms->src_pixel_height = dstrect->h; - data->converter_parms->dstBuffer = dstpixels/*(Uint8 *)data->screen->pixels*/; - data->converter_thread_data->argp = (void *)data->converter_parms; - - /* Convert YUV texture to RGB */ - SPE_SendMsg(data->converter_thread_data, SPU_START); - SPE_SendMsg(data->converter_thread_data, (unsigned int)data->converter_thread_data->argp); - - /* We can probably move that to RenderPresent() */ - SPE_WaitForMsg(data->converter_thread_data, SPU_FIN); - if (scaler_out) { - free(scaler_out); - } - } else { - deprintf(1, "Use software for scaling/converting\n"); - Uint8 *dst; - /* FIXME: Not good */ - dst = (Uint8 *) data->screen->pixels + dstrect->y * data->screen->pitch + dstrect->x - * SDL_BYTESPERPIXEL(texture->format); - return SDL_SW_CopyYUVToRGB(txdata->yuv, srcrect, display->current_mode.format, - dstrect->w, dstrect->h, dst/*data->screen->pixels*/, - data->screen->pitch); - } - } else { - deprintf(1, "SDL_ISPIXELFORMAT_FOURCC = false\n"); - - Uint8 *src, *dst; - int row; - size_t length; - Uint8 *dstpixels; - - src = (Uint8 *) txdata->pixels; - dst = (Uint8 *) data->screen->pixels + dstrect->y * data->screen->pitch + dstrect->x - * SDL_BYTESPERPIXEL(texture->format); - length = dstrect->w * SDL_BYTESPERPIXEL(texture->format); - for (row = 0; row < dstrect->h; ++row) { - SDL_memcpy(dst, src, length); - src += txdata->pitch; - dst += data->screen->pitch; - } - } - - deprintf(1, "-SDL_PS3_RenderCopy()\n"); - return 0; -} - -static void -SDL_PS3_RenderPresent(SDL_Renderer * renderer) -{ - deprintf(1, "+SDL_PS3_RenderPresent()\n"); - SDL_PS3_RenderData *data = - (SDL_PS3_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = window->display; - SDL_VideoData *devdata = display->device->driverdata; - - /* Send the data to the screen */ - /* Get screeninfo */ - struct fb_fix_screeninfo fb_finfo; - if (ioctl(devdata->fbdev, FBIOGET_FSCREENINFO, &fb_finfo)) { - SDL_SetError("[PS3] Can't get fixed screeninfo"); - } - struct fb_var_screeninfo fb_vinfo; - if (ioctl(devdata->fbdev, FBIOGET_VSCREENINFO, &fb_vinfo)) { - SDL_SetError("[PS3] Can't get VSCREENINFO"); - } - - /* 16 and 15 bpp is reported as 16 bpp */ - //txdata->bpp = fb_vinfo.bits_per_pixel; - //if (txdata->bpp == 16) - // txdata->bpp = fb_vinfo.red.length + fb_vinfo.green.length + fb_vinfo.blue.length; - - /* Adjust centering */ - data->bounded_width = window->w < fb_vinfo.xres ? window->w : fb_vinfo.xres; - data->bounded_height = window->h < fb_vinfo.yres ? window->h : fb_vinfo.yres; - /* We could use SDL's CENTERED flag for centering */ - data->offset_left = (fb_vinfo.xres - data->bounded_width) >> 1; - data->offset_top = (fb_vinfo.yres - data->bounded_height) >> 1; - data->center[0] = devdata->frame_buffer + data->offset_left * /*txdata->bpp/8*/ 4 + - data->offset_top * fb_finfo.line_length; - data->center[1] = data->center[0] + fb_vinfo.yres * fb_finfo.line_length; - - deprintf(1, "offset_left = %u\n", data->offset_left); - deprintf(1, "offset_top = %u\n", data->offset_top); - - /* Set SPU parms for copying the surface to framebuffer */ - devdata->fb_parms->data = (unsigned char *)data->screen->pixels; - devdata->fb_parms->center = data->center[data->current_screen]; - devdata->fb_parms->out_line_stride = fb_finfo.line_length; - devdata->fb_parms->in_line_stride = window->w * /*txdata->bpp / 8*/4; - devdata->fb_parms->bounded_input_height = data->bounded_height; - devdata->fb_parms->bounded_input_width = data->bounded_width; - //devdata->fb_parms->fb_pixel_size = txdata->bpp / 8; - devdata->fb_parms->fb_pixel_size = 4;//SDL_BYTESPERPIXEL(window->format); - - deprintf(3, "[PS3->SPU] fb_thread_data->argp = 0x%x\n", devdata->fb_thread_data->argp); - - /* Copying.. */ - SPE_SendMsg(devdata->fb_thread_data, SPU_START); - SPE_SendMsg(devdata->fb_thread_data, (unsigned int)devdata->fb_thread_data->argp); - - SPE_WaitForMsg(devdata->fb_thread_data, SPU_FIN); - - /* Wait for vsync */ - if (renderer->info.flags & SDL_RENDERER_PRESENTVSYNC) { - unsigned long crt = 0; - deprintf(1, "[PS3] Wait for vsync\n"); - ioctl(devdata->fbdev, FBIO_WAITFORVSYNC, &crt); - } - - /* Page flip */ - deprintf(1, "[PS3] Page flip to buffer #%u 0x%x\n", data->current_screen, data->center[data->current_screen]); - ioctl(devdata->fbdev, PS3FB_IOCTL_FSEL, (unsigned long)&data->current_screen); - - /* Update the flipping chain, if any */ - if (data->double_buffering) { - data->current_screen = (data->current_screen + 1) % 2; - } - deprintf(1, "-SDL_PS3_RenderPresent()\n"); -} - -static void -SDL_PS3_DestroyRenderer(SDL_Renderer * renderer) -{ - deprintf(1, "+SDL_PS3_DestroyRenderer()\n"); - SDL_PS3_RenderData *data = - (SDL_PS3_RenderData *) renderer->driverdata; - int i; - - if (data) { - for (i = 0; i < SDL_arraysize(data->screen); ++i) { - if (data->screen) { - SDL_FreeSurface(data->screen); - } - } - - /* Shutdown SPE and release related resources */ - if (data->scaler_thread_data) { - free((void *)data->scaler_thread_data); - } - if (data->scaler_parms) { - free((void *)data->scaler_parms); - } - if (data->converter_thread_data) { - SPE_Shutdown(data->converter_thread_data); - free((void *)data->converter_thread_data); - } - if (data->converter_parms) { - free((void *)data->converter_parms); - } - - SDL_free(data); - } - SDL_free(renderer); - deprintf(1, "-SDL_PS3_DestroyRenderer()\n"); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3render_c.h b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3render_c.h deleted file mode 100644 index 5520ec59f..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3render_c.h +++ /dev/null @@ -1,29 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Default framebuffer device on PS3 */ -/* SDL surface based renderer implementation */ - -extern SDL_RenderDriver SDL_PS3_RenderDriver; - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3spe.c b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3spe.c deleted file mode 100644 index 4f7612cb2..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3spe.c +++ /dev/null @@ -1,166 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_video.h" -#include "SDL_ps3spe_c.h" - -#include "SDL_ps3video.h" -#include "SDL_ps3render_c.h" - -/* Start the SPE thread */ -int SPE_Start(spu_data_t * spe_data) -{ - deprintf(2, "[PS3->SPU] Start SPE: %s\n", spe_data->program_name); - if (!(spe_data->booted)) - SPE_Boot(spe_data); - - /* To allow re-running of context, spe_ctx_entry has to be set before each call */ - spe_data->entry = SPE_DEFAULT_ENTRY; - spe_data->error_code = 0; - - /* Create SPE thread and run */ - deprintf(2, "[PS3->SPU] Create Thread: %s\n", spe_data->program_name); - if (pthread_create - (&spe_data->thread, NULL, (void *)&SPE_RunContext, (void *)spe_data)) { - deprintf(2, "[PS3->SPU] Could not create pthread for spe: %s\n", spe_data->program_name); - SDL_SetError("[PS3->SPU] Could not create pthread for spe"); - return -1; - } - - if (spe_data->keepalive) - SPE_WaitForMsg(spe_data, SPU_READY); -} - -/* Stop the SPE thread */ -int SPE_Stop(spu_data_t * spe_data) -{ - deprintf(2, "[PS3->SPU] Stop SPE: %s\n", spe_data->program_name); - /* Wait for SPE thread to complete */ - deprintf(2, "[PS3->SPU] Wait for SPE thread to complete: %s\n", spe_data->program_name); - if (pthread_join(spe_data->thread, NULL)) { - deprintf(2, "[PS3->SPU] Failed joining the thread: %s\n", spe_data->program_name); - SDL_SetError("[PS3->SPU] Failed joining the thread"); - return -1; - } - - return 0; -} - -/* Create SPE context and load program */ -int SPE_Boot(spu_data_t * spe_data) -{ - /* Create SPE context */ - deprintf(2, "[PS3->SPU] Create SPE Context: %s\n", spe_data->program_name); - spe_data->ctx = spe_context_create(0, NULL); - if (spe_data->ctx == NULL) { - deprintf(2, "[PS3->SPU] Failed creating SPE context: %s\n", spe_data->program_name); - SDL_SetError("[PS3->SPU] Failed creating SPE context"); - return -1; - } - - /* Load SPE object into SPE local store */ - deprintf(2, "[PS3->SPU] Load Program into SPE: %s\n", spe_data->program_name); - if (spe_program_load(spe_data->ctx, &spe_data->program)) { - deprintf(2, "[PS3->SPU] Failed loading program into SPE context: %s\n", spe_data->program_name); - SDL_SetError - ("[PS3->SPU] Failed loading program into SPE context"); - return -1; - } - spe_data->booted = 1; - deprintf(2, "[PS3->SPU] SPE boot successful\n"); - - return 0; -} - -/* (Stop and) shutdown the SPE */ -int SPE_Shutdown(spu_data_t * spe_data) -{ - if (spe_data->keepalive && spe_data->booted) { - SPE_SendMsg(spe_data, SPU_EXIT); - SPE_Stop(spe_data); - } - - /* Destroy SPE context */ - deprintf(2, "[PS3->SPU] Destroy SPE context: %s\n", spe_data->program_name); - if (spe_context_destroy(spe_data->ctx)) { - deprintf(2, "[PS3->SPU] Failed destroying context: %s\n", spe_data->program_name); - SDL_SetError("[PS3->SPU] Failed destroying context"); - return -1; - } - deprintf(2, "[PS3->SPU] SPE shutdown successful: %s\n", spe_data->program_name); - return 0; -} - -/* Send message to the SPE via mailboxe */ -int SPE_SendMsg(spu_data_t * spe_data, unsigned int msg) -{ - deprintf(2, "[PS3->SPU] Sending message %u to %s\n", msg, spe_data->program_name); - /* Send one message, block until message was sent */ - unsigned int spe_in_mbox_msgs[1]; - spe_in_mbox_msgs[0] = msg; - int in_mbox_write = spe_in_mbox_write(spe_data->ctx, spe_in_mbox_msgs, 1, SPE_MBOX_ALL_BLOCKING); - - if (1 > in_mbox_write) { - deprintf(2, "[PS3->SPU] No message could be written to %s\n", spe_data->program_name); - SDL_SetError("[PS3->SPU] No message could be written"); - return -1; - } - return 0; -} - - -/* Read 1 message from SPE, block until at least 1 message was received */ -int SPE_WaitForMsg(spu_data_t * spe_data, unsigned int msg) -{ - deprintf(2, "[PS3->SPU] Waiting for message from %s\n", spe_data->program_name); - unsigned int out_messages[1]; - while (!spe_out_mbox_status(spe_data->ctx)); - int mbox_read = spe_out_mbox_read(spe_data->ctx, out_messages, 1); - deprintf(2, "[PS3->SPU] Got message from %s, message was %u\n", spe_data->program_name, out_messages[0]); - if (out_messages[0] == msg) - return 0; - else - return -1; -} - -/* Re-runnable invocation of the spe_context_run call */ -void SPE_RunContext(void *thread_argp) -{ - /* argp is the pointer to argument to be passed to the SPE program */ - spu_data_t *args = (spu_data_t *) thread_argp; - deprintf(3, "[PS3->SPU] void* argp=0x%x\n", (unsigned int)args->argp); - - /* Run it.. */ - deprintf(2, "[PS3->SPU] Run SPE program: %s\n", args->program_name); - if (spe_context_run - (args->ctx, &args->entry, 0, (void *)args->argp, NULL, - NULL) < 0) { - deprintf(2, "[PS3->SPU] Failed running SPE context: %s\n", args->program_name); - SDL_SetError("[PS3->SPU] Failed running SPE context: %s", args->program_name); - exit(1); - } - - pthread_exit(NULL); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3spe_c.h b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3spe_c.h deleted file mode 100644 index 2508c87b1..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3spe_c.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* This SPE API basically provides 3 ways to run and control a program - * on the SPE: - * - Start and stop the program (keepalive=0). - * SPE_Start() will implicitly boot up the program, create a thread and run - * the context. - * SPE_Stop() will join the (terminated) thread (may block) and return. - * - Boot the program and run it (keepalive=0). - * SPE_Boot() will create a context and load the program and finally start - * the context with SPE_Start(). - * SPE_Stop() will savely end the program. - * - Boot, Run and send messages to the program (keepalive=1). - * Start the program by using one of the methods described above. When - * received the READY-message the program is in its infinite loop waiting - * for new messages. - * Every time you run the program, send SPU_START and the address of the - * according struct using SPE_SendMsg(). - * SPE_WaitForMsg() will than wait for SPU_FIN and is blocking. - * SPE_Shutdown() sends SPU_EXIT and finally stops the program. - * - * Therefor the SPE program - * - either runs once and returns - * - or runs in an infinite loop and is controlled by messages. - */ - -#include "SDL_config.h" - -#include "spulibs/spu_common.h" - -#include - -#ifndef _SDL_ps3spe_h -#define _SDL_ps3spe_h - -/* SPU handling data */ -typedef struct spu_data { - /* Context to be executed */ - spe_context_ptr_t ctx; - spe_program_handle_t program; - /* Thread running the context */ - pthread_t thread; - /* For debugging */ - char * program_name; - /* SPE_Start() or SPE_Boot() called */ - unsigned int booted; - /* Runs the program in an infinite loop? */ - unsigned int keepalive; - unsigned int entry; - /* Exit code of the program */ - int error_code; - /* Arguments passed to the program */ - void * argp; -} spu_data_t; - -/* SPU specific API functions */ -int SPE_Start(spu_data_t * spe_data); -int SPE_Stop(spu_data_t * spe_data); -int SPE_Boot(spu_data_t * spe_data); -int SPE_Shutdown(spu_data_t * spe_data); -int SPE_SendMsg(spu_data_t * spe_data, unsigned int msg); -int SPE_WaitForMsg(spu_data_t * spe_data, unsigned int msg); -void SPE_RunContext(void *thread_argp); - -#endif /* _SDL_ps3spe_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3video.c b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3video.c deleted file mode 100644 index 0d0f2e7d4..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3video.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* SDL PS3 video driver implementation based on dummy video driver - * - * Initial work by Ryan C. Gordon (icculus@icculus.org). A good portion - * of this was cut-and-pasted from Stephane Peter's work in the AAlib - * SDL video driver. Renamed to "DUMMY" by Sam Lantinga. - */ - -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" - -#include "SDL_ps3video.h" -#include "SDL_ps3spe_c.h" -#include "SDL_ps3events_c.h" -#include "SDL_ps3render_c.h" -#include "SDL_ps3modes_c.h" - -#include -#include -#include -#include - -#define PS3VID_DRIVER_NAME "ps3" - -/* Initialization/Query functions */ -static int PS3_VideoInit(_THIS); -static void PS3_VideoQuit(_THIS); - -/* Stores the SPE executable name of fb_writer_spu */ -extern spe_program_handle_t fb_writer_spu; - -/* PS3 driver bootstrap functions */ - -static int -PS3_Available(void) -{ - deprintf(1, "+PS3_Available()\n"); - const char *envr = SDL_getenv("SDL_VIDEODRIVER"); - if ((envr) && (SDL_strcmp(envr, PS3VID_DRIVER_NAME) == 0)) { - return (1); - } - - deprintf(1, "-PS3_Available()\n"); - return (0); -} - -static void -PS3_DeleteDevice(SDL_VideoDevice * device) -{ - deprintf(1, "+PS3_DeleteDevice()\n"); - SDL_free(device->driverdata); - SDL_free(device); - deprintf(1, "-PS3_DeleteDevice()\n"); -} - -static SDL_VideoDevice * -PS3_CreateDevice(int devindex) -{ - deprintf(1, "+PS3_CreateDevice()\n"); - SDL_VideoDevice *device; - SDL_VideoData *data; - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (!device) { - SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } - return (0); - } - data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); - if (!data) { - SDL_OutOfMemory(); - SDL_free(device); - return (0); - } - device->driverdata = data; - - /* Set the function pointers */ - device->VideoInit = PS3_VideoInit; - device->VideoQuit = PS3_VideoQuit; - device->SetDisplayMode = PS3_SetDisplayMode; - device->GetDisplayModes = PS3_GetDisplayModes; - device->PumpEvents = PS3_PumpEvents; - - device->free = PS3_DeleteDevice; - - deprintf(1, "-PS3_CreateDevice()\n"); - return device; -} - -VideoBootStrap PS3_bootstrap = { - PS3VID_DRIVER_NAME, "SDL PS3 Cell video driver", - PS3_Available, PS3_CreateDevice -}; - - -int -PS3_VideoInit(_THIS) -{ - int i; - - deprintf(1, "PS3_VideoInit()\n"); - - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_DisplayMode mode; - - /* Create SPU fb_parms and thread structure */ - data->fb_parms = (struct fb_writer_parms_t *) - memalign(16, sizeof(struct fb_writer_parms_t)); - data->fb_thread_data = (spu_data_t *) malloc(sizeof(spu_data_t)); - if (data->fb_parms == NULL || data->fb_thread_data == NULL) { - SDL_OutOfMemory(); - return -1; - } - data->fb_thread_data->program = fb_writer_spu; - data->fb_thread_data->program_name = "fb_writer_spu"; - data->fb_thread_data->argp = (void *)data->fb_parms; - data->fb_thread_data->keepalive = 1; - data->fb_thread_data->booted = 0; - - SPE_Start(data->fb_thread_data); - - /* Open the device */ - data->fbdev = open(PS3DEV, O_RDWR); - if (data->fbdev < 0) { - SDL_SetError("[PS3] Unable to open device %s", PS3DEV); - return -1; - } - - /* Take control of frame buffer from kernel, for details see - * http://felter.org/wesley/files/ps3/linux-20061110-docs/ApplicationProgrammingEnvironment.html - * kernel will no longer flip the screen itself - */ - ioctl(data->fbdev, PS3FB_IOCTL_ON, 0); - - /* Unblank screen */ - ioctl(data->fbdev, FBIOBLANK, 0); - - struct fb_fix_screeninfo fb_finfo; - if (ioctl(data->fbdev, FBIOGET_FSCREENINFO, &fb_finfo)) { - SDL_SetError("[PS3] Can't get fixed screeninfo"); - return (0); - } - - /* Note: on PS3, fb_finfo.smem_len is enough for double buffering */ - if ((data->frame_buffer = (uint8_t *)mmap(0, fb_finfo.smem_len, - PROT_READ | PROT_WRITE, MAP_SHARED, - data->fbdev, 0)) == (uint8_t *) - 1) { - SDL_SetError("[PS3] Can't mmap for %s", PS3DEV); - return (0); - } else { - /* Enable double buffering */ - } - - /* Blank screen */ - memset(data->frame_buffer, 0x00, fb_finfo.smem_len); - - PS3_InitModes(_this); - for (i = 0; i < _this->num_displays; ++i) { - SDL_AddRenderDriver(&_this->displays[i], &SDL_PS3_RenderDriver); - } - - /* We're done! */ - return 0; -} - -void -PS3_VideoQuit(_THIS) -{ - deprintf(1, "PS3_VideoQuit()\n"); - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - - PS3_QuitModes(_this); - - /* Unmap framebuffer */ - if (data->frame_buffer) { - struct fb_fix_screeninfo fb_finfo; - if (ioctl(data->fbdev, FBIOGET_FSCREENINFO, &fb_finfo) != -1) { - munmap(data->frame_buffer, fb_finfo.smem_len); - data->frame_buffer = 0; - } - } - - /* Shutdown SPE and related resources */ - if (data->fb_parms) - free((void *)data->fb_parms); - if (data->fb_thread_data) { - SPE_Shutdown(data->fb_thread_data); - free((void *)data->fb_thread_data); - } - - /* Close device */ - if (data->fbdev) { - /* Give control of frame buffer back to kernel */ - ioctl(data->fbdev, PS3FB_IOCTL_OFF, 0); - close(data->fbdev); - data->fbdev = -1; - } -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3video.h b/project/jni/sdl-1.3/src/video/ps3/SDL_ps3video.h deleted file mode 100644 index 9306e4e67..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/SDL_ps3video.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_ps3video_h -#define _SDL_ps3video_h - -#include "../SDL_sysvideo.h" -#include "SDL_ps3spe_c.h" - -#include -#include - -/* Debugging - * 0: No debug messages - * 1: Video debug messages - * 2: SPE debug messages - * 3: Memory adresses - */ -#define DEBUG_LEVEL 0 - -#ifdef DEBUG_LEVEL -#define deprintf( level, fmt, args... ) \ - do \ -{ \ - if ( (unsigned)(level) <= DEBUG_LEVEL ) \ - { \ - fprintf( stdout, fmt, ##args ); \ - fflush( stdout ); \ - } \ -} while ( 0 ) -#else -#define deprintf( level, fmt, args... ) -#endif - -/* Default framebuffer device on PS3 */ -#define PS3DEV "/dev/fb0" - -/* Private display data */ -typedef struct SDL_VideoData -{ - /* Framebuffer device descriptor */ - int fbdev; - /* mmap'd access to fbdev */ - uint8_t * frame_buffer; - /* SPE threading stuff of the framebuffer */ - spu_data_t * fb_thread_data; - /* Framebuffer transfer data */ - volatile struct fb_writer_parms_t * fb_parms __attribute__((aligned(128))); -} SDL_VideoData; - -typedef struct SDL_DisplayModeData -{ - unsigned long mode; - //struct ps3fb_ioctl_res res; -} PS3_DisplayModeData; - -#endif /* _SDL_ps3video_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/ps3/spulibs/Makefile b/project/jni/sdl-1.3/src/video/ps3/spulibs/Makefile deleted file mode 100644 index f20fade4a..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/spulibs/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# This Makefile is for building the CELL BE SPU libs -# libfb_writer_spu.so, libyuv2rgb_spu.so, libbilin_scaler_spu.so - -# Toolchain -PPU_LD=/usr/bin/ld -SPU_SRCDIR=$(srcdir)/src/video/ps3/spulibs -SPU_LIBDIR=$(srcdir)/src/video/ps3/spulibs/libs -SPU_CFLAGS=-g -W -Wall -Winline -Wno-main -I. -I /usr/spu/include -I /opt/cell/sdk/usr/spu/include -finline-limit=10000 -Winline -ftree-vectorize -funroll-loops -fmodulo-sched -ffast-math -fPIC -O2 - -DEPS = $(SPU_SRCDIR)/spu_common.h -LIBS= fb_writer yuv2rgb bilin_scaler - -OBJLIBS = $(foreach lib,$(LIBS),lib$(lib)_spu.a) -SHALIBS = $(foreach lib,$(LIBS),lib$(lib)_spu.so) - - -ps3libs: $(foreach lib,$(OBJLIBS),$(SPU_LIBDIR)/$(lib)) $(foreach lib,$(SHALIBS),$(SPU_LIBDIR)/$(lib)) - - -$(SPU_LIBDIR)/lib%_spu.a: $(SPU_LIBDIR)/%-embed.o - $(AR) -qcs $@ $< - -$(SPU_LIBDIR)/lib%_spu.so: $(SPU_LIBDIR)/%-embed.o - $(PPU_LD) -o $@ -shared -soname=$(notdir $@) $< - -$(SPU_LIBDIR)/%-embed.o: $(SPU_LIBDIR)/%.o - $(EMBEDSPU) -m32 $(subst -embed.o,,$(notdir $@))_spu $< $@ - -$(SPU_LIBDIR)/%.o: $(SPU_SRCDIR)/%.c $(DEPS) - $(SPU_GCC) $(SPU_CFLAGS) -o $@ $< -lm - - -ps3libs-install: $(foreach obj,$(OBJLIBS),$(SPU_LIBDIR)/$(obj)) $(foreach obj,$(SHALIBS),$(SPU_LIBDIR)/$(obj)) - for file in $(OBJLIBS); do \ - $(INSTALL) -c -m 0655 $(SPU_LIBDIR)/$$file $(DESTDIR)$(libdir)/$$file; \ - done - for file in $(SHALIBS); do \ - $(INSTALL) -c -m 0755 $(SPU_LIBDIR)/$$file $(DESTDIR)$(libdir)/$$file; \ - done - -ps3libs-uninstall: - for file in $(OBJLIBS) $(SHALIBS); do \ - rm -f $(DESTDIR)$(libdir)/$$file; \ - done - -ps3libs-clean: - rm -f $(SPU_LIBDIR)/* diff --git a/project/jni/sdl-1.3/src/video/ps3/spulibs/bilin_scaler.c b/project/jni/sdl-1.3/src/video/ps3/spulibs/bilin_scaler.c deleted file mode 100644 index be9b5c6e8..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/spulibs/bilin_scaler.c +++ /dev/null @@ -1,2050 +0,0 @@ -/* - * SDL - Simple DirectMedia Layer - * CELL BE Support for PS3 Framebuffer - * Copyright (C) 2008, 2009 International Business Machines Corporation - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Martin Lowinski - * Dirk Herrendoerfer - * SPE code based on research by: - * Rene Becker - * Thimo Emmerich - */ - -#include "spu_common.h" - -#include -#include - -// Debugging -//#define DEBUG - -#ifdef DEBUG -#define deprintf(fmt, args... ) \ - fprintf( stdout, fmt, ##args ); \ - fflush( stdout ); -#else -#define deprintf( fmt, args... ) -#endif - -struct scale_parms_t parms __attribute__((aligned(128))); - -/* A maximum of 8 lines Y, therefore 4 lines V, 4 lines U are stored - * there might be the need to retrieve misaligned data, adjust - * incoming v and u plane to be able to handle this (add 128) - */ -unsigned char y_plane[2][(MAX_HDTV_WIDTH+128)*4] __attribute__((aligned(128))); -unsigned char v_plane[2][(MAX_HDTV_WIDTH+128)*2] __attribute__((aligned(128))); -unsigned char u_plane[2][(MAX_HDTV_WIDTH+128)*2] __attribute__((aligned(128))); - -/* temp-buffer for scaling: 4 lines Y, therefore 2 lines V, 2 lines U */ -unsigned char scaled_y_plane[2][MAX_HDTV_WIDTH*2] __attribute__((aligned(128))); -unsigned char scaled_v_plane[2][MAX_HDTV_WIDTH/2] __attribute__((aligned(128))); -unsigned char scaled_u_plane[2][MAX_HDTV_WIDTH/2] __attribute__((aligned(128))); - -/* some vectors needed by the float to int conversion */ -static const vector float vec_255 = { 255.0f, 255.0f, 255.0f, 255.0f }; -static const vector float vec_0_1 = { 0.1f, 0.1f, 0.1f, 0.1f }; - -void bilinear_scale_line_w8(unsigned char* src, unsigned char* dst_, unsigned int dst_width, vector float vf_x_scale, vector float vf_NSweight, unsigned int src_linestride); -void bilinear_scale_line_w16(unsigned char* src, unsigned char* dst_, unsigned int dst_width, vector float vf_x_scale, vector float vf_NSweight, unsigned int src_linestride); - -void scale_srcw16_dstw16(); -void scale_srcw16_dstw32(); -void scale_srcw32_dstw16(); -void scale_srcw32_dstw32(); - -int main( unsigned long long spe_id __attribute__((unused)), unsigned long long argp ) -{ - deprintf("[SPU] bilin_scaler_spu is up... (on SPE #%llu)\n", spe_id); - /* DMA transfer for the input parameters */ - spu_mfcdma32(&parms, (unsigned int)argp, sizeof(struct scale_parms_t), TAG_INIT, MFC_GET_CMD); - DMA_WAIT_TAG(TAG_INIT); - - deprintf("[SPU] Scale %ux%u to %ux%u\n", parms.src_pixel_width, parms.src_pixel_height, - parms.dst_pixel_width, parms.dst_pixel_height); - - if(parms.src_pixel_width & 0x1f) { - if(parms.dst_pixel_width & 0x1F) { - deprintf("[SPU] Using scale_srcw16_dstw16\n"); - scale_srcw16_dstw16(); - } else { - deprintf("[SPU] Using scale_srcw16_dstw32\n"); - scale_srcw16_dstw32(); - } - } else { - if(parms.dst_pixel_width & 0x1F) { - deprintf("[SPU] Using scale_srcw32_dstw16\n"); - scale_srcw32_dstw16(); - } else { - deprintf("[SPU] Using scale_srcw32_dstw32\n"); - scale_srcw32_dstw32(); - } - } - deprintf("[SPU] bilin_scaler_spu... done!\n"); - - return 0; -} - - -/* - * vfloat_to_vuint() - * - * converts a float vector to an unsinged int vector using saturated - * arithmetic - * - * @param vec_s float vector for conversion - * @returns converted unsigned int vector - */ -inline static vector unsigned int vfloat_to_vuint(vector float vec_s) { - vector unsigned int select_1 = spu_cmpgt(vec_0_1, vec_s); - vec_s = spu_sel(vec_s, vec_0_1, select_1); - - vector unsigned int select_2 = spu_cmpgt(vec_s, vec_255); - vec_s = spu_sel(vec_s, vec_255, select_2); - return spu_convtu(vec_s,0); -} - - -/* - * scale_srcw16_dstw16() - * - * processes an input image of width 16 - * scaling is done to a width 16 - * result stored in RAM - */ -void scale_srcw16_dstw16() { - // extract parameters - unsigned char* dst_addr = (unsigned char *)parms.dstBuffer; - - unsigned int src_width = parms.src_pixel_width; - unsigned int src_height = parms.src_pixel_height; - unsigned int dst_width = parms.dst_pixel_width; - unsigned int dst_height = parms.dst_pixel_height; - - // YVU - unsigned int src_linestride_y = src_width; - unsigned int src_dbl_linestride_y = src_width<<1; - unsigned int src_linestride_vu = src_width>>1; - unsigned int src_dbl_linestride_vu = src_width; - - // scaled YVU - unsigned int scaled_src_linestride_y = dst_width; - - // ram addresses - unsigned char* src_addr_y = parms.y_plane; - unsigned char* src_addr_v = parms.v_plane; - unsigned char* src_addr_u = parms.u_plane; - - // for handling misalignment, addresses are precalculated - unsigned char* precalc_src_addr_v = src_addr_v; - unsigned char* precalc_src_addr_u = src_addr_u; - - unsigned int dst_picture_size = dst_width*dst_height; - - // Sizes for destination - unsigned int dst_dbl_linestride_y = dst_width<<1; - unsigned int dst_dbl_linestride_vu = dst_width>>1; - - // Perform address calculation for Y, V and U in main memory with dst_addr as base - unsigned char* dst_addr_main_memory_y = dst_addr; - unsigned char* dst_addr_main_memory_v = dst_addr + dst_picture_size; - unsigned char* dst_addr_main_memory_u = dst_addr_main_memory_v +(dst_picture_size>>2); - - // calculate scale factors - vector float vf_x_scale = spu_splats( (float)src_width/(float)dst_width ); - float y_scale = (float)src_height/(float)dst_height; - - // double buffered processing - // buffer switching - unsigned int curr_src_idx = 0; - unsigned int curr_dst_idx = 0; - unsigned int next_src_idx, next_dst_idx; - - // 2 lines y as output, upper and lowerline - unsigned int curr_interpl_y_upper = 0; - unsigned int next_interpl_y_upper; - unsigned int curr_interpl_y_lower, next_interpl_y_lower; - // only 1 line v/u output, both planes have the same dimension - unsigned int curr_interpl_vu = 0; - unsigned int next_interpl_vu; - - // weights, calculated in every loop iteration - vector float vf_curr_NSweight_y_upper = { 0.0f, 0.0f, 0.0f, 0.0f }; - vector float vf_next_NSweight_y_upper; - vector float vf_curr_NSweight_y_lower, vf_next_NSweight_y_lower; - vector float vf_curr_NSweight_vu = { 0.0f, 0.0f, 0.0f, 0.0f }; - vector float vf_next_NSweight_vu; - - // line indices for the src picture - float curr_src_y_upper = 0.0f, next_src_y_upper; - float curr_src_y_lower, next_src_y_lower; - float curr_src_vu = 0.0f, next_src_vu; - - // line indices for the dst picture - unsigned int dst_y=0, dst_vu=0; - - // offset for the v and u plane to handle misalignement - unsigned int curr_lsoff_v = 0, next_lsoff_v; - unsigned int curr_lsoff_u = 0, next_lsoff_u; - - // calculate lower line indices - curr_src_y_lower = ((float)curr_interpl_y_upper+1)*y_scale; - curr_interpl_y_lower = (unsigned int)curr_src_y_lower; - // lower line weight - vf_curr_NSweight_y_lower = spu_splats( curr_src_y_lower-(float)curr_interpl_y_lower ); - - - // start partially double buffered processing - // get initial data, 2 sets of y, 1 set v, 1 set u - mfc_get( y_plane[curr_src_idx], (unsigned int) src_addr_y, src_dbl_linestride_y, RETR_BUF, 0, 0 ); - mfc_get( y_plane[curr_src_idx]+src_dbl_linestride_y, - (unsigned int) src_addr_y+(curr_interpl_y_lower*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF, - 0, 0 ); - mfc_get( v_plane[curr_src_idx], (unsigned int) src_addr_v, src_dbl_linestride_vu, RETR_BUF, 0, 0 ); - mfc_get( u_plane[curr_src_idx], (unsigned int) src_addr_u, src_dbl_linestride_vu, RETR_BUF, 0, 0 ); - - /* iteration loop - * within each iteration 4 lines y, 2 lines v, 2 lines u are retrieved - * the scaled output is 2 lines y, 1 line v, 1 line u - * the yuv2rgb-converted output is stored to RAM - */ - for( dst_vu=0; dst_vu<(dst_height>>1)-1; dst_vu++ ) { - dst_y = dst_vu<<1; - - // calculate next indices - next_src_vu = ((float)dst_vu+1)*y_scale; - next_src_y_upper = ((float)dst_y+2)*y_scale; - next_src_y_lower = ((float)dst_y+3)*y_scale; - - next_interpl_vu = (unsigned int) next_src_vu; - next_interpl_y_upper = (unsigned int) next_src_y_upper; - next_interpl_y_lower = (unsigned int) next_src_y_lower; - - // calculate weight NORTH-SOUTH - vf_next_NSweight_vu = spu_splats( next_src_vu-(float)next_interpl_vu ); - vf_next_NSweight_y_upper = spu_splats( next_src_y_upper-(float)next_interpl_y_upper ); - vf_next_NSweight_y_lower = spu_splats( next_src_y_lower-(float)next_interpl_y_lower ); - - // get next lines - next_src_idx = curr_src_idx^1; - next_dst_idx = curr_dst_idx^1; - - // 4 lines y - mfc_get( y_plane[next_src_idx], - (unsigned int) src_addr_y+(next_interpl_y_upper*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF+next_src_idx, - 0, 0 ); - mfc_get( y_plane[next_src_idx]+src_dbl_linestride_y, - (unsigned int) src_addr_y+(next_interpl_y_lower*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF+next_src_idx, - 0, 0 ); - - // 2 lines v - precalc_src_addr_v = src_addr_v+(next_interpl_vu*src_linestride_vu); - next_lsoff_v = ((unsigned int)precalc_src_addr_v)&0x0F; - mfc_get( v_plane[next_src_idx], - ((unsigned int) precalc_src_addr_v)&0xFFFFFFF0, - src_dbl_linestride_vu+(next_lsoff_v<<1), - RETR_BUF+next_src_idx, - 0, 0 ); - // 2 lines u - precalc_src_addr_u = src_addr_u+(next_interpl_vu*src_linestride_vu); - next_lsoff_u = ((unsigned int)precalc_src_addr_u)&0x0F; - mfc_get( u_plane[next_src_idx], - ((unsigned int) precalc_src_addr_u)&0xFFFFFFF0, - src_dbl_linestride_vu+(next_lsoff_v<<1), - RETR_BUF+next_src_idx, - 0, 0 ); - - DMA_WAIT_TAG( (RETR_BUF+curr_src_idx) ); - - // scaling - // work line y_upper - bilinear_scale_line_w16( y_plane[curr_src_idx], - scaled_y_plane[curr_src_idx], - dst_width, - vf_x_scale, - vf_curr_NSweight_y_upper, - src_linestride_y ); - // work line y_lower - bilinear_scale_line_w16( y_plane[curr_src_idx]+src_dbl_linestride_y, - scaled_y_plane[curr_src_idx]+scaled_src_linestride_y, - dst_width, - vf_x_scale, - vf_curr_NSweight_y_lower, - src_linestride_y ); - // work line v - bilinear_scale_line_w8( v_plane[curr_src_idx]+curr_lsoff_v, - scaled_v_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - // work line u - bilinear_scale_line_w8( u_plane[curr_src_idx]+curr_lsoff_u, - scaled_u_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - - - // Store the result back to main memory into a destination buffer in YUV format - //--------------------------------------------------------------------------------------------- - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - - // Perform three DMA transfers to 3 different locations in the main memory! - // dst_width: Pixel width of destination image - // dst_addr: Destination address in main memory - // dst_vu: Counter which is incremented one by one - // dst_y: Counter which is twice larger than dst_vu (dst_y = 2*dst_vu) - mfc_put( scaled_y_plane[curr_src_idx], // What from local store (addr) - (unsigned int)dst_addr_main_memory_y + (dst_vu*dst_dbl_linestride_y), // Destination in main memory (addr) - dst_dbl_linestride_y, // Two Y lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_v_plane[curr_src_idx], // What from local store (addr) - (unsigned int)dst_addr_main_memory_v + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two V lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_u_plane[curr_src_idx], // What from local store (addr) - (unsigned int)dst_addr_main_memory_u + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two U lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - //--------------------------------------------------------------------------------------------- - - - // update for next cycle - curr_src_idx = next_src_idx; - curr_dst_idx = next_dst_idx; - - curr_interpl_y_upper = next_interpl_y_upper; - curr_interpl_y_lower = next_interpl_y_lower; - curr_interpl_vu = next_interpl_vu; - - vf_curr_NSweight_y_upper = vf_curr_NSweight_y_upper; - vf_curr_NSweight_y_lower = vf_curr_NSweight_y_lower; - vf_curr_NSweight_vu = vf_next_NSweight_vu; - - curr_src_y_upper = next_src_y_upper; - curr_src_y_lower = next_src_y_lower; - curr_src_vu = next_src_vu; - - curr_lsoff_v = next_lsoff_v; - curr_lsoff_u = next_lsoff_u; - } - - - - DMA_WAIT_TAG( (RETR_BUF+curr_src_idx) ); - - // scaling - // work line y_upper - bilinear_scale_line_w16( y_plane[curr_src_idx], - scaled_y_plane[curr_src_idx], - dst_width, - vf_x_scale, - vf_curr_NSweight_y_upper, - src_linestride_y ); - // work line y_lower - bilinear_scale_line_w16( y_plane[curr_src_idx]+src_dbl_linestride_y, - scaled_y_plane[curr_src_idx]+scaled_src_linestride_y, - dst_width, - vf_x_scale, - vf_curr_NSweight_y_lower, - src_linestride_y ); - // work line v - bilinear_scale_line_w8( v_plane[curr_src_idx]+curr_lsoff_v, - scaled_v_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - // work line u - bilinear_scale_line_w8( u_plane[curr_src_idx]+curr_lsoff_u, - scaled_u_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - - - // Store the result back to main memory into a destination buffer in YUV format - //--------------------------------------------------------------------------------------------- - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - - // Perform three DMA transfers to 3 different locations in the main memory! - // dst_width: Pixel width of destination image - // dst_addr: Destination address in main memory - // dst_vu: Counter which is incremented one by one - // dst_y: Counter which is twice larger than dst_vu (dst_y = 2*dst_vu) - mfc_put( scaled_y_plane[curr_src_idx], // What from local store (addr) - (unsigned int)dst_addr_main_memory_y + (dst_vu*dst_dbl_linestride_y), // Destination in main memory (addr) - dst_dbl_linestride_y, // Two Y lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_v_plane[curr_src_idx], // What from local store (addr) - (unsigned int)dst_addr_main_memory_v + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two V lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_u_plane[curr_src_idx], // What from local store (addr) - (unsigned int)dst_addr_main_memory_u + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two U lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - // wait for completion - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - //--------------------------------------------------------------------------------------------- -} - - -/* - * scale_srcw16_dstw32() - * - * processes an input image of width 16 - * scaling is done to a width 32 - * yuv2rgb conversion on a width of 32 - * result stored in RAM - */ -void scale_srcw16_dstw32() { - // extract parameters - unsigned char* dst_addr = (unsigned char *)parms.dstBuffer; - - unsigned int src_width = parms.src_pixel_width; - unsigned int src_height = parms.src_pixel_height; - unsigned int dst_width = parms.dst_pixel_width; - unsigned int dst_height = parms.dst_pixel_height; - - // YVU - unsigned int src_linestride_y = src_width; - unsigned int src_dbl_linestride_y = src_width<<1; - unsigned int src_linestride_vu = src_width>>1; - unsigned int src_dbl_linestride_vu = src_width; - // scaled YVU - unsigned int scaled_src_linestride_y = dst_width; - - // ram addresses - unsigned char* src_addr_y = parms.y_plane; - unsigned char* src_addr_v = parms.v_plane; - unsigned char* src_addr_u = parms.u_plane; - - unsigned int dst_picture_size = dst_width*dst_height; - - // Sizes for destination - unsigned int dst_dbl_linestride_y = dst_width<<1; - unsigned int dst_dbl_linestride_vu = dst_width>>1; - - // Perform address calculation for Y, V and U in main memory with dst_addr as base - unsigned char* dst_addr_main_memory_y = dst_addr; - unsigned char* dst_addr_main_memory_v = dst_addr + dst_picture_size; - unsigned char* dst_addr_main_memory_u = dst_addr_main_memory_v +(dst_picture_size>>2); - - - // for handling misalignment, addresses are precalculated - unsigned char* precalc_src_addr_v = src_addr_v; - unsigned char* precalc_src_addr_u = src_addr_u; - - // calculate scale factors - vector float vf_x_scale = spu_splats( (float)src_width/(float)dst_width ); - float y_scale = (float)src_height/(float)dst_height; - - // double buffered processing - // buffer switching - unsigned int curr_src_idx = 0; - unsigned int curr_dst_idx = 0; - unsigned int next_src_idx, next_dst_idx; - - // 2 lines y as output, upper and lowerline - unsigned int curr_interpl_y_upper = 0; - unsigned int next_interpl_y_upper; - unsigned int curr_interpl_y_lower, next_interpl_y_lower; - // only 1 line v/u output, both planes have the same dimension - unsigned int curr_interpl_vu = 0; - unsigned int next_interpl_vu; - - // weights, calculated in every loop iteration - vector float vf_curr_NSweight_y_upper = { 0.0f, 0.0f, 0.0f, 0.0f }; - vector float vf_next_NSweight_y_upper; - vector float vf_curr_NSweight_y_lower, vf_next_NSweight_y_lower; - vector float vf_curr_NSweight_vu = { 0.0f, 0.0f, 0.0f, 0.0f }; - vector float vf_next_NSweight_vu; - - // line indices for the src picture - float curr_src_y_upper = 0.0f, next_src_y_upper; - float curr_src_y_lower, next_src_y_lower; - float curr_src_vu = 0.0f, next_src_vu; - - // line indices for the dst picture - unsigned int dst_y=0, dst_vu=0; - - // offset for the v and u plane to handle misalignement - unsigned int curr_lsoff_v = 0, next_lsoff_v; - unsigned int curr_lsoff_u = 0, next_lsoff_u; - - // calculate lower line idices - curr_src_y_lower = ((float)curr_interpl_y_upper+1)*y_scale; - curr_interpl_y_lower = (unsigned int)curr_src_y_lower; - // lower line weight - vf_curr_NSweight_y_lower = spu_splats( curr_src_y_lower-(float)curr_interpl_y_lower ); - - - // start partially double buffered processing - // get initial data, 2 sets of y, 1 set v, 1 set u - mfc_get( y_plane[curr_src_idx], (unsigned int) src_addr_y, src_dbl_linestride_y, RETR_BUF, 0, 0 ); - mfc_get( y_plane[curr_src_idx]+src_dbl_linestride_y, - (unsigned int) src_addr_y+(curr_interpl_y_lower*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF, - 0, 0 ); - mfc_get( v_plane[curr_src_idx], (unsigned int) src_addr_v, src_dbl_linestride_vu, RETR_BUF, 0, 0 ); - mfc_get( u_plane[curr_src_idx], (unsigned int) src_addr_u, src_dbl_linestride_vu, RETR_BUF, 0, 0 ); - - // iteration loop - // within each iteration 4 lines y, 2 lines v, 2 lines u are retrieved - // the scaled output is 2 lines y, 1 line v, 1 line u - // the yuv2rgb-converted output is stored to RAM - for( dst_vu=0; dst_vu<(dst_height>>1)-1; dst_vu++ ) { - dst_y = dst_vu<<1; - - // calculate next indices - next_src_vu = ((float)dst_vu+1)*y_scale; - next_src_y_upper = ((float)dst_y+2)*y_scale; - next_src_y_lower = ((float)dst_y+3)*y_scale; - - next_interpl_vu = (unsigned int) next_src_vu; - next_interpl_y_upper = (unsigned int) next_src_y_upper; - next_interpl_y_lower = (unsigned int) next_src_y_lower; - - // calculate weight NORTH-SOUTH - vf_next_NSweight_vu = spu_splats( next_src_vu-(float)next_interpl_vu ); - vf_next_NSweight_y_upper = spu_splats( next_src_y_upper-(float)next_interpl_y_upper ); - vf_next_NSweight_y_lower = spu_splats( next_src_y_lower-(float)next_interpl_y_lower ); - - // get next lines - next_src_idx = curr_src_idx^1; - next_dst_idx = curr_dst_idx^1; - - // 4 lines y - mfc_get( y_plane[next_src_idx], - (unsigned int) src_addr_y+(next_interpl_y_upper*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF+next_src_idx, - 0, 0 ); - mfc_get( y_plane[next_src_idx]+src_dbl_linestride_y, - (unsigned int) src_addr_y+(next_interpl_y_lower*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF+next_src_idx, - 0, 0 ); - - // 2 lines v - precalc_src_addr_v = src_addr_v+(next_interpl_vu*src_linestride_vu); - next_lsoff_v = ((unsigned int)precalc_src_addr_v)&0x0F; - mfc_get( v_plane[next_src_idx], - ((unsigned int) precalc_src_addr_v)&0xFFFFFFF0, - src_dbl_linestride_vu+(next_lsoff_v<<1), - RETR_BUF+next_src_idx, - 0, 0 ); - // 2 lines u - precalc_src_addr_u = src_addr_u+(next_interpl_vu*src_linestride_vu); - next_lsoff_u = ((unsigned int)precalc_src_addr_u)&0x0F; - mfc_get( u_plane[next_src_idx], - ((unsigned int) precalc_src_addr_u)&0xFFFFFFF0, - src_dbl_linestride_vu+(next_lsoff_v<<1), - RETR_BUF+next_src_idx, - 0, 0 ); - - DMA_WAIT_TAG( (RETR_BUF+curr_src_idx) ); - - // scaling - // work line y_upper - bilinear_scale_line_w16( y_plane[curr_src_idx], - scaled_y_plane[curr_src_idx], - dst_width, - vf_x_scale, - vf_curr_NSweight_y_upper, - src_linestride_y ); - // work line y_lower - bilinear_scale_line_w16( y_plane[curr_src_idx]+src_dbl_linestride_y, - scaled_y_plane[curr_src_idx]+scaled_src_linestride_y, - dst_width, - vf_x_scale, - vf_curr_NSweight_y_lower, - src_linestride_y ); - // work line v - bilinear_scale_line_w8( v_plane[curr_src_idx]+curr_lsoff_v, - scaled_v_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - // work line u - bilinear_scale_line_w8( u_plane[curr_src_idx]+curr_lsoff_u, - scaled_u_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - - //--------------------------------------------------------------------------------------------- - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - - // Perform three DMA transfers to 3 different locations in the main memory! - // dst_width: Pixel width of destination image - // dst_addr: Destination address in main memory - // dst_vu: Counter which is incremented one by one - // dst_y: Counter which is twice larger than dst_vu (dst_y = 2*dst_vu) - - mfc_put( scaled_y_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_y + (dst_vu*dst_dbl_linestride_y), // Destination in main memory (addr) - dst_dbl_linestride_y, // Two Y lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_v_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_v + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two V lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_u_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_u + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two U lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - //--------------------------------------------------------------------------------------------- - - - // update for next cycle - curr_src_idx = next_src_idx; - curr_dst_idx = next_dst_idx; - - curr_interpl_y_upper = next_interpl_y_upper; - curr_interpl_y_lower = next_interpl_y_lower; - curr_interpl_vu = next_interpl_vu; - - vf_curr_NSweight_y_upper = vf_curr_NSweight_y_upper; - vf_curr_NSweight_y_lower = vf_curr_NSweight_y_lower; - vf_curr_NSweight_vu = vf_next_NSweight_vu; - - curr_src_y_upper = next_src_y_upper; - curr_src_y_lower = next_src_y_lower; - curr_src_vu = next_src_vu; - - curr_lsoff_v = next_lsoff_v; - curr_lsoff_u = next_lsoff_u; - } - - - - DMA_WAIT_TAG( (RETR_BUF+curr_src_idx) ); - - // scaling - // work line y_upper - bilinear_scale_line_w16( y_plane[curr_src_idx], - scaled_y_plane[curr_src_idx], - dst_width, - vf_x_scale, - vf_curr_NSweight_y_upper, - src_linestride_y ); - // work line y_lower - bilinear_scale_line_w16( y_plane[curr_src_idx]+src_dbl_linestride_y, - scaled_y_plane[curr_src_idx]+scaled_src_linestride_y, - dst_width, - vf_x_scale, - vf_curr_NSweight_y_lower, - src_linestride_y ); - // work line v - bilinear_scale_line_w8( v_plane[curr_src_idx]+curr_lsoff_v, - scaled_v_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - // work line u - bilinear_scale_line_w8( u_plane[curr_src_idx]+curr_lsoff_u, - scaled_u_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - - //--------------------------------------------------------------------------------------------- - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - - // Perform three DMA transfers to 3 different locations in the main memory! - // dst_width: Pixel width of destination image - // dst_addr: Destination address in main memory - // dst_vu: Counter which is incremented one by one - // dst_y: Counter which is twice larger than dst_vu (dst_y = 2*dst_vu) - - mfc_put( scaled_y_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_y + (dst_vu*dst_dbl_linestride_y), // Destination in main memory (addr) - dst_dbl_linestride_y, // Two Y lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_v_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_v + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two V lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_u_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_u + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two U lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - // wait for completion - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - //--------------------------------------------------------------------------------------------- -} - - -/* - * scale_srcw32_dstw16() - * - * processes an input image of width 32 - * scaling is done to a width 16 - * yuv2rgb conversion on a width of 16 - * result stored in RAM - */ -void scale_srcw32_dstw16() { - // extract parameters - unsigned char* dst_addr = (unsigned char *)parms.dstBuffer; - - unsigned int src_width = parms.src_pixel_width; - unsigned int src_height = parms.src_pixel_height; - unsigned int dst_width = parms.dst_pixel_width; - unsigned int dst_height = parms.dst_pixel_height; - - // YVU - unsigned int src_linestride_y = src_width; - unsigned int src_dbl_linestride_y = src_width<<1; - unsigned int src_linestride_vu = src_width>>1; - unsigned int src_dbl_linestride_vu = src_width; - // scaled YVU - unsigned int scaled_src_linestride_y = dst_width; - - // ram addresses - unsigned char* src_addr_y = parms.y_plane; - unsigned char* src_addr_v = parms.v_plane; - unsigned char* src_addr_u = parms.u_plane; - - unsigned int dst_picture_size = dst_width*dst_height; - - // Sizes for destination - unsigned int dst_dbl_linestride_y = dst_width<<1; - unsigned int dst_dbl_linestride_vu = dst_width>>1; - - // Perform address calculation for Y, V and U in main memory with dst_addr as base - unsigned char* dst_addr_main_memory_y = dst_addr; - unsigned char* dst_addr_main_memory_v = dst_addr + dst_picture_size; - unsigned char* dst_addr_main_memory_u = dst_addr_main_memory_v +(dst_picture_size>>2); - - // calculate scale factors - vector float vf_x_scale = spu_splats( (float)src_width/(float)dst_width ); - float y_scale = (float)src_height/(float)dst_height; - - // double buffered processing - // buffer switching - unsigned int curr_src_idx = 0; - unsigned int curr_dst_idx = 0; - unsigned int next_src_idx, next_dst_idx; - - // 2 lines y as output, upper and lowerline - unsigned int curr_interpl_y_upper = 0; - unsigned int next_interpl_y_upper; - unsigned int curr_interpl_y_lower, next_interpl_y_lower; - // only 1 line v/u output, both planes have the same dimension - unsigned int curr_interpl_vu = 0; - unsigned int next_interpl_vu; - - // weights, calculated in every loop iteration - vector float vf_curr_NSweight_y_upper = { 0.0f, 0.0f, 0.0f, 0.0f }; - vector float vf_next_NSweight_y_upper; - vector float vf_curr_NSweight_y_lower, vf_next_NSweight_y_lower; - vector float vf_curr_NSweight_vu = { 0.0f, 0.0f, 0.0f, 0.0f }; - vector float vf_next_NSweight_vu; - - // line indices for the src picture - float curr_src_y_upper = 0.0f, next_src_y_upper; - float curr_src_y_lower, next_src_y_lower; - float curr_src_vu = 0.0f, next_src_vu; - - // line indices for the dst picture - unsigned int dst_y=0, dst_vu=0; - - // calculate lower line idices - curr_src_y_lower = ((float)curr_interpl_y_upper+1)*y_scale; - curr_interpl_y_lower = (unsigned int)curr_src_y_lower; - // lower line weight - vf_curr_NSweight_y_lower = spu_splats( curr_src_y_lower-(float)curr_interpl_y_lower ); - - - // start partially double buffered processing - // get initial data, 2 sets of y, 1 set v, 1 set u - mfc_get( y_plane[curr_src_idx], (unsigned int) src_addr_y, src_dbl_linestride_y, RETR_BUF, 0, 0 ); - mfc_get( y_plane[curr_src_idx]+src_dbl_linestride_y, - (unsigned int) src_addr_y+(curr_interpl_y_lower*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF, - 0, 0 ); - mfc_get( v_plane[curr_src_idx], (unsigned int) src_addr_v, src_dbl_linestride_vu, RETR_BUF, 0, 0 ); - mfc_get( u_plane[curr_src_idx], (unsigned int) src_addr_u, src_dbl_linestride_vu, RETR_BUF, 0, 0 ); - - // iteration loop - // within each iteration 4 lines y, 2 lines v, 2 lines u are retrieved - // the scaled output is 2 lines y, 1 line v, 1 line u - // the yuv2rgb-converted output is stored to RAM - for( dst_vu=0; dst_vu<(dst_height>>1)-1; dst_vu++ ) { - dst_y = dst_vu<<1; - - // calculate next indices - next_src_vu = ((float)dst_vu+1)*y_scale; - next_src_y_upper = ((float)dst_y+2)*y_scale; - next_src_y_lower = ((float)dst_y+3)*y_scale; - - next_interpl_vu = (unsigned int) next_src_vu; - next_interpl_y_upper = (unsigned int) next_src_y_upper; - next_interpl_y_lower = (unsigned int) next_src_y_lower; - - // calculate weight NORTH-SOUTH - vf_next_NSweight_vu = spu_splats( next_src_vu-(float)next_interpl_vu ); - vf_next_NSweight_y_upper = spu_splats( next_src_y_upper-(float)next_interpl_y_upper ); - vf_next_NSweight_y_lower = spu_splats( next_src_y_lower-(float)next_interpl_y_lower ); - - // get next lines - next_src_idx = curr_src_idx^1; - next_dst_idx = curr_dst_idx^1; - - // 4 lines y - mfc_get( y_plane[next_src_idx], - (unsigned int) src_addr_y+(next_interpl_y_upper*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF+next_src_idx, - 0, 0 ); - mfc_get( y_plane[next_src_idx]+src_dbl_linestride_y, - (unsigned int) src_addr_y+(next_interpl_y_lower*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF+next_src_idx, - 0, 0 ); - - // 2 lines v - mfc_get( v_plane[next_src_idx], - (unsigned int) src_addr_v+(next_interpl_vu*src_linestride_vu), - src_dbl_linestride_vu, - RETR_BUF+next_src_idx, - 0, 0 ); - // 2 lines u - mfc_get( u_plane[next_src_idx], - (unsigned int) src_addr_u+(next_interpl_vu*src_linestride_vu), - src_dbl_linestride_vu, - RETR_BUF+next_src_idx, - 0, 0 ); - - DMA_WAIT_TAG( (RETR_BUF+curr_src_idx) ); - - // scaling - // work line y_upper - bilinear_scale_line_w16( y_plane[curr_src_idx], - scaled_y_plane[curr_src_idx], - dst_width, - vf_x_scale, - vf_curr_NSweight_y_upper, - src_linestride_y ); - // work line y_lower - bilinear_scale_line_w16( y_plane[curr_src_idx]+src_dbl_linestride_y, - scaled_y_plane[curr_src_idx]+scaled_src_linestride_y, - dst_width, - vf_x_scale, - vf_curr_NSweight_y_lower, - src_linestride_y ); - // work line v - bilinear_scale_line_w16( v_plane[curr_src_idx], - scaled_v_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - // work line u - bilinear_scale_line_w16( u_plane[curr_src_idx], - scaled_u_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - - //--------------------------------------------------------------------------------------------- - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - - // Perform three DMA transfers to 3 different locations in the main memory! - // dst_width: Pixel width of destination image - // dst_addr: Destination address in main memory - // dst_vu: Counter which is incremented one by one - // dst_y: Counter which is twice larger than dst_vu (dst_y = 2*dst_vu) - - mfc_put( scaled_y_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_y + (dst_vu*dst_dbl_linestride_y), // Destination in main memory (addr) - dst_dbl_linestride_y, // Two Y lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_v_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_v + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two V lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_u_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_u + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two U lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - //--------------------------------------------------------------------------------------------- - - - // update for next cycle - curr_src_idx = next_src_idx; - curr_dst_idx = next_dst_idx; - - curr_interpl_y_upper = next_interpl_y_upper; - curr_interpl_y_lower = next_interpl_y_lower; - curr_interpl_vu = next_interpl_vu; - - vf_curr_NSweight_y_upper = vf_curr_NSweight_y_upper; - vf_curr_NSweight_y_lower = vf_curr_NSweight_y_lower; - vf_curr_NSweight_vu = vf_next_NSweight_vu; - - curr_src_y_upper = next_src_y_upper; - curr_src_y_lower = next_src_y_lower; - curr_src_vu = next_src_vu; - } - - - - DMA_WAIT_TAG( (RETR_BUF+curr_src_idx) ); - - // scaling - // work line y_upper - bilinear_scale_line_w16( y_plane[curr_src_idx], - scaled_y_plane[curr_src_idx], - dst_width, - vf_x_scale, - vf_curr_NSweight_y_upper, - src_linestride_y ); - // work line y_lower - bilinear_scale_line_w16( y_plane[curr_src_idx]+src_dbl_linestride_y, - scaled_y_plane[curr_src_idx]+scaled_src_linestride_y, - dst_width, - vf_x_scale, - vf_curr_NSweight_y_lower, - src_linestride_y ); - // work line v - bilinear_scale_line_w16( v_plane[curr_src_idx], - scaled_v_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - // work line u - bilinear_scale_line_w16( u_plane[curr_src_idx], - scaled_u_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - - - //--------------------------------------------------------------------------------------------- - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - - // Perform three DMA transfers to 3 different locations in the main memory! - // dst_width: Pixel width of destination image - // dst_addr: Destination address in main memory - // dst_vu: Counter which is incremented one by one - // dst_y: Counter which is twice larger than dst_vu (dst_y = 2*dst_vu) - - mfc_put( scaled_y_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_y + (dst_vu*dst_dbl_linestride_y), // Destination in main memory (addr) - dst_dbl_linestride_y, // Two Y lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_v_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_v + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two V lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_u_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_u + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two U lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - // wait for completion - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - //--------------------------------------------------------------------------------------------- -} - - -/** - * scale_srcw32_dstw32() - * - * processes an input image of width 32 - * scaling is done to a width 32 - * yuv2rgb conversion on a width of 32 - * result stored in RAM - */ -void scale_srcw32_dstw32() { - // extract parameters - unsigned char* dst_addr = (unsigned char *)parms.dstBuffer; - - unsigned int src_width = parms.src_pixel_width; - unsigned int src_height = parms.src_pixel_height; - unsigned int dst_width = parms.dst_pixel_width; - unsigned int dst_height = parms.dst_pixel_height; - - // YVU - unsigned int src_linestride_y = src_width; - unsigned int src_dbl_linestride_y = src_width<<1; - unsigned int src_linestride_vu = src_width>>1; - unsigned int src_dbl_linestride_vu = src_width; - - // scaled YVU - unsigned int scaled_src_linestride_y = dst_width; - - // ram addresses - unsigned char* src_addr_y = parms.y_plane; - unsigned char* src_addr_v = parms.v_plane; - unsigned char* src_addr_u = parms.u_plane; - - unsigned int dst_picture_size = dst_width*dst_height; - - // Sizes for destination - unsigned int dst_dbl_linestride_y = dst_width<<1; - unsigned int dst_dbl_linestride_vu = dst_width>>1; - - // Perform address calculation for Y, V and U in main memory with dst_addr as base - unsigned char* dst_addr_main_memory_y = dst_addr; - unsigned char* dst_addr_main_memory_v = dst_addr + dst_picture_size; - unsigned char* dst_addr_main_memory_u = dst_addr_main_memory_v +(dst_picture_size>>2); - - // calculate scale factors - vector float vf_x_scale = spu_splats( (float)src_width/(float)dst_width ); - float y_scale = (float)src_height/(float)dst_height; - - // double buffered processing - // buffer switching - unsigned int curr_src_idx = 0; - unsigned int curr_dst_idx = 0; - unsigned int next_src_idx, next_dst_idx; - - // 2 lines y as output, upper and lowerline - unsigned int curr_interpl_y_upper = 0; - unsigned int next_interpl_y_upper; - unsigned int curr_interpl_y_lower, next_interpl_y_lower; - // only 1 line v/u output, both planes have the same dimension - unsigned int curr_interpl_vu = 0; - unsigned int next_interpl_vu; - - // weights, calculated in every loop iteration - vector float vf_curr_NSweight_y_upper = { 0.0f, 0.0f, 0.0f, 0.0f }; - vector float vf_next_NSweight_y_upper; - vector float vf_curr_NSweight_y_lower, vf_next_NSweight_y_lower; - vector float vf_curr_NSweight_vu = { 0.0f, 0.0f, 0.0f, 0.0f }; - vector float vf_next_NSweight_vu; - - // line indices for the src picture - float curr_src_y_upper = 0.0f, next_src_y_upper; - float curr_src_y_lower, next_src_y_lower; - float curr_src_vu = 0.0f, next_src_vu; - - // line indices for the dst picture - unsigned int dst_y=0, dst_vu=0; - - // calculate lower line idices - curr_src_y_lower = ((float)curr_interpl_y_upper+1)*y_scale; - curr_interpl_y_lower = (unsigned int)curr_src_y_lower; - // lower line weight - vf_curr_NSweight_y_lower = spu_splats( curr_src_y_lower-(float)curr_interpl_y_lower ); - - - // start partially double buffered processing - // get initial data, 2 sets of y, 1 set v, 1 set u - mfc_get( y_plane[curr_src_idx], (unsigned int) src_addr_y, src_dbl_linestride_y, RETR_BUF, 0, 0 ); - mfc_get( y_plane[curr_src_idx]+src_dbl_linestride_y, - (unsigned int) src_addr_y+(curr_interpl_y_lower*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF, - 0, 0 ); - mfc_get( v_plane[curr_src_idx], (unsigned int) src_addr_v, src_dbl_linestride_vu, RETR_BUF, 0, 0 ); - mfc_get( u_plane[curr_src_idx], (unsigned int) src_addr_u, src_dbl_linestride_vu, RETR_BUF, 0, 0 ); - - // iteration loop - // within each iteration 4 lines y, 2 lines v, 2 lines u are retrieved - // the scaled output is 2 lines y, 1 line v, 1 line u - // the yuv2rgb-converted output is stored to RAM - for( dst_vu=0; dst_vu<(dst_height>>1)-1; dst_vu++ ) { - dst_y = dst_vu<<1; - - // calculate next indices - next_src_vu = ((float)dst_vu+1)*y_scale; - next_src_y_upper = ((float)dst_y+2)*y_scale; - next_src_y_lower = ((float)dst_y+3)*y_scale; - - next_interpl_vu = (unsigned int) next_src_vu; - next_interpl_y_upper = (unsigned int) next_src_y_upper; - next_interpl_y_lower = (unsigned int) next_src_y_lower; - - // calculate weight NORTH-SOUTH - vf_next_NSweight_vu = spu_splats( next_src_vu-(float)next_interpl_vu ); - vf_next_NSweight_y_upper = spu_splats( next_src_y_upper-(float)next_interpl_y_upper ); - vf_next_NSweight_y_lower = spu_splats( next_src_y_lower-(float)next_interpl_y_lower ); - - // get next lines - next_src_idx = curr_src_idx^1; - next_dst_idx = curr_dst_idx^1; - - // 4 lines y - mfc_get( y_plane[next_src_idx], - (unsigned int) src_addr_y+(next_interpl_y_upper*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF+next_src_idx, - 0, 0 ); - mfc_get( y_plane[next_src_idx]+src_dbl_linestride_y, - (unsigned int) src_addr_y+(next_interpl_y_lower*src_linestride_y), - src_dbl_linestride_y, - RETR_BUF+next_src_idx, - 0, 0 ); - - // 2 lines v - mfc_get( v_plane[next_src_idx], - (unsigned int) src_addr_v+(next_interpl_vu*src_linestride_vu), - src_dbl_linestride_vu, - RETR_BUF+next_src_idx, - 0, 0 ); - // 2 lines u - mfc_get( u_plane[next_src_idx], - (unsigned int) src_addr_u+(next_interpl_vu*src_linestride_vu), - src_dbl_linestride_vu, - RETR_BUF+next_src_idx, - 0, 0 ); - - DMA_WAIT_TAG( (RETR_BUF+curr_src_idx) ); - - // scaling - // work line y_upper - bilinear_scale_line_w16( y_plane[curr_src_idx], - scaled_y_plane[curr_src_idx], - dst_width, - vf_x_scale, - vf_curr_NSweight_y_upper, - src_linestride_y ); - // work line y_lower - bilinear_scale_line_w16( y_plane[curr_src_idx]+src_dbl_linestride_y, - scaled_y_plane[curr_src_idx]+scaled_src_linestride_y, - dst_width, - vf_x_scale, - vf_curr_NSweight_y_lower, - src_linestride_y ); - // work line v - bilinear_scale_line_w16( v_plane[curr_src_idx], - scaled_v_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - // work line u - bilinear_scale_line_w16( u_plane[curr_src_idx], - scaled_u_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - - - - // Store the result back to main memory into a destination buffer in YUV format - //--------------------------------------------------------------------------------------------- - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - - // Perform three DMA transfers to 3 different locations in the main memory! - // dst_width: Pixel width of destination image - // dst_addr: Destination address in main memory - // dst_vu: Counter which is incremented one by one - // dst_y: Counter which is twice larger than dst_vu (dst_y = 2*dst_vu) - - mfc_put( scaled_y_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_y + (dst_vu*dst_dbl_linestride_y), // Destination in main memory (addr) - dst_dbl_linestride_y, // Two Y lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_v_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_v + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two V lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_u_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_u + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two U lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - //--------------------------------------------------------------------------------------------- - - - // update for next cycle - curr_src_idx = next_src_idx; - curr_dst_idx = next_dst_idx; - - curr_interpl_y_upper = next_interpl_y_upper; - curr_interpl_y_lower = next_interpl_y_lower; - curr_interpl_vu = next_interpl_vu; - - vf_curr_NSweight_y_upper = vf_curr_NSweight_y_upper; - vf_curr_NSweight_y_lower = vf_curr_NSweight_y_lower; - vf_curr_NSweight_vu = vf_next_NSweight_vu; - - curr_src_y_upper = next_src_y_upper; - curr_src_y_lower = next_src_y_lower; - curr_src_vu = next_src_vu; - } - - - - DMA_WAIT_TAG( (RETR_BUF+curr_src_idx) ); - - // scaling - // work line y_upper - bilinear_scale_line_w16( y_plane[curr_src_idx], - scaled_y_plane[curr_src_idx], - dst_width, - vf_x_scale, - vf_curr_NSweight_y_upper, - src_linestride_y ); - // work line y_lower - bilinear_scale_line_w16( y_plane[curr_src_idx]+src_dbl_linestride_y, - scaled_y_plane[curr_src_idx]+scaled_src_linestride_y, - dst_width, - vf_x_scale, - vf_curr_NSweight_y_lower, - src_linestride_y ); - // work line v - bilinear_scale_line_w16( v_plane[curr_src_idx], - scaled_v_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - // work line u - bilinear_scale_line_w16( u_plane[curr_src_idx], - scaled_u_plane[curr_src_idx], - dst_width>>1, - vf_x_scale, - vf_curr_NSweight_vu, - src_linestride_vu ); - - - // Store the result back to main memory into a destination buffer in YUV format - //--------------------------------------------------------------------------------------------- - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - - // Perform three DMA transfers to 3 different locations in the main memory! - // dst_width: Pixel width of destination image - // dst_addr: Destination address in main memory - // dst_vu: Counter which is incremented one by one - // dst_y: Counter which is twice larger than dst_vu (dst_y = 2*dst_vu) - - mfc_put( scaled_y_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_y + (dst_vu*dst_dbl_linestride_y), // Destination in main memory (addr) - dst_dbl_linestride_y, // Two Y lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_v_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_v + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two V lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - mfc_put( scaled_u_plane[curr_src_idx], // What from local store (addr) - (unsigned int) dst_addr_main_memory_u + (dst_vu*dst_dbl_linestride_vu), // Destination in main memory (addr) - dst_dbl_linestride_vu, // Two U lines (depending on the widht of the destination resolution) - STR_BUF+curr_dst_idx, // Tag - 0, 0 ); - - // wait for completion - DMA_WAIT_TAG( (STR_BUF+curr_dst_idx) ); - //--------------------------------------------------------------------------------------------- -} - - -/* - * bilinear_scale_line_w8() - * - * processes a line of yuv-input, width has to be a multiple of 8 - * scaled yuv-output is written to local store buffer - * - * @param src buffer for 2 lines input - * @param dst_ buffer for 1 line output - * @param dst_width the width of the destination line - * @param vf_x_scale a float vector, at each entry is the x_scale-factor - * @param vf_NSweight a float vector, at each position is the weight NORTH/SOUTH for the current line - * @param src_linestride the stride of the srcline - */ -void bilinear_scale_line_w8( unsigned char* src, unsigned char* dst_, unsigned int dst_width, vector float vf_x_scale, vector float vf_NSweight, unsigned int src_linestride ) { - - unsigned char* dst = dst_; - - unsigned int dst_x; - for( dst_x=0; dst_xfirst 4 pixel - // upper range->next 4 pixel - vector unsigned int vui_inc_dst_x_lower_range = { 0, 1, 2, 3 }; - vector unsigned int vui_inc_dst_x_upper_range = { 4, 5, 6, 7 }; - vector unsigned int vui_dst_x_lower_range = spu_add( vui_dst_x_tmp, vui_inc_dst_x_lower_range ); - vector unsigned int vui_dst_x_upper_range = spu_add( vui_dst_x_tmp, vui_inc_dst_x_upper_range ); - - // calculate weight EAST-WEST - vector float vf_dst_x_lower_range = spu_convtf( vui_dst_x_lower_range, 0 ); - vector float vf_dst_x_upper_range = spu_convtf( vui_dst_x_upper_range, 0 ); - vector float vf_src_x_lower_range = spu_mul( vf_dst_x_lower_range, vf_x_scale ); - vector float vf_src_x_upper_range = spu_mul( vf_dst_x_upper_range, vf_x_scale ); - vector unsigned int vui_interpl_x_lower_range = spu_convtu( vf_src_x_lower_range, 0 ); - vector unsigned int vui_interpl_x_upper_range = spu_convtu( vf_src_x_upper_range, 0 ); - vector float vf_interpl_x_lower_range = spu_convtf( vui_interpl_x_lower_range, 0 ); - vector float vf_interpl_x_upper_range = spu_convtf( vui_interpl_x_upper_range, 0 ); - vector float vf_EWweight_lower_range = spu_sub( vf_src_x_lower_range, vf_interpl_x_lower_range ); - vector float vf_EWweight_upper_range = spu_sub( vf_src_x_upper_range, vf_interpl_x_upper_range ); - - // calculate address offset - // - // pixel NORTH WEST - vector unsigned int vui_off_pixelNW_lower_range = vui_interpl_x_lower_range; - vector unsigned int vui_off_pixelNW_upper_range = vui_interpl_x_upper_range; - - // pixel NORTH EAST-->(offpixelNW+1) - vector unsigned int vui_add_1 = { 1, 1, 1, 1 }; - vector unsigned int vui_off_pixelNE_lower_range = spu_add( vui_off_pixelNW_lower_range, vui_add_1 ); - vector unsigned int vui_off_pixelNE_upper_range = spu_add( vui_off_pixelNW_upper_range, vui_add_1 ); - - // SOUTH-WEST-->(offpixelNW+src_linestride) - vector unsigned int vui_srclinestride = spu_splats( src_linestride ); - vector unsigned int vui_off_pixelSW_lower_range = spu_add( vui_srclinestride, vui_off_pixelNW_lower_range ); - vector unsigned int vui_off_pixelSW_upper_range = spu_add( vui_srclinestride, vui_off_pixelNW_upper_range ); - - // SOUTH-EAST-->(offpixelNW+src_linestride+1) - vector unsigned int vui_off_pixelSE_lower_range = spu_add( vui_srclinestride, vui_off_pixelNE_lower_range ); - vector unsigned int vui_off_pixelSE_upper_range = spu_add( vui_srclinestride, vui_off_pixelNE_upper_range ); - - // calculate each address - vector unsigned int vui_src_ls = spu_splats( (unsigned int) src ); - vector unsigned int vui_addr_pixelNW_lower_range = spu_add( vui_src_ls, vui_off_pixelNW_lower_range ); - vector unsigned int vui_addr_pixelNW_upper_range = spu_add( vui_src_ls, vui_off_pixelNW_upper_range ); - vector unsigned int vui_addr_pixelNE_lower_range = spu_add( vui_src_ls, vui_off_pixelNE_lower_range ); - vector unsigned int vui_addr_pixelNE_upper_range = spu_add( vui_src_ls, vui_off_pixelNE_upper_range ); - - vector unsigned int vui_addr_pixelSW_lower_range = spu_add( vui_src_ls, vui_off_pixelSW_lower_range ); - vector unsigned int vui_addr_pixelSW_upper_range = spu_add( vui_src_ls, vui_off_pixelSW_upper_range ); - vector unsigned int vui_addr_pixelSE_lower_range = spu_add( vui_src_ls, vui_off_pixelSE_lower_range ); - vector unsigned int vui_addr_pixelSE_upper_range = spu_add( vui_src_ls, vui_off_pixelSE_upper_range ); - - // get each pixel - // - // scalar load, afterwards insertion into the right position - // NORTH WEST - vector unsigned char null_vector = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - vector unsigned char vuc_pixel_NW_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_lower_range, 0 )), null_vector, 3 ); - vuc_pixel_NW_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_lower_range, 1 )), - vuc_pixel_NW_lower_range, 7 ); - vuc_pixel_NW_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_lower_range, 2 )), - vuc_pixel_NW_lower_range, 11 ); - vuc_pixel_NW_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_lower_range, 3 )), - vuc_pixel_NW_lower_range, 15 ); - - vector unsigned char vuc_pixel_NW_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_upper_range, 0 )), null_vector, 3 ); - vuc_pixel_NW_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_upper_range, 1 )), - vuc_pixel_NW_upper_range, 7 ); - vuc_pixel_NW_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_upper_range, 2 )), - vuc_pixel_NW_upper_range, 11 ); - vuc_pixel_NW_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_upper_range, 3 )), - vuc_pixel_NW_upper_range, 15 ); - - // NORTH EAST - vector unsigned char vuc_pixel_NE_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_lower_range, 0 )), null_vector, 3 ); - vuc_pixel_NE_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_lower_range, 1 )), - vuc_pixel_NE_lower_range, 7 ); - vuc_pixel_NE_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_lower_range, 2 )), - vuc_pixel_NE_lower_range, 11 ); - vuc_pixel_NE_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_lower_range, 3 )), - vuc_pixel_NE_lower_range, 15 ); - - vector unsigned char vuc_pixel_NE_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_upper_range, 0 )), null_vector, 3 ); - vuc_pixel_NE_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_upper_range, 1 )), - vuc_pixel_NE_upper_range, 7 ); - vuc_pixel_NE_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_upper_range, 2 )), - vuc_pixel_NE_upper_range, 11 ); - vuc_pixel_NE_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_upper_range, 3 )), - vuc_pixel_NE_upper_range, 15 ); - - - // SOUTH WEST - vector unsigned char vuc_pixel_SW_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_lower_range, 0 )), null_vector, 3 ); - vuc_pixel_SW_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_lower_range, 1 )), - vuc_pixel_SW_lower_range, 7 ); - vuc_pixel_SW_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_lower_range, 2 )), - vuc_pixel_SW_lower_range, 11 ); - vuc_pixel_SW_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_lower_range, 3 )), - vuc_pixel_SW_lower_range, 15 ); - - vector unsigned char vuc_pixel_SW_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_upper_range, 0 )), null_vector, 3 ); - vuc_pixel_SW_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_upper_range, 1 )), - vuc_pixel_SW_upper_range, 7 ); - vuc_pixel_SW_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_upper_range, 2 )), - vuc_pixel_SW_upper_range, 11 ); - vuc_pixel_SW_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_upper_range, 3 )), - vuc_pixel_SW_upper_range, 15 ); - - // SOUTH EAST - vector unsigned char vuc_pixel_SE_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_lower_range, 0 )), null_vector, 3 ); - vuc_pixel_SE_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_lower_range, 1 )), - vuc_pixel_SE_lower_range, 7 ); - vuc_pixel_SE_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_lower_range, 2 )), - vuc_pixel_SE_lower_range, 11 ); - vuc_pixel_SE_lower_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_lower_range, 3 )), - vuc_pixel_SE_lower_range, 15 ); - - vector unsigned char vuc_pixel_SE_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_upper_range, 0 )), null_vector, 3 ); - vuc_pixel_SE_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_upper_range, 1 )), - vuc_pixel_SE_upper_range, 7 ); - vuc_pixel_SE_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_upper_range, 2 )), - vuc_pixel_SE_upper_range, 11 ); - vuc_pixel_SE_upper_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_upper_range, 3 )), - vuc_pixel_SE_upper_range, 15 ); - - - // convert to float - vector float vf_pixel_NW_lower_range = spu_convtf( (vector unsigned int) vuc_pixel_NW_lower_range, 0 ); - vector float vf_pixel_NW_upper_range = spu_convtf( (vector unsigned int) vuc_pixel_NW_upper_range, 0 ); - - vector float vf_pixel_SW_lower_range = spu_convtf( (vector unsigned int) vuc_pixel_SW_lower_range, 0 ); - vector float vf_pixel_SW_upper_range = spu_convtf( (vector unsigned int) vuc_pixel_SW_upper_range, 0 ); - - vector float vf_pixel_NE_lower_range = spu_convtf( (vector unsigned int) vuc_pixel_NE_lower_range, 0 ); - vector float vf_pixel_NE_upper_range = spu_convtf( (vector unsigned int) vuc_pixel_NE_upper_range, 0 ); - - vector float vf_pixel_SE_lower_range = spu_convtf( (vector unsigned int) vuc_pixel_SE_lower_range, 0 ); - vector float vf_pixel_SE_upper_range = spu_convtf( (vector unsigned int) vuc_pixel_SE_upper_range, 0 ); - - - - // first linear interpolation: EWtop - // EWtop = NW + EWweight*(NE-NW) - // - // lower range - vector float vf_EWtop_lower_range_tmp = spu_sub( vf_pixel_NE_lower_range, vf_pixel_NW_lower_range ); - vector float vf_EWtop_lower_range = spu_madd( vf_EWweight_lower_range, - vf_EWtop_lower_range_tmp, - vf_pixel_NW_lower_range ); - - // upper range - vector float vf_EWtop_upper_range_tmp = spu_sub( vf_pixel_NE_upper_range, vf_pixel_NW_upper_range ); - vector float vf_EWtop_upper_range = spu_madd( vf_EWweight_upper_range, - vf_EWtop_upper_range_tmp, - vf_pixel_NW_upper_range ); - - - - // second linear interpolation: EWbottom - // EWbottom = SW + EWweight*(SE-SW) - // - // lower range - vector float vf_EWbottom_lower_range_tmp = spu_sub( vf_pixel_SE_lower_range, vf_pixel_SW_lower_range ); - vector float vf_EWbottom_lower_range = spu_madd( vf_EWweight_lower_range, - vf_EWbottom_lower_range_tmp, - vf_pixel_SW_lower_range ); - - // upper range - vector float vf_EWbottom_upper_range_tmp = spu_sub( vf_pixel_SE_upper_range, vf_pixel_SW_upper_range ); - vector float vf_EWbottom_upper_range = spu_madd( vf_EWweight_upper_range, - vf_EWbottom_upper_range_tmp, - vf_pixel_SW_upper_range ); - - - - // third linear interpolation: the bilinear interpolated value - // result = EWtop + NSweight*(EWbottom-EWtop); - // - // lower range - vector float vf_result_lower_range_tmp = spu_sub( vf_EWbottom_lower_range, vf_EWtop_lower_range ); - vector float vf_result_lower_range = spu_madd( vf_NSweight, - vf_result_lower_range_tmp, - vf_EWtop_lower_range ); - - // upper range - vector float vf_result_upper_range_tmp = spu_sub( vf_EWbottom_upper_range, vf_EWtop_upper_range ); - vector float vf_result_upper_range = spu_madd( vf_NSweight, - vf_result_upper_range_tmp, - vf_EWtop_upper_range ); - - - // convert back: using saturated arithmetic - vector unsigned int vui_result_lower_range = vfloat_to_vuint( vf_result_lower_range ); - vector unsigned int vui_result_upper_range = vfloat_to_vuint( vf_result_upper_range ); - - // merge results->lower,upper - vector unsigned char vuc_mask_merge_result = { 0x03, 0x07, 0x0B, 0x0F, - 0x13, 0x17, 0x1B, 0x1F, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }; - - vector unsigned char vuc_result = spu_shuffle( (vector unsigned char) vui_result_lower_range, - (vector unsigned char) vui_result_upper_range, - vuc_mask_merge_result ); - - // partial storing - vector unsigned char vuc_mask_out = { 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0xFF, 0xFF, 0xFF, 0xFF, - 0xFF, 0xFF, 0xFF, 0xFF }; - - - // get currently stored data - vector unsigned char vuc_orig = *((vector unsigned char*)dst); - - // clear currently stored data - vuc_orig = spu_and( vuc_orig, - spu_rlqwbyte( vuc_mask_out, ((unsigned int)dst)&0x0F) ); - - // rotate result according to storing address - vuc_result = spu_rlqwbyte( vuc_result, ((unsigned int)dst)&0x0F ); - - // store result - *((vector unsigned char*)dst) = spu_or( vuc_result, - vuc_orig ); - dst += 8; - } -} - - -/* - * bilinear_scale_line_w16() - * - * processes a line of yuv-input, width has to be a multiple of 16 - * scaled yuv-output is written to local store buffer - * - * @param src buffer for 2 lines input - * @param dst_ buffer for 1 line output - * @param dst_width the width of the destination line - * @param vf_x_scale a float vector, at each entry is the x_scale-factor - * @param vf_NSweight a float vector, at each position is the weight NORTH/SOUTH for the current line - * @param src_linestride the stride of the srcline - */ -void bilinear_scale_line_w16( unsigned char* src, unsigned char* dst_, unsigned int dst_width, vector float vf_x_scale, vector float vf_NSweight, unsigned int src_linestride ) { - - unsigned char* dst = dst_; - - unsigned int dst_x; - for( dst_x=0; dst_xpixel 1 2 3 4 - // second range->pixel 5 6 7 8 - // third range->pixel 9 10 11 12 - // fourth range->pixel 13 14 15 16 - vector unsigned int vui_inc_dst_x_first_range = { 0, 1, 2, 3 }; - vector unsigned int vui_inc_dst_x_second_range = { 4, 5, 6, 7 }; - vector unsigned int vui_inc_dst_x_third_range = { 8, 9, 10, 11 }; - vector unsigned int vui_inc_dst_x_fourth_range = { 12, 13, 14, 15 }; - vector unsigned int vui_dst_x_first_range = spu_add( vui_dst_x_tmp, vui_inc_dst_x_first_range ); - vector unsigned int vui_dst_x_second_range = spu_add( vui_dst_x_tmp, vui_inc_dst_x_second_range ); - vector unsigned int vui_dst_x_third_range = spu_add( vui_dst_x_tmp, vui_inc_dst_x_third_range ); - vector unsigned int vui_dst_x_fourth_range = spu_add( vui_dst_x_tmp, vui_inc_dst_x_fourth_range ); - - // calculate weight EAST-WEST - vector float vf_dst_x_first_range = spu_convtf( vui_dst_x_first_range, 0 ); - vector float vf_dst_x_second_range = spu_convtf( vui_dst_x_second_range, 0 ); - vector float vf_dst_x_third_range = spu_convtf( vui_dst_x_third_range, 0 ); - vector float vf_dst_x_fourth_range = spu_convtf( vui_dst_x_fourth_range, 0 ); - vector float vf_src_x_first_range = spu_mul( vf_dst_x_first_range, vf_x_scale ); - vector float vf_src_x_second_range = spu_mul( vf_dst_x_second_range, vf_x_scale ); - vector float vf_src_x_third_range = spu_mul( vf_dst_x_third_range, vf_x_scale ); - vector float vf_src_x_fourth_range = spu_mul( vf_dst_x_fourth_range, vf_x_scale ); - vector unsigned int vui_interpl_x_first_range = spu_convtu( vf_src_x_first_range, 0 ); - vector unsigned int vui_interpl_x_second_range = spu_convtu( vf_src_x_second_range, 0 ); - vector unsigned int vui_interpl_x_third_range = spu_convtu( vf_src_x_third_range, 0 ); - vector unsigned int vui_interpl_x_fourth_range = spu_convtu( vf_src_x_fourth_range, 0 ); - vector float vf_interpl_x_first_range = spu_convtf( vui_interpl_x_first_range, 0 ); - vector float vf_interpl_x_second_range = spu_convtf( vui_interpl_x_second_range, 0 ); - vector float vf_interpl_x_third_range = spu_convtf( vui_interpl_x_third_range, 0 ); - vector float vf_interpl_x_fourth_range = spu_convtf( vui_interpl_x_fourth_range, 0 ); - vector float vf_EWweight_first_range = spu_sub( vf_src_x_first_range, vf_interpl_x_first_range ); - vector float vf_EWweight_second_range = spu_sub( vf_src_x_second_range, vf_interpl_x_second_range ); - vector float vf_EWweight_third_range = spu_sub( vf_src_x_third_range, vf_interpl_x_third_range ); - vector float vf_EWweight_fourth_range = spu_sub( vf_src_x_fourth_range, vf_interpl_x_fourth_range ); - - // calculate address offset - // - // pixel NORTH WEST - vector unsigned int vui_off_pixelNW_first_range = vui_interpl_x_first_range; - vector unsigned int vui_off_pixelNW_second_range = vui_interpl_x_second_range; - vector unsigned int vui_off_pixelNW_third_range = vui_interpl_x_third_range; - vector unsigned int vui_off_pixelNW_fourth_range = vui_interpl_x_fourth_range; - - // pixel NORTH EAST-->(offpixelNW+1) - vector unsigned int vui_add_1 = { 1, 1, 1, 1 }; - vector unsigned int vui_off_pixelNE_first_range = spu_add( vui_off_pixelNW_first_range, vui_add_1 ); - vector unsigned int vui_off_pixelNE_second_range = spu_add( vui_off_pixelNW_second_range, vui_add_1 ); - vector unsigned int vui_off_pixelNE_third_range = spu_add( vui_off_pixelNW_third_range, vui_add_1 ); - vector unsigned int vui_off_pixelNE_fourth_range = spu_add( vui_off_pixelNW_fourth_range, vui_add_1 ); - - // SOUTH-WEST-->(offpixelNW+src_linestride) - vector unsigned int vui_srclinestride = spu_splats( src_linestride ); - vector unsigned int vui_off_pixelSW_first_range = spu_add( vui_srclinestride, vui_off_pixelNW_first_range ); - vector unsigned int vui_off_pixelSW_second_range = spu_add( vui_srclinestride, vui_off_pixelNW_second_range ); - vector unsigned int vui_off_pixelSW_third_range = spu_add( vui_srclinestride, vui_off_pixelNW_third_range ); - vector unsigned int vui_off_pixelSW_fourth_range = spu_add( vui_srclinestride, vui_off_pixelNW_fourth_range ); - - // SOUTH-EAST-->(offpixelNW+src_linestride+1) - vector unsigned int vui_off_pixelSE_first_range = spu_add( vui_srclinestride, vui_off_pixelNE_first_range ); - vector unsigned int vui_off_pixelSE_second_range = spu_add( vui_srclinestride, vui_off_pixelNE_second_range ); - vector unsigned int vui_off_pixelSE_third_range = spu_add( vui_srclinestride, vui_off_pixelNE_third_range ); - vector unsigned int vui_off_pixelSE_fourth_range = spu_add( vui_srclinestride, vui_off_pixelNE_fourth_range ); - - // calculate each address - vector unsigned int vui_src_ls = spu_splats( (unsigned int) src ); - vector unsigned int vui_addr_pixelNW_first_range = spu_add( vui_src_ls, vui_off_pixelNW_first_range ); - vector unsigned int vui_addr_pixelNW_second_range = spu_add( vui_src_ls, vui_off_pixelNW_second_range ); - vector unsigned int vui_addr_pixelNW_third_range = spu_add( vui_src_ls, vui_off_pixelNW_third_range ); - vector unsigned int vui_addr_pixelNW_fourth_range = spu_add( vui_src_ls, vui_off_pixelNW_fourth_range ); - - vector unsigned int vui_addr_pixelNE_first_range = spu_add( vui_src_ls, vui_off_pixelNE_first_range ); - vector unsigned int vui_addr_pixelNE_second_range = spu_add( vui_src_ls, vui_off_pixelNE_second_range ); - vector unsigned int vui_addr_pixelNE_third_range = spu_add( vui_src_ls, vui_off_pixelNE_third_range ); - vector unsigned int vui_addr_pixelNE_fourth_range = spu_add( vui_src_ls, vui_off_pixelNE_fourth_range ); - - vector unsigned int vui_addr_pixelSW_first_range = spu_add( vui_src_ls, vui_off_pixelSW_first_range ); - vector unsigned int vui_addr_pixelSW_second_range = spu_add( vui_src_ls, vui_off_pixelSW_second_range ); - vector unsigned int vui_addr_pixelSW_third_range = spu_add( vui_src_ls, vui_off_pixelSW_third_range ); - vector unsigned int vui_addr_pixelSW_fourth_range = spu_add( vui_src_ls, vui_off_pixelSW_fourth_range ); - - vector unsigned int vui_addr_pixelSE_first_range = spu_add( vui_src_ls, vui_off_pixelSE_first_range ); - vector unsigned int vui_addr_pixelSE_second_range = spu_add( vui_src_ls, vui_off_pixelSE_second_range ); - vector unsigned int vui_addr_pixelSE_third_range = spu_add( vui_src_ls, vui_off_pixelSE_third_range ); - vector unsigned int vui_addr_pixelSE_fourth_range = spu_add( vui_src_ls, vui_off_pixelSE_fourth_range ); - - - // get each pixel - // - // scalar load, afterwards insertion into the right position - // NORTH WEST - // first range - vector unsigned char null_vector = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; - vector unsigned char vuc_pixel_NW_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_first_range, 0 )), null_vector, 3 ); - vuc_pixel_NW_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_first_range, 1 )), - vuc_pixel_NW_first_range, 7 ); - vuc_pixel_NW_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_first_range, 2 )), - vuc_pixel_NW_first_range, 11 ); - vuc_pixel_NW_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_first_range, 3 )), - vuc_pixel_NW_first_range, 15 ); - // second range - vector unsigned char vuc_pixel_NW_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_second_range, 0 )), null_vector, 3 ); - vuc_pixel_NW_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_second_range, 1 )), - vuc_pixel_NW_second_range, 7 ); - vuc_pixel_NW_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_second_range, 2 )), - vuc_pixel_NW_second_range, 11 ); - vuc_pixel_NW_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_second_range, 3 )), - vuc_pixel_NW_second_range, 15 ); - // third range - vector unsigned char vuc_pixel_NW_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_third_range, 0 )), null_vector, 3 ); - vuc_pixel_NW_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_third_range, 1 )), - vuc_pixel_NW_third_range, 7 ); - vuc_pixel_NW_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_third_range, 2 )), - vuc_pixel_NW_third_range, 11 ); - vuc_pixel_NW_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_third_range, 3 )), - vuc_pixel_NW_third_range, 15 ); - // fourth range - vector unsigned char vuc_pixel_NW_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_fourth_range, 0 )), null_vector, 3 ); - vuc_pixel_NW_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_fourth_range, 1 )), - vuc_pixel_NW_fourth_range, 7 ); - vuc_pixel_NW_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_fourth_range, 2 )), - vuc_pixel_NW_fourth_range, 11 ); - vuc_pixel_NW_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNW_fourth_range, 3 )), - vuc_pixel_NW_fourth_range, 15 ); - - // NORTH EAST - // first range - vector unsigned char vuc_pixel_NE_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_first_range, 0 )), null_vector, 3 ); - vuc_pixel_NE_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_first_range, 1 )), - vuc_pixel_NE_first_range, 7 ); - vuc_pixel_NE_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_first_range, 2 )), - vuc_pixel_NE_first_range, 11 ); - vuc_pixel_NE_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_first_range, 3 )), - vuc_pixel_NE_first_range, 15 ); - // second range - vector unsigned char vuc_pixel_NE_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_second_range, 0 )), null_vector, 3 ); - vuc_pixel_NE_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_second_range, 1 )), - vuc_pixel_NE_second_range, 7 ); - vuc_pixel_NE_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_second_range, 2 )), - vuc_pixel_NE_second_range, 11 ); - vuc_pixel_NE_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_second_range, 3 )), - vuc_pixel_NE_second_range, 15 ); - // third range - vector unsigned char vuc_pixel_NE_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_third_range, 0 )), null_vector, 3 ); - vuc_pixel_NE_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_third_range, 1 )), - vuc_pixel_NE_third_range, 7 ); - vuc_pixel_NE_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_third_range, 2 )), - vuc_pixel_NE_third_range, 11 ); - vuc_pixel_NE_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_third_range, 3 )), - vuc_pixel_NE_third_range, 15 ); - // fourth range - vector unsigned char vuc_pixel_NE_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_fourth_range, 0 )), null_vector, 3 ); - vuc_pixel_NE_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_fourth_range, 1 )), - vuc_pixel_NE_fourth_range, 7 ); - vuc_pixel_NE_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_fourth_range, 2 )), - vuc_pixel_NE_fourth_range, 11 ); - vuc_pixel_NE_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelNE_fourth_range, 3 )), - vuc_pixel_NE_fourth_range, 15 ); - - // SOUTH WEST - // first range - vector unsigned char vuc_pixel_SW_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_first_range, 0 )), null_vector, 3 ); - vuc_pixel_SW_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_first_range, 1 )), - vuc_pixel_SW_first_range, 7 ); - vuc_pixel_SW_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_first_range, 2 )), - vuc_pixel_SW_first_range, 11 ); - vuc_pixel_SW_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_first_range, 3 )), - vuc_pixel_SW_first_range, 15 ); - // second range - vector unsigned char vuc_pixel_SW_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_second_range, 0 )), null_vector, 3 ); - vuc_pixel_SW_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_second_range, 1 )), - vuc_pixel_SW_second_range, 7 ); - vuc_pixel_SW_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_second_range, 2 )), - vuc_pixel_SW_second_range, 11 ); - vuc_pixel_SW_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_second_range, 3 )), - vuc_pixel_SW_second_range, 15 ); - // third range - vector unsigned char vuc_pixel_SW_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_third_range, 0 )), null_vector, 3 ); - vuc_pixel_SW_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_third_range, 1 )), - vuc_pixel_SW_third_range, 7 ); - vuc_pixel_SW_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_third_range, 2 )), - vuc_pixel_SW_third_range, 11 ); - vuc_pixel_SW_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_third_range, 3 )), - vuc_pixel_SW_third_range, 15 ); - // fourth range - vector unsigned char vuc_pixel_SW_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_fourth_range, 0 )), null_vector, 3 ); - vuc_pixel_SW_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_fourth_range, 1 )), - vuc_pixel_SW_fourth_range, 7 ); - vuc_pixel_SW_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_fourth_range, 2 )), - vuc_pixel_SW_fourth_range, 11 ); - vuc_pixel_SW_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSW_fourth_range, 3 )), - vuc_pixel_SW_fourth_range, 15 ); - - // NORTH EAST - // first range - vector unsigned char vuc_pixel_SE_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_first_range, 0 )), null_vector, 3 ); - vuc_pixel_SE_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_first_range, 1 )), - vuc_pixel_SE_first_range, 7 ); - vuc_pixel_SE_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_first_range, 2 )), - vuc_pixel_SE_first_range, 11 ); - vuc_pixel_SE_first_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_first_range, 3 )), - vuc_pixel_SE_first_range, 15 ); - // second range - vector unsigned char vuc_pixel_SE_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_second_range, 0 )), null_vector, 3 ); - vuc_pixel_SE_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_second_range, 1 )), - vuc_pixel_SE_second_range, 7 ); - vuc_pixel_SE_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_second_range, 2 )), - vuc_pixel_SE_second_range, 11 ); - vuc_pixel_SE_second_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_second_range, 3 )), - vuc_pixel_SE_second_range, 15 ); - // third range - vector unsigned char vuc_pixel_SE_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_third_range, 0 )), null_vector, 3 ); - vuc_pixel_SE_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_third_range, 1 )), - vuc_pixel_SE_third_range, 7 ); - vuc_pixel_SE_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_third_range, 2 )), - vuc_pixel_SE_third_range, 11 ); - vuc_pixel_SE_third_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_third_range, 3 )), - vuc_pixel_SE_third_range, 15 ); - // fourth range - vector unsigned char vuc_pixel_SE_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_fourth_range, 0 )), null_vector, 3 ); - vuc_pixel_SE_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_fourth_range, 1 )), - vuc_pixel_SE_fourth_range, 7 ); - vuc_pixel_SE_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_fourth_range, 2 )), - vuc_pixel_SE_fourth_range, 11 ); - vuc_pixel_SE_fourth_range = spu_insert( - *((unsigned char*) spu_extract( vui_addr_pixelSE_fourth_range, 3 )), - vuc_pixel_SE_fourth_range, 15 ); - - - - // convert to float - vector float vf_pixel_NW_first_range = spu_convtf( (vector unsigned int) vuc_pixel_NW_first_range, 0 ); - vector float vf_pixel_NW_second_range = spu_convtf( (vector unsigned int) vuc_pixel_NW_second_range, 0 ); - vector float vf_pixel_NW_third_range = spu_convtf( (vector unsigned int) vuc_pixel_NW_third_range, 0 ); - vector float vf_pixel_NW_fourth_range = spu_convtf( (vector unsigned int) vuc_pixel_NW_fourth_range, 0 ); - - vector float vf_pixel_NE_first_range = spu_convtf( (vector unsigned int) vuc_pixel_NE_first_range, 0 ); - vector float vf_pixel_NE_second_range = spu_convtf( (vector unsigned int) vuc_pixel_NE_second_range, 0 ); - vector float vf_pixel_NE_third_range = spu_convtf( (vector unsigned int) vuc_pixel_NE_third_range, 0 ); - vector float vf_pixel_NE_fourth_range = spu_convtf( (vector unsigned int) vuc_pixel_NE_fourth_range, 0 ); - - vector float vf_pixel_SW_first_range = spu_convtf( (vector unsigned int) vuc_pixel_SW_first_range, 0 ); - vector float vf_pixel_SW_second_range = spu_convtf( (vector unsigned int) vuc_pixel_SW_second_range, 0 ); - vector float vf_pixel_SW_third_range = spu_convtf( (vector unsigned int) vuc_pixel_SW_third_range, 0 ); - vector float vf_pixel_SW_fourth_range = spu_convtf( (vector unsigned int) vuc_pixel_SW_fourth_range, 0 ); - - vector float vf_pixel_SE_first_range = spu_convtf( (vector unsigned int) vuc_pixel_SE_first_range, 0 ); - vector float vf_pixel_SE_second_range = spu_convtf( (vector unsigned int) vuc_pixel_SE_second_range, 0 ); - vector float vf_pixel_SE_third_range = spu_convtf( (vector unsigned int) vuc_pixel_SE_third_range, 0 ); - vector float vf_pixel_SE_fourth_range = spu_convtf( (vector unsigned int) vuc_pixel_SE_fourth_range, 0 ); - - // first linear interpolation: EWtop - // EWtop = NW + EWweight*(NE-NW) - // - // first range - vector float vf_EWtop_first_range_tmp = spu_sub( vf_pixel_NE_first_range, vf_pixel_NW_first_range ); - vector float vf_EWtop_first_range = spu_madd( vf_EWweight_first_range, - vf_EWtop_first_range_tmp, - vf_pixel_NW_first_range ); - - // second range - vector float vf_EWtop_second_range_tmp = spu_sub( vf_pixel_NE_second_range, vf_pixel_NW_second_range ); - vector float vf_EWtop_second_range = spu_madd( vf_EWweight_second_range, - vf_EWtop_second_range_tmp, - vf_pixel_NW_second_range ); - - // third range - vector float vf_EWtop_third_range_tmp = spu_sub( vf_pixel_NE_third_range, vf_pixel_NW_third_range ); - vector float vf_EWtop_third_range = spu_madd( vf_EWweight_third_range, - vf_EWtop_third_range_tmp, - vf_pixel_NW_third_range ); - - // fourth range - vector float vf_EWtop_fourth_range_tmp = spu_sub( vf_pixel_NE_fourth_range, vf_pixel_NW_fourth_range ); - vector float vf_EWtop_fourth_range = spu_madd( vf_EWweight_fourth_range, - vf_EWtop_fourth_range_tmp, - vf_pixel_NW_fourth_range ); - - - - // second linear interpolation: EWbottom - // EWbottom = SW + EWweight*(SE-SW) - // - // first range - vector float vf_EWbottom_first_range_tmp = spu_sub( vf_pixel_SE_first_range, vf_pixel_SW_first_range ); - vector float vf_EWbottom_first_range = spu_madd( vf_EWweight_first_range, - vf_EWbottom_first_range_tmp, - vf_pixel_SW_first_range ); - - // second range - vector float vf_EWbottom_second_range_tmp = spu_sub( vf_pixel_SE_second_range, vf_pixel_SW_second_range ); - vector float vf_EWbottom_second_range = spu_madd( vf_EWweight_second_range, - vf_EWbottom_second_range_tmp, - vf_pixel_SW_second_range ); - // first range - vector float vf_EWbottom_third_range_tmp = spu_sub( vf_pixel_SE_third_range, vf_pixel_SW_third_range ); - vector float vf_EWbottom_third_range = spu_madd( vf_EWweight_third_range, - vf_EWbottom_third_range_tmp, - vf_pixel_SW_third_range ); - - // first range - vector float vf_EWbottom_fourth_range_tmp = spu_sub( vf_pixel_SE_fourth_range, vf_pixel_SW_fourth_range ); - vector float vf_EWbottom_fourth_range = spu_madd( vf_EWweight_fourth_range, - vf_EWbottom_fourth_range_tmp, - vf_pixel_SW_fourth_range ); - - - - // third linear interpolation: the bilinear interpolated value - // result = EWtop + NSweight*(EWbottom-EWtop); - // - // first range - vector float vf_result_first_range_tmp = spu_sub( vf_EWbottom_first_range, vf_EWtop_first_range ); - vector float vf_result_first_range = spu_madd( vf_NSweight, - vf_result_first_range_tmp, - vf_EWtop_first_range ); - - // second range - vector float vf_result_second_range_tmp = spu_sub( vf_EWbottom_second_range, vf_EWtop_second_range ); - vector float vf_result_second_range = spu_madd( vf_NSweight, - vf_result_second_range_tmp, - vf_EWtop_second_range ); - - // third range - vector float vf_result_third_range_tmp = spu_sub( vf_EWbottom_third_range, vf_EWtop_third_range ); - vector float vf_result_third_range = spu_madd( vf_NSweight, - vf_result_third_range_tmp, - vf_EWtop_third_range ); - - // fourth range - vector float vf_result_fourth_range_tmp = spu_sub( vf_EWbottom_fourth_range, vf_EWtop_fourth_range ); - vector float vf_result_fourth_range = spu_madd( vf_NSweight, - vf_result_fourth_range_tmp, - vf_EWtop_fourth_range ); - - - - // convert back: using saturated arithmetic - vector unsigned int vui_result_first_range = vfloat_to_vuint( vf_result_first_range ); - vector unsigned int vui_result_second_range = vfloat_to_vuint( vf_result_second_range ); - vector unsigned int vui_result_third_range = vfloat_to_vuint( vf_result_third_range ); - vector unsigned int vui_result_fourth_range = vfloat_to_vuint( vf_result_fourth_range ); - - // merge results->lower,upper - vector unsigned char vuc_mask_merge_result_first_second = { 0x03, 0x07, 0x0B, 0x0F, - 0x13, 0x17, 0x1B, 0x1F, - 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00 }; - - vector unsigned char vuc_mask_merge_result_third_fourth = { 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, - 0x03, 0x07, 0x0B, 0x0F, - 0x13, 0x17, 0x1B, 0x1F }; - - vector unsigned char vuc_result_first_second = - spu_shuffle( (vector unsigned char) vui_result_first_range, - (vector unsigned char) vui_result_second_range, - vuc_mask_merge_result_first_second ); - - vector unsigned char vuc_result_third_fourth = - spu_shuffle( (vector unsigned char) vui_result_third_range, - (vector unsigned char) vui_result_fourth_range, - vuc_mask_merge_result_third_fourth ); - - // store result - *((vector unsigned char*)dst) = spu_or( vuc_result_first_second, - vuc_result_third_fourth ); - dst += 16; - } -} - diff --git a/project/jni/sdl-1.3/src/video/ps3/spulibs/fb_writer.c b/project/jni/sdl-1.3/src/video/ps3/spulibs/fb_writer.c deleted file mode 100644 index 0eb51cc68..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/spulibs/fb_writer.c +++ /dev/null @@ -1,193 +0,0 @@ -/* - * SDL - Simple DirectMedia Layer - * CELL BE Support for PS3 Framebuffer - * Copyright (C) 2008, 2009 International Business Machines Corporation - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Martin Lowinski - * Dirk Herrendoerfer - * SPE code based on research by: - * Rene Becker - * Thimo Emmerich - */ - -#include "spu_common.h" - -#include -#include -#include -#include - -// Debugging -//#define DEBUG - -#ifdef DEBUG -#define deprintf(fmt, args... ) \ - fprintf( stdout, fmt, ##args ); \ - fflush( stdout ); -#else -#define deprintf( fmt, args... ) -#endif - -void cpy_to_fb(unsigned int); - -/* fb_writer_spu parms */ -static volatile struct fb_writer_parms_t parms __attribute__ ((aligned(128))); - -/* Code running on SPU */ -int main(unsigned long long spe_id __attribute__ ((unused)), unsigned long long argp __attribute__ ((unused))) -{ - deprintf("[SPU] fb_writer_spu is up... (on SPE #%llu)\n", spe_id); - uint32_t ea_mfc, mbox; - // send ready message - spu_write_out_mbox(SPU_READY); - - while (1) { - /* Check mailbox */ - mbox = spu_read_in_mbox(); - deprintf("[SPU] Message is %u\n", mbox); - switch (mbox) { - case SPU_EXIT: - deprintf("[SPU] fb_writer goes down...\n"); - return 0; - case SPU_START: - break; - default: - deprintf("[SPU] Cannot handle message\n"); - continue; - } - - /* Tag Manager setup */ - unsigned int tags; - tags = mfc_multi_tag_reserve(5); - if (tags == MFC_TAG_INVALID) { - deprintf("[SPU] Failed to reserve mfc tags on fb_writer\n"); - return 0; - } - - /* Framebuffer parms */ - ea_mfc = spu_read_in_mbox(); - deprintf("[SPU] Message on fb_writer is %u\n", ea_mfc); - spu_mfcdma32(&parms, (unsigned int)ea_mfc, - sizeof(struct fb_writer_parms_t), tags, - MFC_GET_CMD); - deprintf("[SPU] argp = %u\n", (unsigned int)argp); - DMA_WAIT_TAG(tags); - - /* Copy parms->data to framebuffer */ - deprintf("[SPU] Copying to framebuffer started\n"); - cpy_to_fb(tags); - deprintf("[SPU] Copying to framebuffer done!\n"); - - mfc_multi_tag_release(tags, 5); - deprintf("[SPU] fb_writer_spu... done!\n"); - /* Send FIN msg */ - spu_write_out_mbox(SPU_FIN); - } - - return 0; -} - -void cpy_to_fb(unsigned int tag_id_base) -{ - unsigned int i; - unsigned char current_buf; - uint8_t *in = parms.data; - - /* Align fb pointer which was centered before */ - uint8_t *fb = - (unsigned char *)((unsigned int)parms.center & 0xFFFFFFF0); - - uint32_t bounded_input_height = parms.bounded_input_height; - uint32_t bounded_input_width = parms.bounded_input_width; - uint32_t fb_pixel_size = parms.fb_pixel_size; - - uint32_t out_line_stride = parms.out_line_stride; - uint32_t in_line_stride = parms.in_line_stride; - uint32_t in_line_size = bounded_input_width * fb_pixel_size; - - current_buf = 0; - - /* Local store buffer */ - static volatile uint8_t buf[4][BUFFER_SIZE] - __attribute__ ((aligned(128))); - /* do 4-times multibuffering using DMA list, process in two steps */ - for (i = 0; i < bounded_input_height >> 2; i++) { - /* first buffer */ - DMA_WAIT_TAG(tag_id_base + 1); - // retrieve buffer - spu_mfcdma32(buf[0], (unsigned int)in, in_line_size, - tag_id_base + 1, MFC_GETB_CMD); - DMA_WAIT_TAG(tag_id_base + 1); - // store buffer - spu_mfcdma32(buf[0], (unsigned int)fb, in_line_size, - tag_id_base + 1, MFC_PUTB_CMD); - in += in_line_stride; - fb += out_line_stride; - deprintf("[SPU] 1st buffer copied in=0x%x, fb=0x%x\n", in, - fb); - - /* second buffer */ - DMA_WAIT_TAG(tag_id_base + 2); - // retrieve buffer - spu_mfcdma32(buf[1], (unsigned int)in, in_line_size, - tag_id_base + 2, MFC_GETB_CMD); - DMA_WAIT_TAG(tag_id_base + 2); - // store buffer - spu_mfcdma32(buf[1], (unsigned int)fb, in_line_size, - tag_id_base + 2, MFC_PUTB_CMD); - in += in_line_stride; - fb += out_line_stride; - deprintf("[SPU] 2nd buffer copied in=0x%x, fb=0x%x\n", in, - fb); - - /* third buffer */ - DMA_WAIT_TAG(tag_id_base + 3); - // retrieve buffer - spu_mfcdma32(buf[2], (unsigned int)in, in_line_size, - tag_id_base + 3, MFC_GETB_CMD); - DMA_WAIT_TAG(tag_id_base + 3); - // store buffer - spu_mfcdma32(buf[2], (unsigned int)fb, in_line_size, - tag_id_base + 3, MFC_PUTB_CMD); - in += in_line_stride; - fb += out_line_stride; - deprintf("[SPU] 3rd buffer copied in=0x%x, fb=0x%x\n", in, - fb); - - /* fourth buffer */ - DMA_WAIT_TAG(tag_id_base + 4); - // retrieve buffer - spu_mfcdma32(buf[3], (unsigned int)in, in_line_size, - tag_id_base + 4, MFC_GETB_CMD); - DMA_WAIT_TAG(tag_id_base + 4); - // store buffer - spu_mfcdma32(buf[3], (unsigned int)fb, in_line_size, - tag_id_base + 4, MFC_PUTB_CMD); - in += in_line_stride; - fb += out_line_stride; - deprintf("[SPU] 4th buffer copied in=0x%x, fb=0x%x\n", in, - fb); - deprintf("[SPU] Loop #%i, bounded_input_height=%i\n", i, - bounded_input_height >> 2); - } - DMA_WAIT_TAG(tag_id_base + 2); - DMA_WAIT_TAG(tag_id_base + 3); - DMA_WAIT_TAG(tag_id_base + 4); -} - - diff --git a/project/jni/sdl-1.3/src/video/ps3/spulibs/spu_common.h b/project/jni/sdl-1.3/src/video/ps3/spulibs/spu_common.h deleted file mode 100644 index 42c328c83..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/spulibs/spu_common.h +++ /dev/null @@ -1,108 +0,0 @@ -/* - * SDL - Simple DirectMedia Layer - * CELL BE Support for PS3 Framebuffer - * Copyright (C) 2008, 2009 International Business Machines Corporation - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Martin Lowinski - * Dirk Herrendoerfer - * SPE code based on research by: - * Rene Becker - * Thimo Emmerich - */ - -/* Common definitions/makros for SPUs */ - -#ifndef _SPU_COMMON_H -#define _SPU_COMMON_H - -#include -#include -#include - -/* Tag management */ -#define DMA_WAIT_TAG(_tag) \ - mfc_write_tag_mask(1<<(_tag)); \ - mfc_read_tag_status_all(); - -/* SPU mailbox messages */ -#define SPU_READY 0 -#define SPU_START 1 -#define SPU_FIN 2 -#define SPU_EXIT 3 - -/* Tags */ -#define RETR_BUF 0 -#define STR_BUF 1 -#define TAG_INIT 2 - -/* Buffersizes */ -#define MAX_HDTV_WIDTH 1920 -#define MAX_HDTV_HEIGHT 1080 -/* One stride of HDTV */ -#define BUFFER_SIZE 7680 - -/* fb_writer ppu/spu exchange parms */ -struct fb_writer_parms_t { - uint8_t *data; - uint8_t *center; - uint32_t out_line_stride; - uint32_t in_line_stride; - uint32_t bounded_input_height; - uint32_t bounded_input_width; - uint32_t fb_pixel_size; - - /* This padding is to fulfill the need for 16 byte alignment. On parm change, update! */ - char padding[4]; -} __attribute__((aligned(128))); - -/* yuv2rgb ppu/spu exchange parms */ -struct yuv2rgb_parms_t { - uint8_t* y_plane; - uint8_t* v_plane; - uint8_t* u_plane; - - uint8_t* dstBuffer; - - unsigned int src_pixel_width; - unsigned int src_pixel_height; - - /* This padding is to fulfill the need for 16 byte alignment. On parm change, update! */ - char padding[128 - ((4 * sizeof(uint8_t *) + 2 * sizeof(unsigned int)) & 0x7F)]; -} __attribute__((aligned(128))); - -/* bilin_scaler ppu/spu exchange parms */ -struct scale_parms_t { - uint8_t* y_plane; - uint8_t* v_plane; - uint8_t* u_plane; - - uint8_t* dstBuffer; - - unsigned int src_pixel_width; - unsigned int src_pixel_height; - - unsigned int dst_pixel_width; - unsigned int dst_pixel_height; - - /* This padding is to fulfill the need for 16 byte alignment. On parm change, update! */ - char padding[128 - ((4 * sizeof(uint8_t *) + 4 * sizeof(unsigned int)) & 0x7F)]; -} __attribute__((aligned(128))); - -#endif /* _SPU_COMMON_H */ - - diff --git a/project/jni/sdl-1.3/src/video/ps3/spulibs/yuv2rgb.c b/project/jni/sdl-1.3/src/video/ps3/spulibs/yuv2rgb.c deleted file mode 100644 index 058ada2cd..000000000 --- a/project/jni/sdl-1.3/src/video/ps3/spulibs/yuv2rgb.c +++ /dev/null @@ -1,662 +0,0 @@ -/* - * SDL - Simple DirectMedia Layer - * CELL BE Support for PS3 Framebuffer - * Copyright (C) 2008, 2009 International Business Machines Corporation - * - * This library is free software; you can redistribute it and/or modify it - * under the terms of the GNU Lesser General Public License as published - * by the Free Software Foundation; either version 2.1 of the License, or - * (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 - * USA - * - * Martin Lowinski - * Dirk Herrendoerfer - * SPE code based on research by: - * Rene Becker - * Thimo Emmerich - */ - -#include "spu_common.h" - -#include -#include - -// Debugging -//#define DEBUG - -// Test environment for /2 resolutions -//#define TESTING - -#ifdef DEBUG -#define deprintf(fmt, args... ) \ - fprintf( stdout, fmt, ##args ); \ - fflush( stdout ); -#else -#define deprintf( fmt, args... ) -#endif - -struct yuv2rgb_parms_t parms_converter __attribute__((aligned(128))); - -/* A maximum of 8 lines Y, therefore 4 lines V, 4 lines U are stored - * there might be the need to retrieve misaligned data, adjust - * incoming v and u plane to be able to handle this (add 128) - */ -unsigned char y_plane[2][(MAX_HDTV_WIDTH + 128) * 4] __attribute__((aligned(128))); -unsigned char v_plane[2][(MAX_HDTV_WIDTH + 128) * 2] __attribute__((aligned(128))); -unsigned char u_plane[2][(MAX_HDTV_WIDTH + 128) * 2] __attribute__((aligned(128))); - -/* A maximum of 4 lines BGRA are stored, 4 byte per pixel */ -unsigned char bgra[4 * MAX_HDTV_WIDTH * 4] __attribute__((aligned(128))); - -/* some vectors needed by the float to int conversion */ -static const vector float vec_255 = { 255.0f, 255.0f, 255.0f, 255.0f }; -static const vector float vec_0_1 = { 0.1f, 0.1f, 0.1f, 0.1f }; - -void yuv_to_rgb_w16(); -void yuv_to_rgb_w32(); - -void yuv_to_rgb_w2_line(unsigned char* y_addr, unsigned char* v_addr, unsigned char* u_addr, unsigned char* bgra_addr, unsigned int width); -void yuv_to_rgb_w32_line(unsigned char* y_addr, unsigned char* v_addr, unsigned char* u_addr, unsigned char* bgra_addr_, unsigned int width); - - -int main(unsigned long long spe_id __attribute__((unused)), unsigned long long argp __attribute__ ((unused))) -{ - deprintf("[SPU] yuv2rgb_spu is up... (on SPE #%llu)\n", spe_id); - uint32_t ea_mfc, mbox; - // send ready message - spu_write_out_mbox(SPU_READY); - - while (1) { - /* Check mailbox */ - mbox = spu_read_in_mbox(); - deprintf("[SPU] Message is %u\n", mbox); - switch (mbox) { - case SPU_EXIT: - deprintf("[SPU] yuv2rgb_converter goes down...\n"); - return 0; - case SPU_START: - break; - default: - deprintf("[SPU] Cannot handle message\n"); - continue; - } - - /* Tag Manager setup */ - unsigned int tag_id; - tag_id = mfc_multi_tag_reserve(1); - if (tag_id == MFC_TAG_INVALID) { - deprintf("[SPU] Failed to reserve mfc tags on yuv2rgb_converter\n"); - return 0; - } - - /* DMA transfer for the input parameters */ - ea_mfc = spu_read_in_mbox(); - deprintf("[SPU] Message on yuv2rgb_converter is %u\n", ea_mfc); - spu_mfcdma32(&parms_converter, (unsigned int)ea_mfc, sizeof(struct yuv2rgb_parms_t), tag_id, MFC_GET_CMD); - DMA_WAIT_TAG(tag_id); - - /* There are alignment issues that involve handling of special cases - * a width of 32 results in a width of 16 in the chrominance - * --> choose the proper handling to optimize the performance - */ - deprintf("[SPU] Convert %ix%i from YUV to RGB\n", parms_converter.src_pixel_width, parms_converter.src_pixel_height); - if (!(parms_converter.src_pixel_width & 0x1f)) { - deprintf("[SPU] Using yuv_to_rgb_w16\n"); - yuv_to_rgb_w16(); - } else { - deprintf("[SPU] Using yuv_to_rgb_w32\n"); - yuv_to_rgb_w32(); - } - - mfc_multi_tag_release(tag_id, 1); - deprintf("[SPU] yuv2rgb_spu... done!\n"); - /* Send FIN message */ - spu_write_out_mbox(SPU_FIN); - } - - return 0; -} - - -/* - * float_to_char() - * - * converts a float to a character using saturated - * arithmetic - * - * @param s float for conversion - * @returns converted character - */ -inline static unsigned char float_to_char(float s) { - vector float vec_s = spu_splats(s); - vector unsigned int select_1 = spu_cmpgt(vec_0_1, vec_s); - vec_s = spu_sel(vec_s, vec_0_1, select_1); - - vector unsigned int select_2 = spu_cmpgt(vec_s, vec_255); - vec_s = spu_sel(vec_s, vec_255, select_2); - return (unsigned char) spu_extract(vec_s,0); -} - - -/* - * vfloat_to_vuint() - * - * converts a float vector to an unsinged int vector using saturated - * arithmetic - * - * @param vec_s float vector for conversion - * @returns converted unsigned int vector - */ -inline static vector unsigned int vfloat_to_vuint(vector float vec_s) { - vector unsigned int select_1 = spu_cmpgt(vec_0_1, vec_s); - vec_s = spu_sel(vec_s, vec_0_1, select_1); - - vector unsigned int select_2 = spu_cmpgt(vec_s, vec_255); - vec_s = spu_sel(vec_s, vec_255, select_2); - return spu_convtu(vec_s,0); -} - - -void yuv_to_rgb_w16() { - // Pixel dimensions of the picture - uint32_t width, height; - - // Extract parameters - width = parms_converter.src_pixel_width; - height = parms_converter.src_pixel_height; - - // Plane data management - // Y - unsigned char* ram_addr_y = parms_converter.y_plane; - // V - unsigned char* ram_addr_v = parms_converter.v_plane; - // U - unsigned char* ram_addr_u = parms_converter.u_plane; - - // BGRA - unsigned char* ram_addr_bgra = parms_converter.dstBuffer; - - // Strides - unsigned int stride_y = width; - unsigned int stride_vu = width>>1; - - // Buffer management - unsigned int buf_idx = 0; - unsigned int size_4lines_y = stride_y<<2; - unsigned int size_2lines_y = stride_y<<1; - unsigned int size_2lines_vu = stride_vu<<1; - - // 2*width*4byte_per_pixel - unsigned int size_2lines_bgra = width<<3; - - - // start double-buffered processing - // 4 lines y - spu_mfcdma32(y_plane[buf_idx], (unsigned int) ram_addr_y, size_4lines_y, RETR_BUF+buf_idx, MFC_GET_CMD); - - // 2 lines v - spu_mfcdma32(v_plane[buf_idx], (unsigned int) ram_addr_v, size_2lines_vu, RETR_BUF+buf_idx, MFC_GET_CMD); - - // 2 lines u - spu_mfcdma32(u_plane[buf_idx], (unsigned int) ram_addr_u, size_2lines_vu, RETR_BUF+buf_idx, MFC_GET_CMD); - - // Wait for these transfers to be completed - DMA_WAIT_TAG((RETR_BUF + buf_idx)); - - unsigned int i; - for(i=0; i<(height>>2)-1; i++) { - - buf_idx^=1; - - // 4 lines y - spu_mfcdma32(y_plane[buf_idx], (unsigned int) ram_addr_y+size_4lines_y, size_4lines_y, RETR_BUF+buf_idx, MFC_GET_CMD); - - // 2 lines v - spu_mfcdma32(v_plane[buf_idx], (unsigned int) ram_addr_v+size_2lines_vu, size_2lines_vu, RETR_BUF+buf_idx, MFC_GET_CMD); - - // 2 lines u - spu_mfcdma32(u_plane[buf_idx], (unsigned int) ram_addr_u+size_2lines_vu, size_2lines_vu, RETR_BUF+buf_idx, MFC_GET_CMD); - - DMA_WAIT_TAG((RETR_BUF + buf_idx)); - - buf_idx^=1; - - - // Convert YUV to BGRA, store it back (first two lines) -#ifndef TESTING - yuv_to_rgb_w16_line(y_plane[buf_idx], v_plane[buf_idx], u_plane[buf_idx], bgra, width); - - // Next two lines - yuv_to_rgb_w16_line(y_plane[buf_idx] + size_2lines_y, - v_plane[buf_idx] + stride_vu, - u_plane[buf_idx] + stride_vu, - bgra + size_2lines_bgra, - width); -#else - yuv_to_rgb_w2_line(y_plane[buf_idx], v_plane[buf_idx], u_plane[buf_idx], bgra, width); - - // Next two lines - yuv_to_rgb_w2_line(y_plane[buf_idx] + size_2lines_y, - v_plane[buf_idx] + stride_vu, - u_plane[buf_idx] + stride_vu, - bgra + size_2lines_bgra, - width); -#endif - - // Wait for previous storing transfer to be completed - DMA_WAIT_TAG(STR_BUF); - - // Store converted lines in two steps->max transfer size 16384 - spu_mfcdma32(bgra, (unsigned int) ram_addr_bgra, size_2lines_bgra, STR_BUF, MFC_PUT_CMD); - ram_addr_bgra += size_2lines_bgra; - spu_mfcdma32(bgra+size_2lines_bgra, (unsigned int) ram_addr_bgra, size_2lines_bgra, STR_BUF, MFC_PUT_CMD); - ram_addr_bgra += size_2lines_bgra; - - // Move 4 lines - ram_addr_y += size_4lines_y; - ram_addr_v += size_2lines_vu; - ram_addr_u += size_2lines_vu; - - buf_idx^=1; - } - -#ifndef TESTING - // Convert YUV to BGRA, store it back (first two lines) - yuv_to_rgb_w16_line(y_plane[buf_idx], v_plane[buf_idx], u_plane[buf_idx], bgra, width); - - // Next two lines - yuv_to_rgb_w16_line(y_plane[buf_idx] + size_2lines_y, - v_plane[buf_idx] + stride_vu, - u_plane[buf_idx] + stride_vu, - bgra + size_2lines_bgra, - width); -#else - // Convert YUV to BGRA, store it back (first two lines) - yuv_to_rgb_w2_line(y_plane[buf_idx], v_plane[buf_idx], u_plane[buf_idx], bgra, width); - - // Next two lines - yuv_to_rgb_w2_line(y_plane[buf_idx] + size_2lines_y, - v_plane[buf_idx] + stride_vu, - u_plane[buf_idx] + stride_vu, - bgra + size_2lines_bgra, - width); -#endif - - // Wait for previous storing transfer to be completed - DMA_WAIT_TAG(STR_BUF); - spu_mfcdma32(bgra, (unsigned int) ram_addr_bgra, size_2lines_bgra, STR_BUF, MFC_PUT_CMD); - ram_addr_bgra += size_2lines_bgra; - spu_mfcdma32(bgra+size_2lines_bgra, (unsigned int) ram_addr_bgra, size_2lines_bgra, STR_BUF, MFC_PUT_CMD); - - // wait for previous storing transfer to be completed - DMA_WAIT_TAG(STR_BUF); - -} - - -void yuv_to_rgb_w32() { - // Pixel dimensions of the picture - uint32_t width, height; - - // Extract parameters - width = parms_converter.src_pixel_width; - height = parms_converter.src_pixel_height; - - // Plane data management - // Y - unsigned char* ram_addr_y = parms_converter.y_plane; - // V - unsigned char* ram_addr_v = parms_converter.v_plane; - // U - unsigned char* ram_addr_u = parms_converter.u_plane; - - // BGRA - unsigned char* ram_addr_bgra = parms_converter.dstBuffer; - - // Strides - unsigned int stride_y = width; - unsigned int stride_vu = width>>1; - - // Buffer management - unsigned int buf_idx = 0; - unsigned int size_4lines_y = stride_y<<2; - unsigned int size_2lines_y = stride_y<<1; - unsigned int size_2lines_vu = stride_vu<<1; - - // 2*width*4byte_per_pixel - unsigned int size_2lines_bgra = width<<3; - - // start double-buffered processing - // 4 lines y - spu_mfcdma32(y_plane[buf_idx], (unsigned int) ram_addr_y, size_4lines_y, RETR_BUF + buf_idx, MFC_GET_CMD); - // 2 lines v - spu_mfcdma32(v_plane[buf_idx], (unsigned int) ram_addr_v, size_2lines_vu, RETR_BUF + buf_idx, MFC_GET_CMD); - // 2 lines u - spu_mfcdma32(u_plane[buf_idx], (unsigned int) ram_addr_u, size_2lines_vu, RETR_BUF + buf_idx, MFC_GET_CMD); - - // Wait for these transfers to be completed - DMA_WAIT_TAG((RETR_BUF + buf_idx)); - - unsigned int i; - for(i=0; i < (height>>2)-1; i++) { - buf_idx^=1; - // 4 lines y - spu_mfcdma32(y_plane[buf_idx], (unsigned int) ram_addr_y+size_4lines_y, size_4lines_y, RETR_BUF + buf_idx, MFC_GET_CMD); - deprintf("4lines = %d\n", size_4lines_y); - // 2 lines v - spu_mfcdma32(v_plane[buf_idx], (unsigned int) ram_addr_v+size_2lines_vu, size_2lines_vu, RETR_BUF + buf_idx, MFC_GET_CMD); - deprintf("2lines = %d\n", size_2lines_vu); - // 2 lines u - spu_mfcdma32(u_plane[buf_idx], (unsigned int) ram_addr_u+size_2lines_vu, size_2lines_vu, RETR_BUF + buf_idx, MFC_GET_CMD); - deprintf("2lines = %d\n", size_2lines_vu); - - DMA_WAIT_TAG((RETR_BUF + buf_idx)); - - buf_idx^=1; - - // Convert YUV to BGRA, store it back (first two lines) - yuv_to_rgb_w32_line(y_plane[buf_idx], v_plane[buf_idx], u_plane[buf_idx], bgra, width); - - // Next two lines - yuv_to_rgb_w32_line(y_plane[buf_idx] + size_2lines_y, - v_plane[buf_idx] + stride_vu, - u_plane[buf_idx] + stride_vu, - bgra + size_2lines_bgra, - width); - - // Wait for previous storing transfer to be completed - DMA_WAIT_TAG(STR_BUF); - - // Store converted lines in two steps->max transfer size 16384 - spu_mfcdma32(bgra, (unsigned int)ram_addr_bgra, size_2lines_bgra, STR_BUF, MFC_PUT_CMD); - ram_addr_bgra += size_2lines_bgra; - spu_mfcdma32(bgra + size_2lines_bgra, (unsigned int)ram_addr_bgra, size_2lines_bgra, STR_BUF, MFC_PUT_CMD); - ram_addr_bgra += size_2lines_bgra; - - // Move 4 lines - ram_addr_y += size_4lines_y; - ram_addr_v += size_2lines_vu; - ram_addr_u += size_2lines_vu; - - buf_idx^=1; - } - - // Convert YUV to BGRA, store it back (first two lines) - yuv_to_rgb_w32_line(y_plane[buf_idx], v_plane[buf_idx], u_plane[buf_idx], bgra, width); - - // Next two lines - yuv_to_rgb_w32_line(y_plane[buf_idx] + size_2lines_y, - v_plane[buf_idx] + stride_vu, - u_plane[buf_idx] + stride_vu, - bgra + size_2lines_bgra, - width); - - // Wait for previous storing transfer to be completed - DMA_WAIT_TAG(STR_BUF); - spu_mfcdma32(bgra, (unsigned int) ram_addr_bgra, size_2lines_bgra, STR_BUF, MFC_PUT_CMD); - ram_addr_bgra += size_2lines_bgra; - spu_mfcdma32(bgra + size_2lines_bgra, (unsigned int) ram_addr_bgra, size_2lines_bgra, STR_BUF, MFC_PUT_CMD); - - // Wait for previous storing transfer to be completed - DMA_WAIT_TAG(STR_BUF); -} - - -/* Some vectors needed by the yuv 2 rgb conversion algorithm */ -const vector float vec_minus_128 = { -128.0f, -128.0f, -128.0f, -128.0f }; -const vector unsigned char vec_null = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; -const vector unsigned char vec_char2int_first = { 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x13 }; -const vector unsigned char vec_char2int_second = { 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17 }; -const vector unsigned char vec_char2int_third = { 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1A, 0x00, 0x00, 0x00, 0x1B }; -const vector unsigned char vec_char2int_fourth = { 0x00, 0x00, 0x00, 0x1C, 0x00, 0x00, 0x00, 0x1D, 0x00, 0x00, 0x00, 0x1E, 0x00, 0x00, 0x00, 0x1F }; - -const vector float vec_R_precalc_coeff = {1.403f, 1.403f, 1.403f, 1.403f}; -const vector float vec_Gu_precalc_coeff = {-0.344f, -0.344f, -0.344f, -0.344f}; -const vector float vec_Gv_precalc_coeff = {-0.714f, -0.714f, -0.714f, -0.714f}; -const vector float vec_B_precalc_coeff = {1.773f, 1.773f, 1.773f, 1.773f}; - -const vector unsigned int vec_alpha = { 255 << 24, 255 << 24, 255 << 24, 255 << 24 }; - -const vector unsigned char vec_select_floats_upper = { 0x00, 0x01, 0x02, 0x03, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x04, 0x05, 0x06, 0x07 }; -const vector unsigned char vec_select_floats_lower = { 0x08, 0x09, 0x0A, 0x0B, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x0C, 0x0D, 0x0E, 0x0F }; - - -#ifdef TESTING -/* - * yuv_to_rgb_w2() - * - * - converts x * 4 pixels from YUV to RGB - * - two lines of YUV are taken as input. - * - width has to be a multiple of 2 (= 4 pixel) - * - * @param y_addr address of the y plane (local store) - * @param v_addr address of the v plane (local store) - * @param u_addr address of the u plane (local store) - * @param bgra_addr_char address of the bgra output buffer (local store) - * @param width the width of a line in pixel - */ -void yuv_to_rgb_w2_line(unsigned char* y_addr, unsigned char* v_addr, unsigned char* u_addr, unsigned char* bgra_addr_char, unsigned int width) { - // each pixel is stored as an integer - unsigned int* bgra_addr = (unsigned int*) bgra_addr_char; - - unsigned int x; - // Go through each line in steps of 2, because every U and V value is connected to 4 pixels Y (YUV 4:2:0) - for(x = 0; x < width; x+=2) { - // Get the 4 Y, 1 U and 1 V values - const unsigned char Y_1 = *(y_addr + x); - const unsigned char Y_2 = *(y_addr + x + 1); - const unsigned char Y_3 = *(y_addr + x + width); - const unsigned char Y_4 = *(y_addr + x + width + 1); - const unsigned char U = *(u_addr + (x >> 1)); - const unsigned char V = *(v_addr + (x >> 1)); - - // Start converting - float V_minus_128 = (float)((float)V - 128.0f); - float U_minus_128 = (float)((float)U - 128.0f); - - float R_precalculate = 1.403f * V_minus_128; - float G_precalculate = -(0.344f * U_minus_128 + 0.714f * V_minus_128); - float B_precalculate = 1.773f * U_minus_128; - - // Cast the results - const unsigned char R_1 = float_to_char((Y_1 + R_precalculate)); - const unsigned char R_2 = float_to_char((Y_2 + R_precalculate)); - const unsigned char R_3 = float_to_char((Y_3 + R_precalculate)); - const unsigned char R_4 = float_to_char((Y_4 + R_precalculate)); - const unsigned char G_1 = float_to_char((Y_1 + G_precalculate)); - const unsigned char G_2 = float_to_char((Y_2 + G_precalculate)); - const unsigned char G_3 = float_to_char((Y_3 + G_precalculate)); - const unsigned char G_4 = float_to_char((Y_4 + G_precalculate)); - const unsigned char B_1 = float_to_char((Y_1 + B_precalculate)); - const unsigned char B_2 = float_to_char((Y_2 + B_precalculate)); - const unsigned char B_3 = float_to_char((Y_3 + B_precalculate)); - const unsigned char B_4 = float_to_char((Y_4 + B_precalculate)); - - // Write back - *(bgra_addr + x) = (B_1 << 0)| (G_1 << 8) | (R_1 << 16) | (255 << 24); - *(bgra_addr + x + 1) = (B_2 << 0)| (G_2 << 8) | (R_2 << 16) | (255 << 24); - *(bgra_addr + x + width) = (B_3 << 0)| (G_3 << 8) | (R_3 << 16) | (255 << 24); - *(bgra_addr + x + width + 1) = (B_4 << 0)| (G_4 << 8) | (R_4 << 16) | (255 << 24); - } -} -#endif - - -/* - * yuv_to_rgb_w32() - * - * processes to line of yuv-input, width has to be a multiple of 32 - * two lines of yuv are taken as input - * - * @param y_addr address of the y plane in local store - * @param v_addr address of the v plane in local store - * @param u_addr address of the u plane in local store - * @param bgra_addr_ address of the bgra output buffer - * @param width the width in pixel - */ -void yuv_to_rgb_w32_line(unsigned char* y_addr, unsigned char* v_addr, unsigned char* u_addr, unsigned char* bgra_addr_, unsigned int width) { - // each pixel is stored as an integer - unsigned int* bgra_addr = (unsigned int*) bgra_addr_; - - unsigned int x; - for(x = 0; x < width; x+=32) { - // Gehe zweischrittig durch die zeile, da jeder u und v wert fuer 4 pixel(zwei hoch, zwei breit) gilt - - const vector unsigned char vchar_Y_1 = *((vector unsigned char*)(y_addr + x)); - const vector unsigned char vchar_Y_2 = *((vector unsigned char*)(y_addr + x + 16)); - const vector unsigned char vchar_Y_3 = *((vector unsigned char*)(y_addr + x + width)); - const vector unsigned char vchar_Y_4 = *((vector unsigned char*)(y_addr + x + width + 16)); - const vector unsigned char vchar_U = *((vector unsigned char*)(u_addr + (x >> 1))); - const vector unsigned char vchar_V = *((vector unsigned char*)(v_addr + (x >> 1))); - - const vector float vfloat_U_1 = spu_add(spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_U, vec_char2int_first), 0),vec_minus_128); - const vector float vfloat_U_2 = spu_add(spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_U, vec_char2int_second), 0),vec_minus_128); - const vector float vfloat_U_3 = spu_add(spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_U, vec_char2int_third), 0),vec_minus_128); - const vector float vfloat_U_4 = spu_add(spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_U, vec_char2int_fourth), 0),vec_minus_128); - - const vector float vfloat_V_1 = spu_add(spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_V, vec_char2int_first), 0),vec_minus_128); - const vector float vfloat_V_2 = spu_add(spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_V, vec_char2int_second), 0),vec_minus_128); - const vector float vfloat_V_3 = spu_add(spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_V, vec_char2int_third), 0),vec_minus_128); - const vector float vfloat_V_4 = spu_add(spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_V, vec_char2int_fourth), 0),vec_minus_128); - - vector float Y_1 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_1, vec_char2int_first), 0); - vector float Y_2 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_1, vec_char2int_second), 0); - vector float Y_3 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_1, vec_char2int_third), 0); - vector float Y_4 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_1, vec_char2int_fourth), 0); - vector float Y_5 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_2, vec_char2int_first), 0); - vector float Y_6 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_2, vec_char2int_second), 0); - vector float Y_7 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_2, vec_char2int_third), 0); - vector float Y_8 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_2, vec_char2int_fourth), 0); - vector float Y_9 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_3, vec_char2int_first), 0); - vector float Y_10 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_3, vec_char2int_second), 0); - vector float Y_11 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_3, vec_char2int_third), 0); - vector float Y_12 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_3, vec_char2int_fourth), 0); - vector float Y_13 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_4, vec_char2int_first), 0); - vector float Y_14 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_4, vec_char2int_second), 0); - vector float Y_15 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_4, vec_char2int_third), 0); - vector float Y_16 = spu_convtf((vector unsigned int)spu_shuffle(vec_null, vchar_Y_4, vec_char2int_fourth), 0); - - const vector float R1a_precalculate = spu_mul(vec_R_precalc_coeff, vfloat_V_1); - const vector float R2a_precalculate = spu_mul(vec_R_precalc_coeff, vfloat_V_2); - const vector float R3a_precalculate = spu_mul(vec_R_precalc_coeff, vfloat_V_3); - const vector float R4a_precalculate = spu_mul(vec_R_precalc_coeff, vfloat_V_4); - - const vector float R1_precalculate = spu_shuffle(R1a_precalculate, R1a_precalculate, vec_select_floats_upper); - const vector float R2_precalculate = spu_shuffle(R1a_precalculate, R1a_precalculate, vec_select_floats_lower); - const vector float R3_precalculate = spu_shuffle(R2a_precalculate, R2a_precalculate, vec_select_floats_upper); - const vector float R4_precalculate = spu_shuffle(R2a_precalculate, R2a_precalculate, vec_select_floats_lower); - const vector float R5_precalculate = spu_shuffle(R3a_precalculate, R3a_precalculate, vec_select_floats_upper); - const vector float R6_precalculate = spu_shuffle(R3a_precalculate, R3a_precalculate, vec_select_floats_lower); - const vector float R7_precalculate = spu_shuffle(R4a_precalculate, R4a_precalculate, vec_select_floats_upper); - const vector float R8_precalculate = spu_shuffle(R4a_precalculate, R4a_precalculate, vec_select_floats_lower); - - - const vector float G1a_precalculate = spu_madd(vec_Gu_precalc_coeff, vfloat_U_1, spu_mul(vfloat_V_1, vec_Gv_precalc_coeff)); - const vector float G2a_precalculate = spu_madd(vec_Gu_precalc_coeff, vfloat_U_2, spu_mul(vfloat_V_2, vec_Gv_precalc_coeff)); - const vector float G3a_precalculate = spu_madd(vec_Gu_precalc_coeff, vfloat_U_3, spu_mul(vfloat_V_3, vec_Gv_precalc_coeff)); - const vector float G4a_precalculate = spu_madd(vec_Gu_precalc_coeff, vfloat_U_4, spu_mul(vfloat_V_4, vec_Gv_precalc_coeff)); - - const vector float G1_precalculate = spu_shuffle(G1a_precalculate, G1a_precalculate, vec_select_floats_upper); - const vector float G2_precalculate = spu_shuffle(G1a_precalculate, G1a_precalculate, vec_select_floats_lower); - const vector float G3_precalculate = spu_shuffle(G2a_precalculate, G2a_precalculate, vec_select_floats_upper); - const vector float G4_precalculate = spu_shuffle(G2a_precalculate, G2a_precalculate, vec_select_floats_lower); - const vector float G5_precalculate = spu_shuffle(G3a_precalculate, G3a_precalculate, vec_select_floats_upper); - const vector float G6_precalculate = spu_shuffle(G3a_precalculate, G3a_precalculate, vec_select_floats_lower); - const vector float G7_precalculate = spu_shuffle(G4a_precalculate, G4a_precalculate, vec_select_floats_upper); - const vector float G8_precalculate = spu_shuffle(G4a_precalculate, G4a_precalculate, vec_select_floats_lower); - - - const vector float B1a_precalculate = spu_mul(vec_B_precalc_coeff, vfloat_U_1); - const vector float B2a_precalculate = spu_mul(vec_B_precalc_coeff, vfloat_U_2); - const vector float B3a_precalculate = spu_mul(vec_B_precalc_coeff, vfloat_U_3); - const vector float B4a_precalculate = spu_mul(vec_B_precalc_coeff, vfloat_U_4); - - const vector float B1_precalculate = spu_shuffle(B1a_precalculate, B1a_precalculate, vec_select_floats_upper); - const vector float B2_precalculate = spu_shuffle(B1a_precalculate, B1a_precalculate, vec_select_floats_lower); - const vector float B3_precalculate = spu_shuffle(B2a_precalculate, B2a_precalculate, vec_select_floats_upper); - const vector float B4_precalculate = spu_shuffle(B2a_precalculate, B2a_precalculate, vec_select_floats_lower); - const vector float B5_precalculate = spu_shuffle(B3a_precalculate, B3a_precalculate, vec_select_floats_upper); - const vector float B6_precalculate = spu_shuffle(B3a_precalculate, B3a_precalculate, vec_select_floats_lower); - const vector float B7_precalculate = spu_shuffle(B4a_precalculate, B4a_precalculate, vec_select_floats_upper); - const vector float B8_precalculate = spu_shuffle(B4a_precalculate, B4a_precalculate, vec_select_floats_lower); - - - const vector unsigned int R_1 = vfloat_to_vuint(spu_add( Y_1, R1_precalculate)); - const vector unsigned int R_2 = vfloat_to_vuint(spu_add( Y_2, R2_precalculate)); - const vector unsigned int R_3 = vfloat_to_vuint(spu_add( Y_3, R3_precalculate)); - const vector unsigned int R_4 = vfloat_to_vuint(spu_add( Y_4, R4_precalculate)); - const vector unsigned int R_5 = vfloat_to_vuint(spu_add( Y_5, R5_precalculate)); - const vector unsigned int R_6 = vfloat_to_vuint(spu_add( Y_6, R6_precalculate)); - const vector unsigned int R_7 = vfloat_to_vuint(spu_add( Y_7, R7_precalculate)); - const vector unsigned int R_8 = vfloat_to_vuint(spu_add( Y_8, R8_precalculate)); - const vector unsigned int R_9 = vfloat_to_vuint(spu_add( Y_9, R1_precalculate)); - const vector unsigned int R_10 = vfloat_to_vuint(spu_add(Y_10, R2_precalculate)); - const vector unsigned int R_11 = vfloat_to_vuint(spu_add(Y_11, R3_precalculate)); - const vector unsigned int R_12 = vfloat_to_vuint(spu_add(Y_12, R4_precalculate)); - const vector unsigned int R_13 = vfloat_to_vuint(spu_add(Y_13, R5_precalculate)); - const vector unsigned int R_14 = vfloat_to_vuint(spu_add(Y_14, R6_precalculate)); - const vector unsigned int R_15 = vfloat_to_vuint(spu_add(Y_15, R7_precalculate)); - const vector unsigned int R_16 = vfloat_to_vuint(spu_add(Y_16, R8_precalculate)); - - const vector unsigned int G_1 = vfloat_to_vuint(spu_add( Y_1, G1_precalculate)); - const vector unsigned int G_2 = vfloat_to_vuint(spu_add( Y_2, G2_precalculate)); - const vector unsigned int G_3 = vfloat_to_vuint(spu_add( Y_3, G3_precalculate)); - const vector unsigned int G_4 = vfloat_to_vuint(spu_add( Y_4, G4_precalculate)); - const vector unsigned int G_5 = vfloat_to_vuint(spu_add( Y_5, G5_precalculate)); - const vector unsigned int G_6 = vfloat_to_vuint(spu_add( Y_6, G6_precalculate)); - const vector unsigned int G_7 = vfloat_to_vuint(spu_add( Y_7, G7_precalculate)); - const vector unsigned int G_8 = vfloat_to_vuint(spu_add( Y_8, G8_precalculate)); - const vector unsigned int G_9 = vfloat_to_vuint(spu_add( Y_9, G1_precalculate)); - const vector unsigned int G_10 = vfloat_to_vuint(spu_add(Y_10, G2_precalculate)); - const vector unsigned int G_11 = vfloat_to_vuint(spu_add(Y_11, G3_precalculate)); - const vector unsigned int G_12 = vfloat_to_vuint(spu_add(Y_12, G4_precalculate)); - const vector unsigned int G_13 = vfloat_to_vuint(spu_add(Y_13, G5_precalculate)); - const vector unsigned int G_14 = vfloat_to_vuint(spu_add(Y_14, G6_precalculate)); - const vector unsigned int G_15 = vfloat_to_vuint(spu_add(Y_15, G7_precalculate)); - const vector unsigned int G_16 = vfloat_to_vuint(spu_add(Y_16, G8_precalculate)); - - const vector unsigned int B_1 = vfloat_to_vuint(spu_add( Y_1, B1_precalculate)); - const vector unsigned int B_2 = vfloat_to_vuint(spu_add( Y_2, B2_precalculate)); - const vector unsigned int B_3 = vfloat_to_vuint(spu_add( Y_3, B3_precalculate)); - const vector unsigned int B_4 = vfloat_to_vuint(spu_add( Y_4, B4_precalculate)); - const vector unsigned int B_5 = vfloat_to_vuint(spu_add( Y_5, B5_precalculate)); - const vector unsigned int B_6 = vfloat_to_vuint(spu_add( Y_6, B6_precalculate)); - const vector unsigned int B_7 = vfloat_to_vuint(spu_add( Y_7, B7_precalculate)); - const vector unsigned int B_8 = vfloat_to_vuint(spu_add( Y_8, B8_precalculate)); - const vector unsigned int B_9 = vfloat_to_vuint(spu_add( Y_9, B1_precalculate)); - const vector unsigned int B_10 = vfloat_to_vuint(spu_add(Y_10, B2_precalculate)); - const vector unsigned int B_11 = vfloat_to_vuint(spu_add(Y_11, B3_precalculate)); - const vector unsigned int B_12 = vfloat_to_vuint(spu_add(Y_12, B4_precalculate)); - const vector unsigned int B_13 = vfloat_to_vuint(spu_add(Y_13, B5_precalculate)); - const vector unsigned int B_14 = vfloat_to_vuint(spu_add(Y_14, B6_precalculate)); - const vector unsigned int B_15 = vfloat_to_vuint(spu_add(Y_15, B7_precalculate)); - const vector unsigned int B_16 = vfloat_to_vuint(spu_add(Y_16, B8_precalculate)); - - *((vector unsigned int*)(bgra_addr + x)) = spu_or(spu_or(vec_alpha, B_1), spu_or(spu_slqwbyte( R_1, 2),spu_slqwbyte(G_1, 1))); - *((vector unsigned int*)(bgra_addr + x + 4)) = spu_or(spu_or(vec_alpha, B_2), spu_or(spu_slqwbyte( R_2, 2),spu_slqwbyte(G_2, 1))); - *((vector unsigned int*)(bgra_addr + x + 8)) = spu_or(spu_or(vec_alpha, B_3), spu_or(spu_slqwbyte( R_3, 2),spu_slqwbyte(G_3, 1))); - *((vector unsigned int*)(bgra_addr + x + 12)) = spu_or(spu_or(vec_alpha, B_4), spu_or(spu_slqwbyte( R_4, 2),spu_slqwbyte(G_4, 1))); - *((vector unsigned int*)(bgra_addr + x + 16)) = spu_or(spu_or(vec_alpha, B_5), spu_or(spu_slqwbyte( R_5, 2),spu_slqwbyte(G_5, 1))); - *((vector unsigned int*)(bgra_addr + x + 20)) = spu_or(spu_or(vec_alpha, B_6), spu_or(spu_slqwbyte( R_6, 2),spu_slqwbyte(G_6, 1))); - *((vector unsigned int*)(bgra_addr + x + 24)) = spu_or(spu_or(vec_alpha, B_7), spu_or(spu_slqwbyte( R_7, 2),spu_slqwbyte(G_7, 1))); - *((vector unsigned int*)(bgra_addr + x + 28)) = spu_or(spu_or(vec_alpha, B_8), spu_or(spu_slqwbyte( R_8, 2),spu_slqwbyte(G_8, 1))); - *((vector unsigned int*)(bgra_addr + x + width)) = spu_or(spu_or(vec_alpha, B_9), spu_or(spu_slqwbyte( R_9, 2),spu_slqwbyte(G_9, 1))); - *((vector unsigned int*)(bgra_addr + x + width + 4)) = spu_or(spu_or(vec_alpha, B_10), spu_or(spu_slqwbyte(R_10, 2),spu_slqwbyte(G_10, 1))); - *((vector unsigned int*)(bgra_addr + x + width + 8)) = spu_or(spu_or(vec_alpha, B_11), spu_or(spu_slqwbyte(R_11, 2),spu_slqwbyte(G_11, 1))); - *((vector unsigned int*)(bgra_addr + x + width + 12)) = spu_or(spu_or(vec_alpha, B_12), spu_or(spu_slqwbyte(R_12, 2),spu_slqwbyte(G_12, 1))); - *((vector unsigned int*)(bgra_addr + x + width + 16)) = spu_or(spu_or(vec_alpha, B_13), spu_or(spu_slqwbyte(R_13, 2),spu_slqwbyte(G_13, 1))); - *((vector unsigned int*)(bgra_addr + x + width + 20)) = spu_or(spu_or(vec_alpha, B_14), spu_or(spu_slqwbyte(R_14, 2),spu_slqwbyte(G_14, 1))); - *((vector unsigned int*)(bgra_addr + x + width + 24)) = spu_or(spu_or(vec_alpha, B_15), spu_or(spu_slqwbyte(R_15, 2),spu_slqwbyte(G_15, 1))); - *((vector unsigned int*)(bgra_addr + x + width + 28)) = spu_or(spu_or(vec_alpha, B_16), spu_or(spu_slqwbyte(R_16, 2),spu_slqwbyte(G_16, 1))); - } -} - diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_input.c b/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_input.c deleted file mode 100644 index d627cb4ec..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_input.c +++ /dev/null @@ -1,1144 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_gf_input.h" - -#include "SDL_config.h" -#include "SDL_events.h" -#include "../../events/SDL_mouse_c.h" -#include "../../events/SDL_keyboard_c.h" - -/* Include QNX HIDDI definitions */ -#include "SDL_hiddi_keyboard.h" -#include "SDL_hiddi_mouse.h" -#include "SDL_hiddi_joystick.h" - -/* Mouse related functions */ -SDL_Cursor *gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y); -int gf_showcursor(SDL_Cursor * cursor); -void gf_movecursor(SDL_Cursor * cursor); -void gf_freecursor(SDL_Cursor * cursor); -void gf_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y); -void gf_freemouse(SDL_Mouse * mouse); - -/* HIDDI interacting functions */ -static int32_t hiddi_connect_devices(); -static int32_t hiddi_disconnect_devices(); - -int32_t -gf_addinputdevices(_THIS) -{ - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata; - struct SDL_Mouse gf_mouse; - SDL_Keyboard gf_keyboard; - SDLKey keymap[SDL_NUM_SCANCODES]; - SDL_MouseData *mdata; - uint32_t it; - - for (it = 0; it < _this->num_displays; it++) { - SDL_VideoDisplay *display = &_this->displays[it]; - - /* Clear SDL mouse structure */ - SDL_memset(&gf_mouse, 0x00, sizeof(struct SDL_Mouse)); - - /* Allocate SDL_MouseData structure */ - mdata = (SDL_MouseData *) SDL_calloc(1, sizeof(SDL_MouseData)); - if (mdata == NULL) { - SDL_OutOfMemory(); - return -1; - } - - /* Mark this mouse with ID 0 */ - gf_mouse.id = it; - gf_mouse.driverdata = (void *) mdata; - gf_mouse.CreateCursor = gf_createcursor; - gf_mouse.ShowCursor = gf_showcursor; - gf_mouse.MoveCursor = gf_movecursor; - gf_mouse.FreeCursor = gf_freecursor; - gf_mouse.WarpMouse = gf_warpmouse; - gf_mouse.FreeMouse = gf_freemouse; - - /* Get display data */ - didata = (SDL_DisplayData *) display->driverdata; - - /* Store SDL_DisplayData pointer in the mouse driver internals */ - mdata->didata = didata; - - /* Set cursor pos to 0,0 to avoid cursor disappearing in some drivers */ - gf_cursor_set_pos(didata->display, 0, 0, 0); - - /* Register mouse cursor in SDL */ - SDL_AddMouse(&gf_mouse, "GF mouse cursor", 0, 0, 1); - } - - /* Keyboard could be one only */ - SDL_zero(gf_keyboard); - SDL_AddKeyboard(&gf_keyboard, -1); - - /* Add scancode to key mapping, HIDDI uses USB HID codes, so */ - /* map will be exact one-to-one */ - SDL_GetDefaultKeymap(keymap); - SDL_SetKeymap(0, 0, keymap, SDL_NUM_SCANCODES); - - /* Connect to HID server and enumerate all input devices */ - hiddi_connect_devices(); - - return 0; -} - -int32_t -gf_delinputdevices(_THIS) -{ - /* Disconnect from HID server and release input devices */ - hiddi_disconnect_devices(); - - /* Delete keyboard */ - SDL_KeyboardQuit(); - - /* Destroy all of the mice */ - SDL_MouseQuit(); -} - -/*****************************************************************************/ -/* GF Mouse related functions */ -/*****************************************************************************/ -SDL_Cursor * -gf_createcursor(SDL_Surface * surface, int hot_x, int hot_y) -{ - gf_cursor_t *internal_cursor; - SDL_Cursor *sdl_cursor; - uint8_t *image0 = NULL; - uint8_t *image1 = NULL; - uint32_t it; - uint32_t jt; - uint32_t shape_color; - - /* SDL converts monochrome cursor shape to 32bpp cursor shape */ - /* and we must convert it back to monochrome, this routine handles */ - /* 24/32bpp surfaces only */ - if ((surface->format->BitsPerPixel != 32) - && (surface->format->BitsPerPixel != 24)) { - SDL_SetError("GF: Cursor shape is not 24/32bpp."); - return NULL; - } - - /* Since GF is not checking data, we must check */ - if ((surface->w == 0) || (surface->h == 0)) { - SDL_SetError("GF: Cursor shape dimensions are zero"); - return NULL; - } - - /* Allocate memory for the internal cursor format */ - internal_cursor = (gf_cursor_t *) SDL_calloc(1, sizeof(gf_cursor_t)); - if (internal_cursor == NULL) { - SDL_OutOfMemory(); - return NULL; - } - - /* Allocate memory for the SDL cursor */ - sdl_cursor = (SDL_Cursor *) SDL_calloc(1, sizeof(SDL_Cursor)); - if (sdl_cursor == NULL) { - SDL_free(internal_cursor); - SDL_OutOfMemory(); - return NULL; - } - - /* Allocate two monochrome images */ - image0 = (uint8_t *) SDL_calloc(1, ((surface->w + 7) / 8) * surface->h); - if (image0 == NULL) { - SDL_free(sdl_cursor); - SDL_free(internal_cursor); - SDL_OutOfMemory(); - return NULL; - } - image1 = (uint8_t *) SDL_calloc(1, ((surface->w + 7) >> 3) * surface->h); - if (image1 == NULL) { - SDL_free(image0); - SDL_free(sdl_cursor); - SDL_free(internal_cursor); - SDL_OutOfMemory(); - return NULL; - } - - /* Set driverdata as GF cursor format */ - sdl_cursor->driverdata = (void *) internal_cursor; - internal_cursor->type = GF_CURSOR_BITMAP; - internal_cursor->hotspot.x = hot_x; - internal_cursor->hotspot.y = hot_y; - internal_cursor->cursor.bitmap.w = surface->w; - internal_cursor->cursor.bitmap.h = surface->h; - internal_cursor->cursor.bitmap.color0 = SDL_GF_MOUSE_COLOR_BLACK; - internal_cursor->cursor.bitmap.color1 = SDL_GF_MOUSE_COLOR_WHITE; - - /* Setup cursor shape images */ - internal_cursor->cursor.bitmap.stride = ((surface->w + 7) >> 3); - internal_cursor->cursor.bitmap.image0 = image0; - internal_cursor->cursor.bitmap.image1 = image1; - - /* Convert cursor from 32 bpp */ - for (jt = 0; jt < surface->h; jt++) { - for (it = 0; it < surface->w; it++) { - shape_color = - *((uint32_t *) ((uint8_t *) surface->pixels + - jt * surface->pitch + - it * surface->format->BytesPerPixel)); - switch (shape_color) { - case SDL_GF_MOUSE_COLOR_BLACK: - { - *(image0 + jt * (internal_cursor->cursor.bitmap.stride) + - (it >> 3)) |= 0x80 >> (it % 8); - *(image1 + jt * (internal_cursor->cursor.bitmap.stride) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - } - break; - case SDL_GF_MOUSE_COLOR_WHITE: - { - *(image0 + jt * (internal_cursor->cursor.bitmap.stride) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - *(image1 + jt * (internal_cursor->cursor.bitmap.stride) + - (it >> 3)) |= 0x80 >> (it % 8); - } - break; - case SDL_GF_MOUSE_COLOR_TRANS: - { - *(image0 + jt * (internal_cursor->cursor.bitmap.stride) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - *(image1 + jt * (internal_cursor->cursor.bitmap.stride) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - } - break; - default: - { - /* The same as transparent color, must not happen */ - *(image0 + jt * (internal_cursor->cursor.bitmap.stride) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - *(image1 + jt * (internal_cursor->cursor.bitmap.stride) + - (it >> 3)) &= ~(0x80 >> (it % 8)); - } - break; - } - } - } - - return sdl_cursor; -} - -int -gf_showcursor(SDL_Cursor * cursor) -{ - SDL_VideoDisplay *display; - SDL_DisplayData *didata; - SDL_Window *window; - SDL_WindowID window_id; - gf_cursor_t *internal_cursor; - int32_t status; - - /* Get current window id */ - window_id = SDL_GetFocusWindow(); - if (window_id <= 0) { - SDL_MouseData *mdata = NULL; - - /* If there is no current window, then someone calls this function */ - /* to set global mouse settings during SDL initialization */ - if (cursor != NULL) { - mdata = (SDL_MouseData *) cursor->mouse->driverdata; - didata = (SDL_DisplayData *) mdata->didata; - if ((didata == NULL) || (mdata == NULL)) { - return; - } - } else { - /* We can't get SDL_DisplayData at this point, return fake success */ - return 0; - } - } else { - /* Sanity checks */ - window = SDL_GetWindowFromID(window_id); - if (window != NULL) { - display = window->display; - if (display != NULL) { - didata = (SDL_DisplayData *) display->driverdata; - if (didata == NULL) { - return -1; - } - } else { - return -1; - } - } else { - return -1; - } - } - - /* Check if we need to set new shape or disable cursor shape */ - if (cursor != NULL) { - /* Retrieve GF cursor shape */ - internal_cursor = (gf_cursor_t *) cursor->driverdata; - if (internal_cursor == NULL) { - SDL_SetError("GF: Internal cursor data is absent"); - return -1; - } - if ((internal_cursor->cursor.bitmap.image0 == NULL) || - (internal_cursor->cursor.bitmap.image1 == NULL)) { - SDL_SetError("GF: Cursor shape is absent"); - return -1; - } - - /* Store last shown cursor to display data */ - didata->cursor.type = internal_cursor->type; - didata->cursor.hotspot.x = internal_cursor->hotspot.x; - didata->cursor.hotspot.y = internal_cursor->hotspot.y; - if (internal_cursor->cursor.bitmap.w > SDL_VIDEO_GF_MAX_CURSOR_SIZE) { - didata->cursor.cursor.bitmap.w = SDL_VIDEO_GF_MAX_CURSOR_SIZE; - } else { - didata->cursor.cursor.bitmap.w = internal_cursor->cursor.bitmap.w; - } - - if (didata->cursor.cursor.bitmap.h > SDL_VIDEO_GF_MAX_CURSOR_SIZE) { - didata->cursor.cursor.bitmap.h = SDL_VIDEO_GF_MAX_CURSOR_SIZE; - } else { - didata->cursor.cursor.bitmap.h = internal_cursor->cursor.bitmap.h; - } - - didata->cursor.cursor.bitmap.color0 = - internal_cursor->cursor.bitmap.color0; - didata->cursor.cursor.bitmap.color1 = - internal_cursor->cursor.bitmap.color1; - didata->cursor.cursor.bitmap.stride = - internal_cursor->cursor.bitmap.stride; - SDL_memcpy(didata->cursor.cursor.bitmap.image0, - internal_cursor->cursor.bitmap.image0, - ((internal_cursor->cursor.bitmap.w + - 7) / (sizeof(uint8_t) * 8)) * - internal_cursor->cursor.bitmap.h); - SDL_memcpy(didata->cursor.cursor.bitmap.image1, - internal_cursor->cursor.bitmap.image1, - ((internal_cursor->cursor.bitmap.w + - 7) / (sizeof(uint8_t) * 8)) * - internal_cursor->cursor.bitmap.h); - - /* Setup cursor shape */ - status = gf_cursor_set(didata->display, 0, internal_cursor); - if (status != GF_ERR_OK) { - if (status != GF_ERR_NOSUPPORT) { - SDL_SetError("GF: Can't set hardware cursor shape"); - return -1; - } - } - - /* Enable just set cursor */ - status = gf_cursor_enable(didata->display, 0); - if (status != GF_ERR_OK) { - if (status != GF_ERR_NOSUPPORT) { - SDL_SetError("GF: Can't enable hardware cursor"); - return -1; - } - } - - /* Set cursor visible */ - didata->cursor_visible = SDL_TRUE; - } else { - /* SDL requests to disable cursor */ - status = gf_cursor_disable(didata->display, 0); - if (status != GF_ERR_OK) { - if (status != GF_ERR_NOSUPPORT) { - SDL_SetError("GF: Can't disable hardware cursor"); - return -1; - } - } - - /* Set cursor invisible */ - didata->cursor_visible = SDL_FALSE; - } - - /* New cursor shape is set */ - return 0; -} - -void -gf_movecursor(SDL_Cursor * cursor) -{ - SDL_VideoDisplay *display; - SDL_DisplayData *didata; - SDL_Window *window; - SDL_WindowID window_id; - int32_t status; - uint32_t xmax; - uint32_t ymax; - - /* Get current window id */ - window_id = SDL_GetFocusWindow(); - if (window_id <= 0) { - didata = (SDL_DisplayData *) cursor->mouse->driverdata; - if (didata == NULL) { - return; - } - } else { - /* Sanity checks */ - window = SDL_GetWindowFromID(window_id); - if (window != NULL) { - display = window->display; - if (display != NULL) { - didata = (SDL_DisplayData *) display->driverdata; - if (didata == NULL) { - return; - } - } else { - return; - } - } else { - return; - } - } - - /* Add checks for out of screen bounds position */ - if (cursor->mouse->x < 0) { - cursor->mouse->x = 0; - } - if (cursor->mouse->y < 0) { - cursor->mouse->y = 0; - } - - /* Get window size to clamp maximum coordinates */ - SDL_GetWindowSize(window_id, &xmax, &ymax); - if (cursor->mouse->x >= xmax) { - cursor->mouse->x = xmax - 1; - } - if (cursor->mouse->y >= ymax) { - cursor->mouse->y = ymax - 1; - } - - status = - gf_cursor_set_pos(didata->display, 0, cursor->mouse->x, - cursor->mouse->y); - if (status != GF_ERR_OK) { - if (status != GF_ERR_NOSUPPORT) { - SDL_SetError("GF: Can't set hardware cursor position"); - return; - } - } -} - -void -gf_freecursor(SDL_Cursor * cursor) -{ - gf_cursor_t *internal_cursor; - - if (cursor != NULL) { - internal_cursor = (gf_cursor_t *) cursor->driverdata; - if (internal_cursor != NULL) { - if (internal_cursor->cursor.bitmap.image0 != NULL) { - SDL_free((uint8_t *) internal_cursor->cursor.bitmap.image0); - } - if (internal_cursor->cursor.bitmap.image1 != NULL) { - SDL_free((uint8_t *) internal_cursor->cursor.bitmap.image1); - } - SDL_free(internal_cursor); - } - } -} - -void -gf_warpmouse(SDL_Mouse * mouse, SDL_Window * window, int x, int y) -{ - SDL_VideoDisplay *display; - SDL_DisplayData *didata; - uint32_t xmax; - uint32_t ymax; - int32_t status; - - /* Sanity checks */ - if (window != NULL) { - display = window->display; - if (display != NULL) { - didata = (SDL_DisplayData *) display->driverdata; - if (didata == NULL) { - return; - } - } else { - return; - } - } else { - return; - } - - /* Add checks for out of screen bounds position */ - if (x < 0) { - x = 0; - } - if (y < 0) { - y = 0; - } - - /* Get window size to clamp maximum coordinates */ - SDL_GetWindowSize(window, &xmax, &ymax); - if (x >= xmax) { - x = xmax - 1; - } - if (y >= ymax) { - y = ymax - 1; - } - - status = gf_cursor_set_pos(didata->display, 0, x, y); - if (status != GF_ERR_OK) { - if (status != GF_ERR_NOSUPPORT) { - SDL_SetError("GF: Can't set hardware cursor position"); - return; - } - } -} - -void -gf_freemouse(SDL_Mouse * mouse) -{ - if (mouse->driverdata == NULL) { - return; - } - - /* Mouse framework doesn't deletes automatically our driverdata */ - SDL_free(mouse->driverdata); - mouse->driverdata = NULL; - - return; -} - -/*****************************************************************************/ -/* HIDDI handlers code */ -/*****************************************************************************/ -static key_packet key_last_state[SDL_HIDDI_MAX_DEVICES]; - -static void -hiddi_keyboard_handler(uint32_t devno, uint8_t * report_data, - uint32_t report_len) -{ - key_packet *packet; - uint32_t it; - uint32_t jt; - - packet = (key_packet *) report_data; - - /* Check for special states */ - switch (report_len) { - case 8: /* 8 bytes of report length */ - { - for (it = 0; it < 6; it++) { - /* Check for keyboard overflow, when it can't handle */ - /* many simultaneous pressed keys */ - if (packet->codes[it] == HIDDI_KEY_OVERFLOW) { - return; - } - } - } - break; - default: - { - /* Do not process unknown reports */ - return; - } - break; - } - - /* Check if modifier key was pressed */ - if (packet->modifiers != key_last_state[devno].modifiers) { - if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL) == - HIDDI_MKEY_LEFT_CTRL) - && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL) == 0) { - /* Left Ctrl key was pressed */ - SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LCTRL); - } - if (((packet->modifiers & HIDDI_MKEY_LEFT_CTRL) == 0) && - (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_CTRL) == - HIDDI_MKEY_LEFT_CTRL) { - /* Left Ctrl key was released */ - SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LCTRL); - } - if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT) == - HIDDI_MKEY_LEFT_SHIFT) - && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT) == 0) { - /* Left Shift key was pressed */ - SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LSHIFT); - } - if (((packet->modifiers & HIDDI_MKEY_LEFT_SHIFT) == 0) && - (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_SHIFT) == - HIDDI_MKEY_LEFT_SHIFT) { - /* Left Shift key was released */ - SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LSHIFT); - } - if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT) == HIDDI_MKEY_LEFT_ALT) - && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT) == 0) { - /* Left Alt key was pressed */ - SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LALT); - } - if (((packet->modifiers & HIDDI_MKEY_LEFT_ALT) == 0) && - (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_ALT) == - HIDDI_MKEY_LEFT_ALT) { - /* Left Alt key was released */ - SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LALT); - } - if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG) == - HIDDI_MKEY_LEFT_WFLAG) - && (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG) == 0) { - /* Left Windows flag key was pressed */ - SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_LGUI); - } - if (((packet->modifiers & HIDDI_MKEY_LEFT_WFLAG) == 0) && - (key_last_state[devno].modifiers & HIDDI_MKEY_LEFT_WFLAG) == - HIDDI_MKEY_LEFT_WFLAG) { - /* Left Windows flag key was released */ - SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_LGUI); - } - if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL) == - HIDDI_MKEY_RIGHT_CTRL) - && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL) == 0) { - /* Right Ctrl key was pressed */ - SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RCTRL); - } - if (((packet->modifiers & HIDDI_MKEY_RIGHT_CTRL) == 0) && - (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_CTRL) == - HIDDI_MKEY_RIGHT_CTRL) { - /* Right Ctrl key was released */ - SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RCTRL); - } - if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT) == - HIDDI_MKEY_RIGHT_SHIFT) - && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT) == - 0) { - /* Right Shift key was pressed */ - SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RSHIFT); - } - if (((packet->modifiers & HIDDI_MKEY_RIGHT_SHIFT) == 0) && - (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_SHIFT) == - HIDDI_MKEY_RIGHT_SHIFT) { - /* Right Shift key was released */ - SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RSHIFT); - } - if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT) == - HIDDI_MKEY_RIGHT_ALT) - && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT) == 0) { - /* Right Alt key was pressed */ - SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RALT); - } - if (((packet->modifiers & HIDDI_MKEY_RIGHT_ALT) == 0) && - (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_ALT) == - HIDDI_MKEY_RIGHT_ALT) { - /* Right Alt key was released */ - SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RALT); - } - if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG) == - HIDDI_MKEY_RIGHT_WFLAG) - && (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG) == - 0) { - /* Right Windows flag key was pressed */ - SDL_SendKeyboardKey(0, SDL_PRESSED, SDL_SCANCODE_RGUI); - } - if (((packet->modifiers & HIDDI_MKEY_RIGHT_WFLAG) == 0) && - (key_last_state[devno].modifiers & HIDDI_MKEY_RIGHT_WFLAG) == - HIDDI_MKEY_RIGHT_WFLAG) { - /* Right Windows flag key was released */ - SDL_SendKeyboardKey(0, SDL_RELEASED, SDL_SCANCODE_RGUI); - } - } - - /* Check each key in the press/release buffer */ - switch (report_len) { - case 8: /* 8 bytes of report length */ - { - /* Check if at least one key was unpressed */ - for (it = 0; it < 6; it++) { - if (key_last_state[devno].codes[it] == HIDDI_KEY_UNPRESSED) { - /* if stored keycode is zero, find another */ - continue; - } - for (jt = 0; jt < 6; jt++) { - /* Find stored keycode in the current pressed codes */ - if (packet->codes[jt] == key_last_state[devno].codes[it]) { - /* If found then particular key state is not changed */ - break; - } - } - - /* Check if pressed key can't longer be found */ - if (jt == 6) { - SDL_SendKeyboardKey(0, SDL_RELEASED, - key_last_state[devno].codes[it]); - } - } - - /* Check if at least one new key was pressed */ - for (it = 0; it < 6; it++) { - if (packet->codes[it] == HIDDI_KEY_UNPRESSED) { - continue; - } - for (jt = 0; jt < 6; jt++) { - /* Find new keycode it the array of old pressed keys */ - if (packet->codes[it] == key_last_state[devno].codes[jt]) { - break; - } - } - - /* Check if new key was pressed */ - if (jt == 6) { - SDL_SendKeyboardKey(0, SDL_PRESSED, packet->codes[it]); - } - } - } - default: /* unknown keyboard report type */ - { - /* Ignore all unknown reports */ - } - break; - } - - /* Store last state */ - key_last_state[devno] = *packet; -} - -static uint32_t mouse_last_state_button[SDL_HIDDI_MAX_DEVICES]; -static uint32_t collect_reports = 0; - -static void -hiddi_mouse_handler(uint32_t devno, uint8_t * report_data, - uint32_t report_len) -{ - uint32_t it; - uint32_t sdlbutton; - - /* We do not want to collect stored events */ - if (collect_reports == 0) { - return; - } - - /* Check for special states */ - switch (report_len) { - case 8: /* 8 bytes of report length, usually multi-button USB mice */ - { - mouse_packet8 *packet; - packet = (mouse_packet8 *) report_data; - - /* Send motion event if motion really was */ - if ((packet->horizontal_precision != 0) - || (packet->vertical_precision != 0)) { - SDL_SendMouseMotion(0, 1, packet->horizontal_precision, - packet->vertical_precision, 0); - } - - /* Send mouse button press/release events */ - if (mouse_last_state_button[devno] != packet->buttons) { - /* Cycle all buttons status */ - for (it = 0; it < 8; it++) { - /* convert hiddi button id to sdl button id */ - switch (it) { - case 0: - { - sdlbutton = SDL_BUTTON_LEFT; - } - break; - case 1: - { - sdlbutton = SDL_BUTTON_RIGHT; - } - break; - case 2: - { - sdlbutton = SDL_BUTTON_MIDDLE; - } - break; - default: - { - sdlbutton = it + 1; - } - break; - } - - /* Button pressed */ - if (((packet->buttons & (0x01 << it)) == (0x01 << it)) && - ((mouse_last_state_button[devno] & (0x01 << it)) == - 0x00)) { - SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton); - } - /* Button released */ - if (((packet->buttons & (0x01 << it)) == 0x00) && - ((mouse_last_state_button[devno] & (0x01 << it)) == - (0x01 << it))) { - SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton); - } - } - mouse_last_state_button[devno] = packet->buttons; - } - - /* Send mouse wheel events */ - if (packet->wheel != 0) { - /* Send vertical wheel event only */ - SDL_SendMouseWheel(0, 0, packet->wheel); - } - } - break; - case 4: /* 4 bytes of report length, usually PS/2 mice */ - { - mouse_packet4 *packet; - packet = (mouse_packet4 *) report_data; - - /* Send motion event if motion really was */ - if ((packet->horizontal != 0) || (packet->vertical != 0)) { - SDL_SendMouseMotion(0, 1, packet->horizontal, - packet->vertical, 0); - } - - /* Send mouse button press/release events */ - if (mouse_last_state_button[devno] != packet->buttons) { - /* Cycle all buttons status */ - for (it = 0; it < 8; it++) { - /* convert hiddi button id to sdl button id */ - switch (it) { - case 0: - { - sdlbutton = SDL_BUTTON_LEFT; - } - break; - case 1: - { - sdlbutton = SDL_BUTTON_RIGHT; - } - break; - case 2: - { - sdlbutton = SDL_BUTTON_MIDDLE; - } - break; - default: - { - sdlbutton = it + 1; - } - break; - } - - /* Button pressed */ - if (((packet->buttons & (0x01 << it)) == (0x01 << it)) && - ((mouse_last_state_button[devno] & (0x01 << it)) == - 0x00)) { - SDL_SendMouseButton(0, SDL_PRESSED, sdlbutton); - } - /* Button released */ - if (((packet->buttons & (0x01 << it)) == 0x00) && - ((mouse_last_state_button[devno] & (0x01 << it)) == - (0x01 << it))) { - SDL_SendMouseButton(0, SDL_RELEASED, sdlbutton); - } - } - mouse_last_state_button[devno] = packet->buttons; - } - - /* Send mouse wheel events */ - if (packet->wheel != 0) { - /* Send vertical wheel event only */ - SDL_SendMouseWheel(0, 0, packet->wheel); - } - } - break; - } -} - -/*****************************************************************************/ -/* HIDDI interacting code */ -/*****************************************************************************/ -static hidd_device_ident_t hiddevice = { - HIDD_CONNECT_WILDCARD, /* vendor id: any */ - HIDD_CONNECT_WILDCARD, /* product id: any */ - HIDD_CONNECT_WILDCARD, /* version: any */ -}; - -static hidd_connect_parm_t hidparams = - { NULL, HID_VERSION, HIDD_VERSION, 0, 0, &hiddevice, NULL, 0 }; - -static void hiddi_insertion(struct hidd_connection *connection, - hidd_device_instance_t * device_instance); -static void hiddi_removal(struct hidd_connection *connection, - hidd_device_instance_t * instance); -static void hiddi_report(struct hidd_connection *connection, - struct hidd_report *report, void *report_data, - uint32_t report_len, uint32_t flags, void *user); - -static hidd_funcs_t hidfuncs = - { _HIDDI_NFUNCS, hiddi_insertion, hiddi_removal, hiddi_report, NULL }; - -/* HID handle, singletone */ -struct hidd_connection *connection = NULL; - -/* SDL detected input device types, singletone */ -static uint32_t sdl_input_devices[SDL_HIDDI_MAX_DEVICES]; - -static int -hiddi_register_for_reports(struct hidd_collection *col, - hidd_device_instance_t * device_instance) -{ - int it; - uint16_t num_col; - struct hidd_collection **hidd_collections; - struct hidd_report_instance *report_instance; - struct hidd_report *report; - int status = 0; - hidview_device_t *device; - - for (it = 0; it < 10 && !status; it++) { - status = - hidd_get_report_instance(col, it, HID_INPUT_REPORT, - &report_instance); - if (status == EOK) { - status = - hidd_report_attach(connection, device_instance, - report_instance, 0, - sizeof(hidview_device_t), &report); - if (status == EOK) { - device = hidd_report_extra(report); - device->report = report; - device->instance = report_instance; - } - } - } - hidd_get_collections(NULL, col, &hidd_collections, &num_col); - - for (it = 0; it < num_col; it++) { - hiddi_register_for_reports(hidd_collections[it], device_instance); - } - - return EOK; -} - -static void -hiddi_insertion(struct hidd_connection *connection, - hidd_device_instance_t * device_instance) -{ - uint32_t it; - struct hidd_collection **hidd_collections; - uint16_t num_col; - - /* get root level collections */ - hidd_get_collections(device_instance, NULL, &hidd_collections, &num_col); - for (it = 0; it < num_col; it++) { - hiddi_register_for_reports(hidd_collections[it], device_instance); - } -} - -static void -hiddi_removal(struct hidd_connection *connection, - hidd_device_instance_t * instance) -{ - hidd_reports_detach(connection, instance); -} - -static void -hiddi_report(struct hidd_connection *connection, hidd_report_t * report, - void *report_data, uint32_t report_len, uint32_t flags, - void *user) -{ - if (report->dev_inst->devno >= SDL_HIDDI_MAX_DEVICES) { - /* Unknown HID device, with devno number out of supported range */ - return; - } - - /* Check device type which generates event */ - switch (sdl_input_devices[report->dev_inst->devno]) { - case SDL_GF_HIDDI_NONE: - { - /* We do not handle other devices type */ - return; - } - break; - case SDL_GF_HIDDI_MOUSE: - { - /* Call mouse handler */ - hiddi_mouse_handler(report->dev_inst->devno, report_data, - report_len); - } - break; - case SDL_GF_HIDDI_KEYBOARD: - { - /* Call keyboard handler */ - hiddi_keyboard_handler(report->dev_inst->devno, report_data, - report_len); - } - break; - case SDL_GF_HIDDI_JOYSTICK: - { - /* Call joystick handler */ - } - break; - } -} - -static -hiddi_get_device_type(uint8_t * report_data, uint16_t report_length) -{ - hid_byte_t byte; - uint16_t usage_page = 0; - uint16_t usage = 0; - uint16_t data = 0; - - while (report_length && !(usage_page && usage)) { - if (hidp_analyse_byte(*report_data, &byte)) { - /* Error in parser, do nothing */ - } - data = hidp_get_data((report_data + 1), &byte); - switch (byte.HIDB_Type) { - case HID_TYPE_GLOBAL: - if (!usage_page && byte.HIDB_Tag == HID_GLOBAL_USAGE_PAGE) { - usage_page = data; - } - break; - case HID_TYPE_LOCAL: - if (!usage && byte.HIDB_Tag == HID_LOCAL_USAGE) { - usage = data; - } - break; - } - report_data += byte.HIDB_Length + 1; - report_length -= byte.HIDB_Length + 1; - } - - switch (usage_page) { - case HIDD_PAGE_DESKTOP: - { - switch (usage) { - case HIDD_USAGE_MOUSE: - { - return SDL_GF_HIDDI_MOUSE; - } - break; - case HIDD_USAGE_JOYSTICK: - { - return SDL_GF_HIDDI_JOYSTICK; - } - break; - case HIDD_USAGE_KEYBOARD: - { - return SDL_GF_HIDDI_KEYBOARD; - } - break; - } - } - break; - case HIDD_PAGE_DIGITIZER: - { - /* Do not handle digitizers */ - } - break; - case HIDD_PAGE_CONSUMER: - { - /* Do not handle consumer input devices */ - } - break; - } - - return SDL_GF_HIDDI_NONE; -} - -static int32_t -hiddi_connect_devices() -{ - int32_t status; - uint32_t it; - uint8_t *report_data; - uint16_t report_length; - hidd_device_instance_t instance; - - /* Cleanup initial keys and mice state */ - SDL_memset(key_last_state, 0x00, - sizeof(key_packet) * SDL_HIDDI_MAX_DEVICES); - SDL_memset(mouse_last_state_button, 0x00, - sizeof(uint32_t) * SDL_HIDDI_MAX_DEVICES); - - status = hidd_connect(&hidparams, &connection); - if (status != EOK) { - connection=NULL; - return -1; - } - - for (it = 0; it < SDL_HIDDI_MAX_DEVICES; it++) { - /* Get device instance */ - status = hidd_get_device_instance(connection, it, &instance); - if (status != EOK) { - continue; - } - - status = - hidd_get_report_desc(connection, &instance, &report_data, - &report_length); - if (status != EOK) { - continue; - } - - status = hiddi_get_device_type(report_data, report_length); - sdl_input_devices[it] = status; - - free(report_data); - } - - /* Disconnect from HID server */ - status = hidd_disconnect(connection); - if (status != EOK) { - connection=NULL; - return -1; - } - - /* Add handlers for HID devices */ - hidparams.funcs = &hidfuncs; - - status = hidd_connect(&hidparams, &connection); - if (status != EOK) { - connection=NULL; - return -1; - } - - return 0; -} - -static int32_t -hiddi_disconnect_devices() -{ - int32_t status; - - hiddi_disable_mouse(); - - /* Disconnect from HID server */ - if (connection!=NULL) - { - status = hidd_disconnect(connection); - if (status != EOK) { - return -1; - } - } -} - -void -hiddi_enable_mouse() -{ - collect_reports = 1; -} - -void -hiddi_disable_mouse() -{ - collect_reports = 0; -} diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_input.h b/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_input.h deleted file mode 100644 index f9ca15cc7..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_input.h +++ /dev/null @@ -1,165 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_GF_INPUT_H__ -#define __SDL_GF_INPUT_H__ - -#include "SDL_config.h" -#include "SDL_video.h" -#include "../SDL_sysvideo.h" - -#include - -#include - -#include -#include - -#include "SDL_qnxgf.h" - -typedef struct SDL_MouseData -{ - SDL_DisplayData *didata; -} SDL_MouseData; - -int32_t gf_addinputdevices(_THIS); -int32_t gf_delinputdevices(_THIS); - -#define SDL_GF_MOUSE_COLOR_BLACK 0xFF000000 -#define SDL_GF_MOUSE_COLOR_WHITE 0xFFFFFFFF -#define SDL_GF_MOUSE_COLOR_TRANS 0x00000000 - -/*****************************************************************************/ -/* This is HIDDI closed interface declarations */ -/*****************************************************************************/ -#define HID_TYPE_MAIN 0x0 -#define HID_TYPE_GLOBAL 0x1 -#define HID_TYPE_LOCAL 0x2 -#define HID_TYPE_RESERVED 0x3 - -#define HID_GLOBAL_USAGE_PAGE 0x0 -#define HID_LOCAL_USAGE 0x0 - -typedef struct _hid_byte -{ - uint8_t HIDB_Length; - uint8_t HIDB_Type; - uint8_t HIDB_Tag; - uint8_t reserved[1]; -} hid_byte_t; - -typedef struct _hidd_global_item -{ - uint16_t usage_page; - uint16_t logical_min; - uint16_t logical_max; - uint16_t physical_min; - uint16_t physical_max; - uint16_t unit_expo; - uint16_t unit; - uint16_t report_size; - uint16_t report_id; - uint16_t report_count; -} hidd_global_item_t; - -typedef struct _hidd_local_item -{ - uint16_t type; - uint8_t reserved[2]; - uint32_t value; - struct _hidd_local_item *next_local; - struct _hidd_local_item *alt_local; -} hidd_local_item_t; - -typedef struct _hidd_local_table -{ - hidd_local_item_t *usage_info; - hidd_local_item_t *designator_info; - hidd_local_item_t *string_info; - uint8_t delimiter; - uint8_t reserved[3]; -} hidd_local_table_t; - -typedef struct _hidd_field -{ - struct hidd_report_instance *report; - struct hidd_collection *collection; - uint16_t report_offset; - uint16_t flags; - hidd_global_item_t gitem; - hidd_local_table_t *ltable; - struct _hidd_field *next_field; - void *user; -} hidd_field_t; - -typedef struct hidd_report_instance -{ - uint8_t report_id; - uint8_t reserved[1]; - uint16_t report_type; - hidd_field_t *field; - uint16_t num_field; - uint16_t byte_len; - uint16_t bit_len; - uint8_t reserved2[2]; - struct hidd_collection *collection; - struct hidd_report_instance *next_col_report; - struct hidd_report_instance *next_report; -} hidd_report_instance_t; - -typedef struct hidd_report -{ - TAILQ_ENTRY(hidd_report) link; - hidd_report_instance_t *rinst; - hidd_device_instance_t *dev_inst; - uint32_t flags; - struct hidd_connection *connection; - void *user; -} hidd_report_t; - -typedef struct hidview_device -{ - struct hidd_report_instance *instance; - struct hidd_report *report; -} hidview_device_t; - -/*****************************************************************************/ -/* Closed HIDDI interface declarations end */ -/*****************************************************************************/ - -/* Maximum devices and subdevices amount per host */ -#define SDL_HIDDI_MAX_DEVICES 64 - -/* Detected device/subdevice type for SDL */ -#define SDL_GF_HIDDI_NONE 0x00000000 -#define SDL_GF_HIDDI_MOUSE 0x00000001 -#define SDL_GF_HIDDI_KEYBOARD 0x00000002 -#define SDL_GF_HIDDI_JOYSTICK 0x00000003 - -extern void hiddi_enable_mouse(); -extern void hiddi_disable_mouse(); - -#endif /* __SDL_GF_INPUT_H__ */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_opengles.c b/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_opengles.c deleted file mode 100644 index 1162a860f..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_opengles.c +++ /dev/null @@ -1,54 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include -#include - -/* This is OpenGL ES 1.0 helper functions from OpenGL ES 1.1 specification, */ -/* which could be implemented independently from hardware, just wrappers */ - -GLAPI void APIENTRY -glTexParameteri(GLenum target, GLenum pname, GLint param) -{ - glTexParameterx(target, pname, (GLfixed) param); - return; -} - -GLAPI void APIENTRY -glTexParameteriv(GLenum target, GLenum pname, const GLint * params) -{ - /* Retrieve one parameter only */ - glTexParameterx(target, pname, (GLfixed) * params); - return; -} - -GLAPI void APIENTRY -glColor4ub(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha) -{ - glColor4f(((GLfloat) red) / 255.f, ((GLfloat) green) / 255.f, - ((GLfloat) blue) / 255.f, ((GLfloat) alpha) / 255.f); - return; -} diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_opengles.h b/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_opengles.h deleted file mode 100644 index 512727b71..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_opengles.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_GF_OPENGLES_H__ -#define __SDL_GF_OPENGLES_H__ - -#include -#include - -GLAPI void APIENTRY glTexParameteri(GLenum target, GLenum pname, GLint param); -GLAPI void APIENTRY glTexParameteriv(GLenum target, GLenum pname, - const GLint * params); -GLAPI void APIENTRY glColor4ub(GLubyte red, GLubyte green, GLubyte blue, - GLubyte alpha); - -#endif /* __SDL_GF_OPENGLES_H__ */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_pixelfmt.c b/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_pixelfmt.c deleted file mode 100644 index bac60b78f..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_pixelfmt.c +++ /dev/null @@ -1,187 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_config.h" -#include "SDL_gf_pixelfmt.h" - -gf_format_t -qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt) -{ - switch (pixelfmt) { - case SDL_PIXELFORMAT_INDEX8: - { - return GF_FORMAT_PAL8; - } - break; - case SDL_PIXELFORMAT_ARGB1555: - { - return GF_FORMAT_PACK_ARGB1555; - } - break; - case SDL_PIXELFORMAT_RGB555: - { - /* RGB555 is the same as ARGB1555, but alpha is ignored */ - return GF_FORMAT_PACK_ARGB1555; - } - break; - case SDL_PIXELFORMAT_RGB565: - { - return GF_FORMAT_PACK_RGB565; - } - break; - case SDL_PIXELFORMAT_BGR565: - { - return GF_FORMAT_PKBE_RGB565; - } - break; - case SDL_PIXELFORMAT_RGB24: - { - /* GF has wrong components order */ - return GF_FORMAT_BGR888; - } - break; - case SDL_PIXELFORMAT_RGB888: - { - /* The same format as ARGB8888, but with alpha ignored */ - /* and GF has wrong components order */ - return GF_FORMAT_BGRA8888; - } - break; - case SDL_PIXELFORMAT_ARGB8888: - { - /* GF has wrong components order */ - return GF_FORMAT_BGRA8888; - } - break; - case SDL_PIXELFORMAT_BGRA8888: - { - /* GF has wrong components order */ - return GF_FORMAT_ARGB8888; - } - break; - case SDL_PIXELFORMAT_YV12: - { - return GF_FORMAT_PLANAR_YUV_YV12; - } - break; - case SDL_PIXELFORMAT_YUY2: - { - return GF_FORMAT_PACK_YUV_YUY2; - } - break; - case SDL_PIXELFORMAT_UYVY: - { - return GF_FORMAT_PACK_YUV_UYVY; - } - break; - case SDL_PIXELFORMAT_YVYU: - { - return GF_FORMAT_PACK_YUV_YVYU; - } - break; - } - - return GF_FORMAT_INVALID; -} - -uint32_t -qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt) -{ - switch (pixelfmt) { - case GF_FORMAT_PAL8: - { - return SDL_PIXELFORMAT_INDEX8; - } - break; - case GF_FORMAT_PKLE_ARGB1555: - { - return SDL_PIXELFORMAT_ARGB1555; - } - break; - case GF_FORMAT_PACK_ARGB1555: - { - return SDL_PIXELFORMAT_ARGB1555; - } - break; - case GF_FORMAT_PKBE_RGB565: - { - return SDL_PIXELFORMAT_BGR565; - } - break; - case GF_FORMAT_PKLE_RGB565: - { - return SDL_PIXELFORMAT_RGB565; - } - break; - case GF_FORMAT_PACK_RGB565: - { - return SDL_PIXELFORMAT_RGB565; - } - break; - case GF_FORMAT_BGR888: - { - /* GF has wrong components order */ - return SDL_PIXELFORMAT_RGB24; - } - break; - case GF_FORMAT_BGRA8888: - { - /* GF has wrong components order */ - return SDL_PIXELFORMAT_ARGB8888; - } - break; - case GF_FORMAT_ARGB8888: - { - /* GF has wrong components order */ - return SDL_PIXELFORMAT_BGRA8888; - } - break; - case GF_FORMAT_PLANAR_YUV_YV12: - { - return SDL_PIXELFORMAT_YV12; - } - break; - case GF_FORMAT_PACK_YUV_YUY2: - { - return SDL_PIXELFORMAT_YUY2; - } - break; - case GF_FORMAT_PACK_YUV_UYVY: - { - return SDL_PIXELFORMAT_UYVY; - } - break; - case GF_FORMAT_PACK_YUV_YVYU: - { - return SDL_PIXELFORMAT_YVYU; - } - break; - } - - return SDL_PIXELFORMAT_UNKNOWN; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_pixelfmt.h b/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_pixelfmt.h deleted file mode 100644 index 668111202..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_pixelfmt.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_GF_PIXELFMT_H__ -#define __SDL_GF_PIXELFMT_H__ - -#include "../SDL_sysvideo.h" - -#include - -gf_format_t qnxgf_sdl_to_gf_pixelformat(uint32_t pixelfmt); -uint32_t qnxgf_gf_to_sdl_pixelformat(gf_format_t pixelfmt); - -#endif /* __SDL_GF_PIXELFMT_H__ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_render.c b/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_render.c deleted file mode 100644 index fd94f607f..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_render.c +++ /dev/null @@ -1,425 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_config.h" - -#include "../SDL_pixels_c.h" -#include "../SDL_yuv_sw_c.h" - -#include "SDL_video.h" - -#include "SDL_gf_render.h" -#include "SDL_qnxgf.h" - -static SDL_Renderer *gf_createrenderer(SDL_Window * window, Uint32 flags); -static int gf_displaymodechanged(SDL_Renderer * renderer); -static int gf_activaterenderer(SDL_Renderer * renderer); -static int gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int gf_querytexturepixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int gf_settexturepalette(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); -static int gf_gettexturepalette(SDL_Renderer * renderer, - SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors); -static int gf_settexturecolormod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int gf_settexturealphamod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int gf_settextureblendmode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int gf_settexturescalemode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); -static int gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch); -static void gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture); -static void gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects); -static int gf_renderpoint(SDL_Renderer * renderer, int x, int y); -static int gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, - int y2); -static int gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect); -static int gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect); -static void gf_renderpresent(SDL_Renderer * renderer); -static void gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture); -static void gf_destroyrenderer(SDL_Renderer * renderer); - -SDL_RenderDriver gf_renderdriver = { - gf_createrenderer, - { - "qnxgf", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTVSYNC | SDL_RENDERER_PRESENTDISCARD | - SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_COLOR | - SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK | - SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | SDL_BLENDMODE_MOD), - (SDL_SCALEMODE_NONE | SDL_SCALEMODE_SLOW), - 13, - { - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_BGR888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGBA8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_YUY2, - SDL_PIXELFORMAT_UYVY, - SDL_PIXELFORMAT_YVYU}, - 0, - 0} -}; - -static SDL_Renderer * -gf_createrenderer(SDL_Window * window, Uint32 flags) -{ - SDL_VideoDisplay *display = window->display; - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - SDL_Renderer *renderer = NULL; - SDL_RenderData *rdata = NULL; - uint32_t it; - int32_t jt; - int32_t status; - - /* Check if it is OpenGL ES window */ - if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { - /* No error, just no need to create 2D renderer for OpenGL ES window */ - return NULL; - } - - /* Allocate new renderer structure */ - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(SDL_Renderer)); - if (renderer == NULL) { - SDL_OutOfMemory(); - return NULL; - } - - /* Allocate renderer data */ - rdata = (SDL_RenderData *) SDL_calloc(1, sizeof(SDL_RenderData)); - if (rdata == NULL) { - SDL_free(renderer); - SDL_OutOfMemory(); - return NULL; - } - - renderer->DisplayModeChanged = gf_displaymodechanged; - renderer->ActivateRenderer = gf_activaterenderer; - renderer->CreateTexture = gf_createtexture; - renderer->QueryTexturePixels = gf_querytexturepixels; - renderer->SetTexturePalette = gf_settexturepalette; - renderer->GetTexturePalette = gf_gettexturepalette; - renderer->SetTextureAlphaMod = gf_settexturealphamod; - renderer->SetTextureColorMod = gf_settexturecolormod; - renderer->SetTextureBlendMode = gf_settextureblendmode; - renderer->SetTextureScaleMode = gf_settexturescalemode; - renderer->UpdateTexture = gf_updatetexture; - renderer->LockTexture = gf_locktexture; - renderer->UnlockTexture = gf_unlocktexture; - renderer->DirtyTexture = gf_dirtytexture; - renderer->RenderPoint = gf_renderpoint; - renderer->RenderLine = gf_renderline; - renderer->RenderFill = gf_renderfill; - renderer->RenderCopy = gf_rendercopy; - renderer->RenderPresent = gf_renderpresent; - renderer->DestroyTexture = gf_destroytexture; - renderer->DestroyRenderer = gf_destroyrenderer; - renderer->info = gf_renderdriver.info; - renderer->window = window; - renderer->driverdata = rdata; - - /* Set render acceleration flag in case it is accelerated */ - if ((didata->caps & SDL_GF_ACCELERATED) == SDL_GF_ACCELERATED) { - renderer->info.flags = SDL_RENDERER_ACCELERATED; - } else { - renderer->info.flags &= ~(SDL_RENDERER_ACCELERATED); - } - - rdata->window = window; - - /* Check if upper level requested synchronization on vsync signal */ - if ((flags & SDL_RENDERER_PRESENTVSYNC) == SDL_RENDERER_PRESENTVSYNC) { - rdata->enable_vsync = SDL_TRUE; - } else { - rdata->enable_vsync = SDL_FALSE; - } - - /* Check what buffer copy/flip scheme is requested */ - rdata->surfaces_count = 0; - if ((flags & SDL_RENDERER_SINGLEBUFFER) == SDL_RENDERER_SINGLEBUFFER) { - if ((flags & SDL_RENDERER_PRESENTDISCARD) == - SDL_RENDERER_PRESENTDISCARD) { - renderer->info.flags |= - SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD; - } else { - renderer->info.flags |= - SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; - } - rdata->surfaces_count = 1; - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 0; - } else { - if ((flags & SDL_RENDERER_PRESENTFLIP2) == SDL_RENDERER_PRESENTFLIP2) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; - rdata->surfaces_count = 2; - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 1; - } else { - if ((flags & SDL_RENDERER_PRESENTFLIP3) == - SDL_RENDERER_PRESENTFLIP3) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; - rdata->surfaces_count = 3; - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 1; - } else { - renderer->info.flags |= - SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY; - rdata->surfaces_count = 1; - rdata->surface_visible_idx = 0; - rdata->surface_render_idx = 0; - } - } - } - - /* Create layer surfaces, which could be visible */ - for (it = 0; it < rdata->surfaces_count; it++) { - /* TODO: add palette creation */ - - /* Create displayable surfaces */ - status = - gf_surface_create_layer(&rdata->surface[it], &didata->layer, 1, 0, - didata->current_mode.w, - didata->current_mode.h, - qnxgf_sdl_to_gf_pixelformat(didata-> - current_mode. - format), NULL, - GF_SURFACE_CREATE_2D_ACCESSIBLE); - - if (status != GF_ERR_OK) { - /* Free already allocated surfaces */ - for (jt = it - 1; jt > 0; jt--) { - gf_surface_free(rdata->surface[jt]); - rdata->surface[jt] = NULL; - } - SDL_free(rdata); - SDL_free(renderer); - if (status == GF_ERR_MEM) { - SDL_SetError("unsufficient free video memory"); - } else { - SDL_SetError("error during displayable surface creation"); - } - return NULL; - } - - /* Get detailed information about allocated surface */ - gf_surface_get_info(rdata->surface[it], &rdata->surface_info[it]); - } - - return renderer; -} - -void -gf_addrenderdriver(_THIS) -{ - uint32_t it; - - for (it = 0; it < _this->num_displays; it++) { - SDL_AddRenderDriver(&_this->displays[it], &gf_renderdriver); - } -} - -/****************************************************************************/ -/* SDL render interface */ -/****************************************************************************/ -static int -gf_displaymodechanged(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - - /* Remove all allocated surfaces, they are no more valid */ - - /* TODO: Add video mode change detection and new parameters detection */ - - return 0; -} - -static int -gf_activaterenderer(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - SDL_VideoDisplay *display = rdata->window->display; - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - - /* Setup current surface as visible */ -// gf_layer_set_surfaces(didata->layer, &rdata->surface[rdata->surface_visible_idx], 1); - - /* Set visible surface when hardware in idle state */ -// gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE); - - return 0; -} - -static int -gf_createtexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - SDL_RenderData *renderdata = (SDL_RenderData *) renderer->driverdata; - SDL_Window *window = SDL_GetWindowFromID(renderer->window); - SDL_VideoDisplay *display = window->display; - SDL_TextureData *tdata = NULL; - - /* Allocate texture driver data */ - tdata = (SDL_TextureData *) SDL_calloc(1, sizeof(SDL_TextureData)); - if (tdata == NULL) { - SDL_OutOfMemory(); - return -1; - } - - /* Set texture driver data */ - texture->driverdata = tdata; - -} - -static int -gf_querytexturepixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ -} - -static int -gf_settexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, int ncolors) -{ -} - -static int -gf_gettexturepalette(SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, int ncolors) -{ -} - -static int -gf_settexturecolormod(SDL_Renderer * renderer, SDL_Texture * texture) -{ -} - -static int -gf_settexturealphamod(SDL_Renderer * renderer, SDL_Texture * texture) -{ -} - -static int -gf_settextureblendmode(SDL_Renderer * renderer, SDL_Texture * texture) -{ -} - -static int -gf_settexturescalemode(SDL_Renderer * renderer, SDL_Texture * texture) -{ -} - -static int -gf_updatetexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ -} - -static int -gf_locktexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ -} - -static void -gf_unlocktexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ -} - -static void -gf_dirtytexture(SDL_Renderer * renderer, SDL_Texture * texture, int numrects, - const SDL_Rect * rects) -{ -} - -static int -gf_renderpoint(SDL_Renderer * renderer, int x, int y) -{ -} - -static int -gf_renderline(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) -{ -} - -static int -gf_renderfill(SDL_Renderer * renderer, const SDL_Rect * rect) -{ -} - -static int -gf_rendercopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ -} - -static void -gf_renderpresent(SDL_Renderer * renderer) -{ -} - -static void -gf_destroytexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ -} - -static void -gf_destroyrenderer(SDL_Renderer * renderer) -{ - SDL_RenderData *rdata = (SDL_RenderData *) renderer->driverdata; - uint32_t it; - - for (it = 0; it < rdata->surfaces_count; it++) { - if (rdata->surface[it] != NULL) { - gf_surface_free(rdata->surface[it]); - } - } -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_render.h b/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_render.h deleted file mode 100644 index 99986c6bd..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_gf_render.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_GF_RENDER_H__ -#define __SDL_GF_RENDER_H__ - -#include "../SDL_sysvideo.h" - -#include - -#define SDL_GF_MAX_SURFACES 3 - -typedef struct SDL_RenderData -{ - SDL_Window *window; /* SDL window type */ - SDL_bool enable_vsync; /* VSYNC flip synchronization enable */ - gf_surface_t surface[SDL_GF_MAX_SURFACES]; /* Surface handles */ - gf_surface_info_t surface_info[SDL_GF_MAX_SURFACES]; /* Surface info */ - uint32_t surface_visible_idx; /* Index of visible surface */ - uint32_t surface_render_idx; /* Index of render surface */ - uint32_t surfaces_count; /* Amount of allocated surfaces */ -} SDL_RenderData; - -typedef struct SDL_TextureData -{ - gf_surface_t surface; - gf_surface_info_t surface_info; -} SDL_TextureData; - -extern void gf_addrenderdriver(_THIS); - -#endif /* __SDL_GF_RENDER_H__ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_joystick.h b/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_joystick.h deleted file mode 100644 index 15423a344..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_joystick.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_HIDDI_JOYSTICK_H__ -#define __SDL_HIDDI_JOYSTICK_H__ - -#include - -#endif /* __SDL_HIDDI_JOYSTICK_H__ */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_keyboard.h b/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_keyboard.h deleted file mode 100644 index 17bbddb58..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_keyboard.h +++ /dev/null @@ -1,159 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_HIDDI_KEYBOARD_H__ -#define __SDL_HIDDI_KEYBOARD_H__ - -#include - -/* PS/2 and USB keyboards are generating this packet */ -typedef struct key_packet -{ - uint8_t modifiers; - uint8_t data; - uint8_t codes[6]; -} key_packet; - -/* Key modifier codes */ -#define HIDDI_MKEY_LEFT_CTRL 0x00000001 -#define HIDDI_MKEY_LEFT_SHIFT 0x00000002 -#define HIDDI_MKEY_LEFT_ALT 0x00000004 -#define HIDDI_MKEY_LEFT_WFLAG 0x00000008 -#define HIDDI_MKEY_RIGHT_CTRL 0x00000010 -#define HIDDI_MKEY_RIGHT_SHIFT 0x00000020 -#define HIDDI_MKEY_RIGHT_ALT 0x00000040 -#define HIDDI_MKEY_RIGHT_WFLAG 0x00000080 - -/* Key codes */ -#define HIDDI_KEY_UNPRESSED 0x00000000 -#define HIDDI_KEY_OVERFLOW 0x00000001 -#define HIDDI_KEY_ESC 0x00000029 -#define HIDDI_KEY_F1 0x0000003A -#define HIDDI_KEY_F2 0x0000003B -#define HIDDI_KEY_F3 0x0000003C -#define HIDDI_KEY_F4 0x0000003D -#define HIDDI_KEY_F5 0x0000003E -#define HIDDI_KEY_F6 0x0000003F -#define HIDDI_KEY_F7 0x00000040 -#define HIDDI_KEY_F8 0x00000041 -#define HIDDI_KEY_F9 0x00000042 -#define HIDDI_KEY_F10 0x00000043 -#define HIDDI_KEY_F11 0x00000044 -#define HIDDI_KEY_F12 0x00000045 - -#define HIDDI_KEY_BACKQUOTE 0x00000035 -#define HIDDI_KEY_1 0x0000001E -#define HIDDI_KEY_2 0x0000001F -#define HIDDI_KEY_3 0x00000020 -#define HIDDI_KEY_4 0x00000021 -#define HIDDI_KEY_5 0x00000022 -#define HIDDI_KEY_6 0x00000023 -#define HIDDI_KEY_7 0x00000024 -#define HIDDI_KEY_8 0x00000025 -#define HIDDI_KEY_9 0x00000026 -#define HIDDI_KEY_0 0x00000027 -#define HIDDI_KEY_MINUS 0x0000002D -#define HIDDI_KEY_EQUAL 0x0000002E -#define HIDDI_KEY_BACKSPACE 0x0000002A - -#define HIDDI_KEY_TAB 0x0000002B -#define HIDDI_KEY_Q 0x00000014 -#define HIDDI_KEY_W 0x0000001A -#define HIDDI_KEY_E 0x00000008 -#define HIDDI_KEY_R 0x00000015 -#define HIDDI_KEY_T 0x00000017 -#define HIDDI_KEY_Y 0x0000001C -#define HIDDI_KEY_U 0x00000018 -#define HIDDI_KEY_I 0x0000000C -#define HIDDI_KEY_O 0x00000012 -#define HIDDI_KEY_P 0x00000013 -#define HIDDI_KEY_LEFT_SQ_BRACKET 0x0000002F -#define HIDDI_KEY_RIGHT_SQ_BRACKET 0x00000030 -#define HIDDI_KEY_BACKSLASH 0x00000031 - -#define HIDDI_KEY_CAPSLOCK 0x00000039 -#define HIDDI_KEY_A 0x00000004 -#define HIDDI_KEY_S 0x00000016 -#define HIDDI_KEY_D 0x00000007 -#define HIDDI_KEY_F 0x00000009 -#define HIDDI_KEY_G 0x0000000A -#define HIDDI_KEY_H 0x0000000B -#define HIDDI_KEY_J 0x0000000D -#define HIDDI_KEY_K 0x0000000E -#define HIDDI_KEY_L 0x0000000F -#define HIDDI_KEY_SEMICOLON 0x00000033 -#define HIDDI_KEY_QUOTE 0x00000034 -#define HIDDI_KEY_ENTER 0x00000028 - -#define HIDDI_KEY_Z 0x0000001D -#define HIDDI_KEY_X 0x0000001B -#define HIDDI_KEY_C 0x00000006 -#define HIDDI_KEY_V 0x00000019 -#define HIDDI_KEY_B 0x00000005 -#define HIDDI_KEY_N 0x00000011 -#define HIDDI_KEY_M 0x00000010 -#define HIDDI_KEY_COMMA 0x00000036 -#define HIDDI_KEY_POINT 0x00000037 -#define HIDDI_KEY_SLASH 0x00000038 - -#define HIDDI_KEY_SPACE 0x0000002C -#define HIDDI_KEY_MENU 0x00000065 - -#define HIDDI_KEY_PRINTSCREEN 0x00000046 -#define HIDDI_KEY_SCROLLLOCK 0x00000047 -#define HIDDI_KEY_PAUSE 0x00000048 - -#define HIDDI_KEY_INSERT 0x00000049 -#define HIDDI_KEY_HOME 0x0000004A -#define HIDDI_KEY_PAGEUP 0x0000004B -#define HIDDI_KEY_DELETE 0x0000004C -#define HIDDI_KEY_END 0x0000004D -#define HIDDI_KEY_PAGEDOWN 0x0000004E - -#define HIDDI_KEY_UP 0x00000052 -#define HIDDI_KEY_LEFT 0x00000050 -#define HIDDI_KEY_DOWN 0x00000051 -#define HIDDI_KEY_RIGHT 0x0000004F - -#define HIDDI_KEY_NUMLOCK 0x00000053 -#define HIDDI_KEY_GR_SLASH 0x00000054 -#define HIDDI_KEY_GR_ASTERISK 0x00000055 -#define HIDDI_KEY_GR_MINUS 0x00000056 -#define HIDDI_KEY_GR_7 0x0000005F -#define HIDDI_KEY_GR_8 0x00000060 -#define HIDDI_KEY_GR_9 0x00000061 -#define HIDDI_KEY_GR_PLUS 0x00000057 -#define HIDDI_KEY_GR_4 0x0000005C -#define HIDDI_KEY_GR_5 0x0000005D -#define HIDDI_KEY_GR_6 0x0000005E -#define HIDDI_KEY_GR_1 0x00000059 -#define HIDDI_KEY_GR_2 0x0000005A -#define HIDDI_KEY_GR_3 0x0000005B -#define HIDDI_KEY_GR_ENTER 0x00000058 -#define HIDDI_KEY_GR_0 0x00000062 -#define HIDDI_KEY_GR_DELETE 0x00000063 - -#endif /* __SDL_HIDDI_KEYBOARD_H__ */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_mouse.h b/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_mouse.h deleted file mode 100644 index 9cbe51e4e..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_hiddi_mouse.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_HIDDI_MOUSE_H__ -#define __SDL_HIDDI_MOUSE_H__ - -#include - -/* USB keyboard multimedia keys are generating this packet */ -typedef struct mouse_packet2 -{ - uint8_t buttons; - int8_t wheel; -} mouse_packet2; - -/* PS/2 mice are generating this packet */ -typedef struct mouse_packet4 -{ - uint8_t buttons; - int8_t horizontal; - int8_t vertical; - int8_t wheel; -} mouse_packet4; - -/* USB keyboard with mice wheel onboard generating this packet */ -typedef struct mouse_packet5 -{ - uint8_t buttons; - int8_t horizontal; - int8_t vertical; - int8_t wheel; - uint8_t state; -} mouse_packet5; - -/* USB multi-button mice are generating this packet */ -typedef struct mouse_packet8 -{ - uint8_t buttons; - int8_t horizontal; - int8_t vertical; - int8_t wheel; - int16_t horizontal_precision; - int16_t vertical_precision; -} mouse_packet8; - -#endif /* __SDL_HIDDI_MOUSE_H__ */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_qnxgf.c b/project/jni/sdl-1.3/src/video/qnxgf/SDL_qnxgf.c deleted file mode 100644 index ab6867968..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_qnxgf.c +++ /dev/null @@ -1,1934 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#include "SDL_config.h" - -#include "../SDL_sysvideo.h" -#include "SDL_version.h" -#include "SDL_syswm.h" -#include "SDL_loadso.h" - -/* Include QNX Graphics Framework declarations */ -#include - -#include "SDL_qnxgf.h" -#include "SDL_gf_render.h" -#include "SDL_gf_pixelfmt.h" -#include "SDL_gf_opengles.h" -#include "SDL_gf_input.h" - -/******************************************************************************/ -/* SDL Generic video modes, which could provide GF */ -/* This is real pain in the ass. GF is just wrapper around a selected driver */ -/* some drivers could support double scan modes, like 320x200, 512x384, etc */ -/* but some drivers are not. Later we can distinguish one driver from another */ -/* Feel free to add any new custom graphics mode */ -/******************************************************************************/ -static const SDL_DisplayMode generic_mode[] = { - {0, 320, 200, 70, NULL}, /* 320x200 modes are 70Hz and 85Hz */ - {0, 320, 200, 85, NULL}, - {0, 320, 240, 70, NULL}, /* 320x240 modes are 70Hz and 85Hz */ - {0, 320, 240, 85, NULL}, - {0, 400, 300, 60, NULL}, /* 400x300 mode is 60Hz only */ - {0, 480, 360, 60, NULL}, /* 480x360 mode is 60Hz only */ - {0, 512, 384, 60, NULL}, /* 512x384 modes are 60Hz and 70Hz */ - {0, 512, 384, 70, NULL}, - {0, 640, 480, 60, NULL}, /* 640x480 modes are 60Hz, 75Hz, 85Hz */ - {0, 640, 480, 75, NULL}, - {0, 640, 480, 85, NULL}, - {0, 800, 600, 60, NULL}, /* 800x600 modes are 60Hz, 75Hz, 85Hz */ - {0, 800, 600, 75, NULL}, - {0, 800, 600, 85, NULL}, - {0, 800, 480, 60, NULL}, /* 800x480 mode is 60Hz only */ - {0, 848, 480, 60, NULL}, /* 848x480 mode is 60Hz only */ - {0, 960, 600, 60, NULL}, /* 960x600 mode is 60Hz only */ - {0, 1024, 640, 60, NULL}, /* 1024x640 mode is 60Hz only */ - {0, 1024, 768, 60, NULL}, /* 1024x768 modes are 60Hz, 70Hz, 75Hz */ - {0, 1024, 768, 70, NULL}, - {0, 1024, 768, 75, NULL}, - {0, 1088, 612, 60, NULL}, /* 1088x612 mode is 60Hz only */ - {0, 1152, 864, 60, NULL}, /* 1152x864 modes are 60Hz, 70Hz, 72Hz */ - {0, 1152, 864, 70, NULL}, /* 75Hz and 85Hz */ - {0, 1152, 864, 72, NULL}, - {0, 1152, 864, 75, NULL}, - {0, 1152, 864, 85, NULL}, - {0, 1280, 720, 60, NULL}, /* 1280x720 mode is 60Hz only */ - {0, 1280, 768, 60, NULL}, /* 1280x768 mode is 60Hz only */ - {0, 1280, 800, 60, NULL}, /* 1280x800 mode is 60Hz only */ - {0, 1280, 960, 60, NULL}, /* 1280x960 mode is 60Hz only */ - {0, 1280, 1024, 60, NULL}, /* 1280x1024 modes are 60Hz, 75Hz, 85Hz and */ - {0, 1280, 1024, 75, NULL}, /* 100 Hz */ - {0, 1280, 1024, 85, NULL}, /* */ - {0, 1280, 1024, 100, NULL}, /* */ - {0, 1360, 768, 60, NULL}, /* 1360x768 mode is 60Hz only */ - {0, 1400, 1050, 60, NULL}, /* 1400x1050 mode is 60Hz only */ - {0, 1440, 900, 60, NULL}, /* 1440x900 mode is 60Hz only */ - {0, 1440, 960, 60, NULL}, /* 1440x960 mode is 60Hz only */ - {0, 1600, 900, 60, NULL}, /* 1600x900 mode is 60Hz only */ - {0, 1600, 1024, 60, NULL}, /* 1600x1024 mode is 60Hz only */ - {0, 1600, 1200, 60, NULL}, /* 1600x1200 mode is 60Hz only */ - {0, 1680, 1050, 60, NULL}, /* 1680x1050 mode is 60Hz only */ - {0, 1920, 1080, 60, NULL}, /* 1920x1080 mode is 60Hz only */ - {0, 1920, 1200, 60, NULL}, /* 1920x1200 mode is 60Hz only */ - {0, 1920, 1440, 60, NULL}, /* 1920x1440 mode is 60Hz only */ - {0, 2048, 1536, 60, NULL}, /* 2048x1536 mode is 60Hz only */ - {0, 2048, 1080, 60, NULL}, /* 2048x1080 mode is 60Hz only */ - {0, 0, 0, 0, NULL} /* End of generic mode list */ -}; - -/* Low level device graphics driver names, which they are reporting */ -static const GF_DeviceCaps gf_devicename[] = { - /* ATI Rage 128 graphics driver (devg-ati_rage128) */ - {"ati_rage128", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Fujitsu Carmine graphics driver (devg-carmine.so) */ - {"carmine", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* C&T graphics driver (devg-chips.so) */ - {"chips", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Fujitsu Coral graphics driver (devg-coral.so) */ - {"coral", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Intel integrated graphics driver (devg-extreme2.so) */ - {"extreme2", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Unaccelerated FB driver (devg-flat.so) */ - {"flat", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY}, - /* NS Geode graphics driver (devg-geode.so) */ - {"geode", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Geode LX graphics driver (devg-geodelx.so) */ - {"geodelx", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Intel integrated graphics driver (devg-gma9xx.so) */ - {"gma", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Intel integrated graphics driver (devg-i810.so) */ - {"i810", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Intel integrated graphics driver (devg-i830.so) */ - {"i830", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Geode LX graphics driver (devg-lx800.so) */ - {"lx800", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Matrox Gxx graphics driver (devg-matroxg.so) */ - {"matroxg", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Intel Poulsbo graphics driver (devg-poulsbo.so) */ - {"poulsbo", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* ATI Radeon driver (devg-radeon.so) */ - {"radeon", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* ATI Rage driver (devg-rage.so) */ - {"rage", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* S3 Savage graphics driver (devg-s3_savage.so) */ - {"s3_savage", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* SiS630 integrated graphics driver (devg-sis630.so) */ - {"sis630", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* PowerVR SGX 535 graphics driver (devg-poulsbo.so) */ - {"sgx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_ACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* SM Voyager GX graphics driver (devg-smi5xx.so) */ - {"smi5xx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* Silicon Motion graphics driver (devg-smi7xx.so) */ - {"smi7xx", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* SVGA unaccelerated gfx driver (devg-svga.so) */ - {"svga", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY}, - /* nVidia TNT graphics driver (devg-tnt.so) */ - {"tnt", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* VIA integrated graphics driver (devg-tvia.so) */ - {"tvia", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* VIA UniChrome graphics driver (devg-unichrome.so) */ - {"unichrome", SDL_GF_ACCELERATED | SDL_GF_NOLOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* VESA unaccelerated gfx driver (devg-vesa.so) */ - {"vesa", SDL_GF_UNACCELERATED | SDL_GF_LOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY}, - /* VmWare graphics driver (devg-volari.so) */ - {"vmware", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_NOVIDEOMEMORY}, - /* XGI XP10 graphics driver (devg-volari.so) */ - {"volari", SDL_GF_ACCELERATED | SDL_GF_LOWRESOLUTION | - SDL_GF_UNACCELERATED_3D | SDL_GF_VIDEOMEMORY}, - /* End of list */ - {NULL, 0x00000000} -}; - -/*****************************************************************************/ -/* SDL Video Device initialization functions */ -/*****************************************************************************/ - -static int -qnxgf_available(void) -{ - gf_dev_t gfdev; - gf_dev_info_t gfdev_info; - int status; - - /* Try to attach to graphics device driver */ - status = gf_dev_attach(&gfdev, GF_DEVICE_INDEX(0), &gfdev_info); - if (status != GF_ERR_OK) { - return 0; - } - - /* Detach from graphics device driver for now */ - gf_dev_detach(gfdev); - - return 1; -} - -static void -qnxgf_destroy(SDL_VideoDevice * device) -{ - SDL_VideoData *gfdata = (SDL_VideoData *) device->driverdata; - - /* Detach from graphics device driver, if it was initialized */ - if (gfdata->gfinitialized != SDL_FALSE) { - gf_dev_detach(gfdata->gfdev); - gfdata->gfdev = NULL; - } - - if (device->driverdata != NULL) { - device->driverdata = NULL; - } -} - -static SDL_VideoDevice * -qnxgf_create(int devindex) -{ - SDL_VideoDevice *device; - SDL_VideoData *gfdata; - int status; - - /* Initialize SDL_VideoDevice structure */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device == NULL) { - SDL_OutOfMemory(); - return NULL; - } - - /* Initialize internal GF specific data */ - gfdata = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); - if (gfdata == NULL) { - SDL_OutOfMemory(); - SDL_free(device); - return NULL; - } - device->driverdata = gfdata; - - /* By default GF is not initialized */ - gfdata->gfinitialized = SDL_FALSE; - - /* Try to attach to graphics device driver */ - status = - gf_dev_attach(&gfdata->gfdev, GF_DEVICE_INDEX(devindex), - &gfdata->gfdev_info); - if (status != GF_ERR_OK) { - SDL_OutOfMemory(); - SDL_free(gfdata); - SDL_free(device); - return NULL; - } - - if (gfdata->gfdev_info.description == NULL) { - gf_dev_detach(gfdata->gfdev); - SDL_SetError("GF: Failed to initialize graphics driver"); - return NULL; - } - - /* Setup amount of available displays and current display */ - device->num_displays = 0; - device->current_display = 0; - - /* Setup device shutdown function */ - gfdata->gfinitialized = SDL_TRUE; - device->free = qnxgf_destroy; - - /* Setup all functions which we can handle */ - device->VideoInit = qnxgf_videoinit; - device->VideoQuit = qnxgf_videoquit; - device->GetDisplayModes = qnxgf_getdisplaymodes; - device->SetDisplayMode = qnxgf_setdisplaymode; - device->SetDisplayPalette = qnxgf_setdisplaypalette; - device->GetDisplayPalette = qnxgf_getdisplaypalette; - device->SetDisplayGammaRamp = qnxgf_setdisplaygammaramp; - device->GetDisplayGammaRamp = qnxgf_getdisplaygammaramp; - device->CreateWindow = qnxgf_createwindow; - device->CreateWindowFrom = qnxgf_createwindowfrom; - device->SetWindowTitle = qnxgf_setwindowtitle; - device->SetWindowIcon = qnxgf_setwindowicon; - device->SetWindowPosition = qnxgf_setwindowposition; - device->SetWindowSize = qnxgf_setwindowsize; - device->ShowWindow = qnxgf_showwindow; - device->HideWindow = qnxgf_hidewindow; - device->RaiseWindow = qnxgf_raisewindow; - device->MaximizeWindow = qnxgf_maximizewindow; - device->MinimizeWindow = qnxgf_minimizewindow; - device->RestoreWindow = qnxgf_restorewindow; - device->SetWindowGrab = qnxgf_setwindowgrab; - device->DestroyWindow = qnxgf_destroywindow; - device->GetWindowWMInfo = qnxgf_getwindowwminfo; - device->GL_LoadLibrary = qnxgf_gl_loadlibrary; - device->GL_GetProcAddress = qnxgf_gl_getprocaddres; - device->GL_UnloadLibrary = qnxgf_gl_unloadlibrary; - device->GL_CreateContext = qnxgf_gl_createcontext; - device->GL_MakeCurrent = qnxgf_gl_makecurrent; - device->GL_SetSwapInterval = qnxgf_gl_setswapinterval; - device->GL_GetSwapInterval = qnxgf_gl_getswapinterval; - device->GL_SwapWindow = qnxgf_gl_swapwindow; - device->GL_DeleteContext = qnxgf_gl_deletecontext; - device->PumpEvents = qnxgf_pumpevents; - device->SuspendScreenSaver = qnxgf_suspendscreensaver; - - return device; -} - -VideoBootStrap qnxgf_bootstrap = { - "qnxgf", - "SDL QNX Graphics Framework (GF) video driver", - qnxgf_available, - qnxgf_create -}; - -/*****************************************************************************/ -/* SDL Video and Display initialization/handling functions */ -/*****************************************************************************/ -int -qnxgf_videoinit(_THIS) -{ - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - uint32_t it; - uint32_t jt; - char *override; - int32_t status; - - /* By default GF uses buffer swap on vsync */ - gfdata->swapinterval = 1; - - /* Add each detected output to SDL */ - for (it = 0; it < gfdata->gfdev_info.ndisplays; it++) { - SDL_VideoDisplay display; - SDL_DisplayMode current_mode; - SDL_DisplayData *didata; - - didata = (SDL_DisplayData *) SDL_calloc(1, sizeof(SDL_DisplayData)); - if (didata == NULL) { - /* memory allocation problem */ - SDL_OutOfMemory(); - return -1; - } - - /* Set default cursor settings, maximum 128x128 cursor */ - didata->cursor_visible = SDL_FALSE; - didata->cursor.type = GF_CURSOR_BITMAP; - didata->cursor.hotspot.x = 0; - didata->cursor.hotspot.y = 0; - didata->cursor.cursor.bitmap.w = SDL_VIDEO_GF_MAX_CURSOR_SIZE; - didata->cursor.cursor.bitmap.h = SDL_VIDEO_GF_MAX_CURSOR_SIZE; - didata->cursor.cursor.bitmap.stride = - (didata->cursor.cursor.bitmap.w + 7) / (sizeof(uint8_t) * 8); - didata->cursor.cursor.bitmap.color0 = 0x00000000; - didata->cursor.cursor.bitmap.color1 = 0x00000000; - didata->cursor.cursor.bitmap.image0 = - SDL_calloc(sizeof(uint8_t), - (didata->cursor.cursor.bitmap.w + - 7) * didata->cursor.cursor.bitmap.h / - (sizeof(uint8_t) * 8)); - if (didata->cursor.cursor.bitmap.image0 == NULL) { - SDL_free(didata); - SDL_OutOfMemory(); - return -1; - } - didata->cursor.cursor.bitmap.image1 = - SDL_calloc(sizeof(uint8_t), - (didata->cursor.cursor.bitmap.w + - 7) * didata->cursor.cursor.bitmap.h / - (sizeof(uint8_t) * 8)); - if (didata->cursor.cursor.bitmap.image1 == NULL) { - SDL_OutOfMemory(); - SDL_free((void *) didata->cursor.cursor.bitmap.image0); - SDL_free(didata); - return -1; - } - - /* Query current display settings */ - status = gf_display_query(gfdata->gfdev, it, &didata->display_info); - if (status == GF_ERR_OK) { - SDL_zero(current_mode); - current_mode.w = didata->display_info.xres; - current_mode.h = didata->display_info.yres; - current_mode.refresh_rate = didata->display_info.refresh; - current_mode.format = - qnxgf_gf_to_sdl_pixelformat(didata->display_info.format); - current_mode.driverdata = NULL; - } else { - /* video initialization problem */ - SDL_free((void *) didata->cursor.cursor.bitmap.image0); - SDL_free((void *) didata->cursor.cursor.bitmap.image1); - SDL_free(didata); - SDL_SetError("GF: Display query failed"); - return -1; - } - - /* Attach GF to selected display */ - status = gf_display_attach(&didata->display, gfdata->gfdev, it, NULL); - if (status != GF_ERR_OK) { - /* video initialization problem */ - SDL_free((void *) didata->cursor.cursor.bitmap.image0); - SDL_free((void *) didata->cursor.cursor.bitmap.image1); - SDL_free(didata); - SDL_SetError("GF: Couldn't attach to display"); - return -1; - } - - /* Initialize status variables */ - didata->layer_attached = SDL_FALSE; - - /* Attach to main display layer */ - status = - gf_layer_attach(&didata->layer, didata->display, - didata->display_info.main_layer_index, 0); - if (status != GF_ERR_OK) { - /* Failed to attach to main layer */ - SDL_free((void *) didata->cursor.cursor.bitmap.image0); - SDL_free((void *) didata->cursor.cursor.bitmap.image1); - SDL_free(didata); - SDL_SetError - ("GF: Couldn't attach to main layer, it could be busy"); - return -1; - } - - /* Mark main display layer is attached */ - didata->layer_attached = SDL_TRUE; - - /* Set layer source and destination viewport */ - gf_layer_set_src_viewport(didata->layer, 0, 0, current_mode.w - 1, - current_mode.h - 1); - gf_layer_set_dst_viewport(didata->layer, 0, 0, current_mode.w - 1, - current_mode.h - 1); - - /* Create main visible on display surface */ - status = gf_surface_create_layer(&didata->surface[0], &didata->layer, - 1, 0, current_mode.w, current_mode.h, - qnxgf_sdl_to_gf_pixelformat - (current_mode.format), NULL, - GF_SURFACE_CREATE_2D_ACCESSIBLE | - GF_SURFACE_CREATE_3D_ACCESSIBLE | - GF_SURFACE_CREATE_SHAREABLE); - if (status != GF_ERR_OK) { - gf_layer_disable(didata->layer); - gf_layer_detach(didata->layer); - didata->layer_attached = SDL_FALSE; - SDL_free((void *) didata->cursor.cursor.bitmap.image0); - SDL_free((void *) didata->cursor.cursor.bitmap.image1); - SDL_free(didata); - SDL_SetError("GF: Can't create main layer surface at init (%d)\n", - status); - return -1; - } - - /* Set just created surface as main visible on the layer */ -// gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1); - - /* Update layer parameters */ - status = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE); - if (status != GF_ERR_OK) { - /* Free allocated surface */ - gf_surface_free(didata->surface[0]); - didata->surface[0] = NULL; - - /* Disable and detach from layer */ - gf_layer_disable(didata->layer); - gf_layer_detach(didata->layer); - didata->layer_attached = SDL_FALSE; - SDL_free((void *) didata->cursor.cursor.bitmap.image0); - SDL_free((void *) didata->cursor.cursor.bitmap.image1); - SDL_free(didata); - SDL_SetError("GF: Can't update layer parameters\n"); - return -1; - } - - /* Enable layer in case if hardware supports layer enable/disable */ - gf_layer_enable(didata->layer); - - /* Copy device name for each display */ - SDL_strlcpy(didata->description, gfdata->gfdev_info.description, - SDL_VIDEO_GF_DEVICENAME_MAX - 1); - - /* Search device capabilities and possible workarounds */ - jt = 0; - do { - if (gf_devicename[jt].name == NULL) { - break; - } - if (SDL_strncmp - (gf_devicename[jt].name, didata->description, - SDL_strlen(gf_devicename[jt].name)) == 0) { - didata->caps = gf_devicename[jt].caps; - } - jt++; - } while (1); - - /* Initialize display structure */ - SDL_zero(display); - display.desktop_mode = current_mode; - display.current_mode = current_mode; - display.driverdata = didata; - didata->current_mode = current_mode; - SDL_AddVideoDisplay(&display); - - /* Check for environment variables which could override some SDL settings */ - didata->custom_refresh = 0; - override = SDL_getenv("SDL_VIDEO_GF_REFRESH_RATE"); - if (override != NULL) { - if (SDL_sscanf(override, "%u", &didata->custom_refresh) != 1) { - didata->custom_refresh = 0; - } - } - - /* Get all display modes for this display */ - qnxgf_getdisplaymodes(_this, display); - } - - /* Add GF renderer to SDL */ - gf_addrenderdriver(_this); - - /* Add GF input devices */ - status = gf_addinputdevices(_this); - if (status != 0) { - /* SDL error is set by gf_addinputdevices() function */ - return -1; - } - - /* video has been initialized successfully */ - return 1; -} - -void -qnxgf_videoquit(_THIS) -{ - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata = NULL; - uint32_t it; - - /* Check if GF was initialized before */ - if ((gfdata == NULL) || (gfdata->gfinitialized != SDL_TRUE)) - { - /* If not, do not deinitialize */ - return; - } - - /* Stop collecting mouse events */ - hiddi_disable_mouse(); - /* Delete GF input devices */ - gf_delinputdevices(_this); - - /* SDL will restore old desktop mode on exit */ - for (it = 0; it < _this->num_displays; it++) { - didata = _this->displays[it].driverdata; - - /* Free cursor image */ - if (didata->cursor.cursor.bitmap.image0 != NULL) { - SDL_free((void *) didata->cursor.cursor.bitmap.image0); - didata->cursor.cursor.bitmap.image0 = NULL; - } - if (didata->cursor.cursor.bitmap.image1 != NULL) { - SDL_free((void *) didata->cursor.cursor.bitmap.image1); - didata->cursor.cursor.bitmap.image1 = NULL; - } - - /* Free main surface */ - if (didata->surface[0] != NULL) { - gf_surface_free(didata->surface[0]); - didata->surface[0] = NULL; - } - - /* Free back surface */ - if (didata->surface[1] != NULL) { - gf_surface_free(didata->surface[1]); - didata->surface[1] = NULL; - } - - /* Free second back surface */ - if (didata->surface[2] != NULL) { - gf_surface_free(didata->surface[2]); - didata->surface[2] = NULL; - } - - /* Detach layer before quit */ - if (didata->layer_attached == SDL_TRUE) { - /* Disable layer if hardware supports this */ - gf_layer_disable(didata->layer); - - /* Detach from layer, free it for others */ - gf_layer_detach(didata->layer); - didata->layer = NULL; - - /* Mark it as detached */ - didata->layer_attached = SDL_FALSE; - } - - /* Detach from selected display */ - gf_display_detach(didata->display); - didata->display = NULL; - } -} - -void -qnxgf_getdisplaymodes(_THIS, SDL_VideoDisplay * display) -{ - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - SDL_DisplayMode mode; - gf_modeinfo_t modeinfo; - uint32_t it = 0; - uint32_t jt = 0; - uint32_t kt = 0; - int status; - - do { - status = gf_display_query_mode(didata->display, it, &modeinfo); - if (status == GF_ERR_OK) { - /* Parsing current mode */ - if ((modeinfo.flags & GF_MODE_GENERIC) == GF_MODE_GENERIC) { - /* This mode is generic, so we can add to SDL our resolutions */ - /* Only pixel format is fixed, refresh rate could be any */ - jt = 0; - do { - if (generic_mode[jt].w == 0) { - break; - } - - /* Check if driver do not supports doublescan video modes */ - if ((didata->caps & SDL_GF_LOWRESOLUTION) != - SDL_GF_LOWRESOLUTION) { - if (generic_mode[jt].w < 640) { - jt++; - continue; - } - } - - mode.w = generic_mode[jt].w; - mode.h = generic_mode[jt].h; - mode.refresh_rate = generic_mode[jt].refresh_rate; - mode.format = - qnxgf_gf_to_sdl_pixelformat(modeinfo.primary_format); - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - - /* If mode is RGBA8888, add the same mode as RGBx888 */ - if (modeinfo.primary_format == GF_FORMAT_BGRA8888) { - mode.w = generic_mode[jt].w; - mode.h = generic_mode[jt].h; - mode.refresh_rate = generic_mode[jt].refresh_rate; - mode.format = SDL_PIXELFORMAT_RGB888; - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - } - /* If mode is RGBA1555, add the same mode as RGBx555 */ - if (modeinfo.primary_format == GF_FORMAT_PACK_ARGB1555) { - mode.w = generic_mode[jt].w; - mode.h = generic_mode[jt].h; - mode.refresh_rate = generic_mode[jt].refresh_rate; - mode.format = SDL_PIXELFORMAT_RGB555; - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - } - - jt++; - } while (1); - } else { - /* Add this display mode as is in case if it is non-generic */ - /* But go through the each refresh rate, supported by gf */ - jt = 0; - do { - if (modeinfo.refresh[jt] != 0) { - mode.w = modeinfo.xres; - mode.h = modeinfo.yres; - mode.refresh_rate = modeinfo.refresh[jt]; - mode.format = - qnxgf_gf_to_sdl_pixelformat(modeinfo. - primary_format); - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - - /* If mode is RGBA8888, add the same mode as RGBx888 */ - if (modeinfo.primary_format == GF_FORMAT_BGRA8888) { - mode.w = modeinfo.xres; - mode.h = modeinfo.yres; - mode.refresh_rate = modeinfo.refresh[jt]; - mode.format = SDL_PIXELFORMAT_RGB888; - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - } - /* If mode is RGBA1555, add the same mode as RGBx555 */ - if (modeinfo.primary_format == - GF_FORMAT_PACK_ARGB1555) { - mode.w = modeinfo.xres; - mode.h = modeinfo.yres; - mode.refresh_rate = modeinfo.refresh[jt]; - mode.format = SDL_PIXELFORMAT_RGB555; - mode.driverdata = NULL; - SDL_AddDisplayMode(display, &mode); - } - - jt++; - } else { - break; - } - } while (1); - } - } else { - if (status == GF_ERR_PARM) { - /* out of available modes, all are listed */ - break; - } - - /* Error occured during mode listing */ - break; - } - it++; - } while (1); -} - -int -qnxgf_setdisplaymode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) -{ - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - uint32_t refresh_rate = 0; - int status; - - /* Current display dimensions and bpp are no more valid */ - didata->current_mode.format = SDL_PIXELFORMAT_UNKNOWN; - didata->current_mode.w = 0; - didata->current_mode.h = 0; - - /* Check if custom refresh rate requested */ - if (didata->custom_refresh != 0) { - refresh_rate = didata->custom_refresh; - } else { - refresh_rate = mode->refresh_rate; - } - - /* Check if SDL GF driver needs to find appropriate refresh rate itself */ - if (refresh_rate == 0) { - uint32_t it; - SDL_DisplayMode tempmode; - - /* Clear display mode structure */ - SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); - tempmode.refresh_rate = 0x0000FFFF; - - /* Check if window width and height matches one of our modes */ - for (it = 0; it < display->num_display_modes; it++) { - if ((display->display_modes[it].w == mode->w) && - (display->display_modes[it].h == mode->h) && - (display->display_modes[it].format == mode->format)) - { - /* Find the lowest refresh rate available */ - if (tempmode.refresh_rate > - display->display_modes[it].refresh_rate) { - tempmode = display->display_modes[it]; - } - } - } - if (tempmode.refresh_rate != 0x0000FFFF) { - refresh_rate = tempmode.refresh_rate; - } else { - /* Let video driver decide what to do with this */ - refresh_rate = 0; - } - } - - /* Check if SDL GF driver needs to check custom refresh rate */ - if (didata->custom_refresh != 0) { - uint32_t it; - SDL_DisplayMode tempmode; - - /* Clear display mode structure */ - SDL_memset(&tempmode, 0x00, sizeof(SDL_DisplayMode)); - tempmode.refresh_rate = 0x0000FFFF; - - /* Check if window width and height matches one of our modes */ - for (it = 0; it < display->num_display_modes; it++) { - if ((display->display_modes[it].w == mode->w) && - (display->display_modes[it].h == mode->h) && - (display->display_modes[it].format == mode->format)) - { - /* Find the lowest refresh rate available */ - if (tempmode.refresh_rate > - display->display_modes[it].refresh_rate) { - tempmode = display->display_modes[it]; - } - - /* Check if requested refresh rate found */ - if (refresh_rate == - display->display_modes[it].refresh_rate) { - tempmode = display->display_modes[it]; - break; - } - } - } - if (tempmode.refresh_rate != 0x0000FFFF) { - refresh_rate = tempmode.refresh_rate; - } else { - /* Let video driver decide what to do with this */ - refresh_rate = 0; - } - } - - /* Free main surface */ - if (didata->surface[0] != NULL) { - gf_surface_free(didata->surface[0]); - didata->surface[0] = NULL; - } - - /* Free back surface */ - if (didata->surface[1] != NULL) { - gf_surface_free(didata->surface[1]); - didata->surface[1] = NULL; - } - - /* Free second back surface */ - if (didata->surface[2] != NULL) { - gf_surface_free(didata->surface[2]); - didata->surface[2] = NULL; - } - - /* Detach layer before switch to new graphics mode */ - if (didata->layer_attached == SDL_TRUE) { - /* Disable layer if hardware supports this */ - gf_layer_disable(didata->layer); - - /* Detach from layer, free it for others */ - gf_layer_detach(didata->layer); - - /* Mark it as detached */ - didata->layer_attached = SDL_FALSE; - } - - /* Set new display video mode */ - status = - gf_display_set_mode(didata->display, mode->w, mode->h, refresh_rate, - qnxgf_sdl_to_gf_pixelformat(mode->format), 0); - if (status != GF_ERR_OK) { - /* Display mode/resolution switch has been failed */ - SDL_SetError("GF: Mode is not supported by graphics driver"); - return -1; - } else { - didata->current_mode = *mode; - didata->current_mode.refresh_rate = refresh_rate; - } - - /* Attach to main display layer */ - status = - gf_layer_attach(&didata->layer, didata->display, - didata->display_info.main_layer_index, 0); - if (status != GF_ERR_OK) { - SDL_SetError("GF: Couldn't attach to main layer, it could be busy"); - - /* Failed to attach to main displayable layer */ - return -1; - } - - /* Mark main display layer is attached */ - didata->layer_attached = SDL_TRUE; - - /* Set layer source and destination viewports */ - gf_layer_set_src_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1); - gf_layer_set_dst_viewport(didata->layer, 0, 0, mode->w - 1, mode->h - 1); - - /* Create main visible on display surface */ - status = - gf_surface_create_layer(&didata->surface[0], &didata->layer, 1, 0, - mode->w, mode->h, - qnxgf_sdl_to_gf_pixelformat(mode->format), - NULL, - GF_SURFACE_CREATE_2D_ACCESSIBLE | - GF_SURFACE_CREATE_3D_ACCESSIBLE | - GF_SURFACE_CREATE_SHAREABLE); - if (status != GF_ERR_OK) { - gf_layer_disable(didata->layer); - gf_layer_detach(didata->layer); - didata->layer_attached = SDL_FALSE; - SDL_SetError - ("GF: Can't create main layer surface at modeswitch (%d)\n", - status); - return -1; - } - - /* Set just created surface as main visible on the layer */ - gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1); - - /* Update layer parameters */ - status = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE); - if (status != GF_ERR_OK) { - /* Free main surface */ - gf_surface_free(didata->surface[0]); - didata->surface[0] = NULL; - - /* Detach layer */ - gf_layer_disable(didata->layer); - gf_layer_detach(didata->layer); - didata->layer_attached = SDL_FALSE; - SDL_SetError("GF: Can't update layer parameters\n"); - return -1; - } - - /* Restore cursor if it was visible */ - if (didata->cursor_visible == SDL_TRUE) { - gf_cursor_set(didata->display, 0, &didata->cursor); - gf_cursor_enable(didata->display, 0); - } - - /* Enable layer in case if hardware supports layer enable/disable */ - gf_layer_enable(didata->layer); - - return 0; -} - -int -qnxgf_setdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette) -{ - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - - /* QNX GF doesn't have support for global palette changing, but we */ - /* could store it for usage in future */ - - SDL_Unsupported(); - return -1; -} - -int -qnxgf_getdisplaypalette(_THIS, SDL_VideoDisplay * display, SDL_Palette * palette) -{ - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - - /* We can't provide current palette settings and looks like SDL */ - /* do not call this function also, in such case this function returns -1 */ - - SDL_Unsupported(); - return -1; -} - -int -qnxgf_setdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp) -{ - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - int status; - - /* Setup gamma ramp, for each color channel */ - status = - gf_display_set_color_lut16(didata->display, (uint16_t *) ramp, - (uint16_t *) ramp + 256, - (uint16_t *) ramp + 512); - if (status != GF_ERR_OK) { - /* Setting display gamma ramp operation has been failed */ - return -1; - } - - return 0; -} - -int -qnxgf_getdisplaygammaramp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp) -{ - /* TODO: We need to return previous gamma set */ - /* Also we need some initial fake gamma to return */ - - SDL_Unsupported(); - return -1; -} - -int -qnxgf_createwindow(_THIS, SDL_Window * window) -{ - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - SDL_VideoDisplay *display = window->display; - SDL_DisplayData *didata = (SDL_DisplayData *) display->driverdata; - SDL_WindowData *wdata; - int32_t status; - - /* QNX GF supports fullscreen window modes only */ - if ((window->flags & SDL_WINDOW_FULLSCREEN) != SDL_WINDOW_FULLSCREEN) { - uint32_t it; - SDL_DisplayMode mode; - - /* Clear display mode structure */ - SDL_memset(&mode, 0x00, sizeof(SDL_DisplayMode)); - mode.refresh_rate = 0x0000FFFF; - - /* Check if window width and height matches one of our modes */ - for (it = 0; it < display->num_display_modes; it++) { - if ((display->display_modes[it].w == window->w) && - (display->display_modes[it].h == window->h) && - (display->display_modes[it].format == - display->desktop_mode.format)) { - /* Find the lowest refresh rate available */ - if (mode.refresh_rate > - display->display_modes[it].refresh_rate) { - mode = display->display_modes[it]; - } - } - } - - /* Check if end of display list has been reached */ - if (mode.refresh_rate == 0x0000FFFF) { - SDL_SetError("GF: Desired video mode is not supported"); - - /* Failed to create new window */ - return -1; - } else { - /* Tell to the caller that mode will be fullscreen */ - window->flags |= SDL_WINDOW_FULLSCREEN; - - /* Setup fullscreen mode, bpp used from desktop mode in this case */ - status = qnxgf_setdisplaymode(_this, &mode); - if (status != 0) { - /* Failed to swith fullscreen video mode */ - return -1; - } - } - } - - /* Setup our own window decorations and states, which are depend on fullscreen mode */ - window->flags |= SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | - SDL_WINDOW_MAXIMIZED | SDL_WINDOW_INPUT_GRABBED | - SDL_WINDOW_INPUT_FOCUS | SDL_WINDOW_MOUSE_FOCUS; - window->flags &= ~(SDL_WINDOW_RESIZABLE | SDL_WINDOW_MINIMIZED); - - /* Ignore any window position settings */ - window->x = SDL_WINDOWPOS_UNDEFINED; - window->y = SDL_WINDOWPOS_UNDEFINED; - - /* Allocate window internal data */ - wdata = (SDL_WindowData *) SDL_calloc(1, sizeof(SDL_WindowData)); - if (wdata == NULL) { - SDL_OutOfMemory(); - return -1; - } - - /* Setup driver data for this window */ - window->driverdata = wdata; - - /* Check if window must support OpenGL ES rendering */ - if ((window->flags & SDL_WINDOW_OPENGL) == SDL_WINDOW_OPENGL) { -#if defined(SDL_VIDEO_OPENGL_ES) - EGLBoolean initstatus; - - /* Mark this window as OpenGL ES compatible */ - wdata->uses_gles = SDL_TRUE; - - /* Create connection to OpenGL ES */ - if (gfdata->egldisplay == EGL_NO_DISPLAY) { - gfdata->egldisplay = eglGetDisplay(gfdata->gfdev); - if (gfdata->egldisplay == EGL_NO_DISPLAY) { - SDL_SetError("GF: Can't get connection to OpenGL ES"); - return -1; - } - - /* Initialize OpenGL ES library, ignore EGL version */ - initstatus = eglInitialize(gfdata->egldisplay, NULL, NULL); - if (initstatus != EGL_TRUE) { - SDL_SetError("GF: Can't init OpenGL ES library"); - return -1; - } - } - - /* Increment GL ES reference count usage */ - gfdata->egl_refcount++; -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ - } - - /* Enable mouse event collecting */ - hiddi_enable_mouse(); - - /* By default last created window got a input focus */ - SDL_SetKeyboardFocus(0, window); - SDL_SetMouseFocus(0, window); - - /* Window has been successfully created */ - return 0; -} - -int -qnxgf_createwindowfrom(_THIS, SDL_Window * window, const void *data) -{ - /* Failed to create window from another window */ - return -1; -} - -void -qnxgf_setwindowtitle(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon) -{ -} - -void -qnxgf_setwindowposition(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_setwindowsize(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_showwindow(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_hidewindow(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_raisewindow(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_maximizewindow(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_minimizewindow(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_restorewindow(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_setwindowgrab(_THIS, SDL_Window * window) -{ -} - -void -qnxgf_destroywindow(_THIS, SDL_Window * window) -{ - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - - if (wdata != NULL) { -#if defined(SDL_VIDEO_OPENGL_ES) - /* Destroy OpenGL ES surface if it was created */ - if (wdata->gles_surface != EGL_NO_SURFACE) { - eglDestroySurface(gfdata->egldisplay, wdata->gles_surface); - } - - /* Free any 3D target if it was created before */ - if (wdata->target_created == SDL_TRUE) { - gf_3d_target_free(wdata->target); - wdata->target_created == SDL_FALSE; - } - - gfdata->egl_refcount--; - if (gfdata->egl_refcount == 0) { - /* Terminate connection to OpenGL ES */ - if (gfdata->egldisplay != EGL_NO_DISPLAY) { - eglTerminate(gfdata->egldisplay); - gfdata->egldisplay = EGL_NO_DISPLAY; - } - } -#endif /* SDL_VIDEO_OPENGL_ES */ - } -} - -/*****************************************************************************/ -/* SDL Window Manager function */ -/*****************************************************************************/ -SDL_bool -qnxgf_getwindowwminfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info) -{ - /* QNX GF do not operates at window level, this means we are have no */ - /* Window Manager available, no specific data in SDL_SysWMinfo too */ - - if (info->version.major <= SDL_MAJOR_VERSION) { - return SDL_TRUE; - } else { - SDL_SetError("Application not compiled with SDL %d.%d\n", - SDL_MAJOR_VERSION, SDL_MINOR_VERSION); - return SDL_FALSE; - } - - /* Failed to get window manager information */ - return SDL_FALSE; -} - -/*****************************************************************************/ -/* SDL OpenGL/OpenGL ES functions */ -/*****************************************************************************/ -int -qnxgf_gl_loadlibrary(_THIS, const char *path) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - /* Check if OpenGL ES library is specified for GF driver */ - if (path == NULL) { - path = SDL_getenv("SDL_OPENGL_LIBRARY"); - if (path == NULL) { - path = SDL_getenv("SDL_OPENGLES_LIBRARY"); - } - } - - /* Check if default library loading requested */ - if (path == NULL) { - /* Already linked with GF library which provides egl* subset of */ - /* functions, use Common profile of OpenGL ES library by default */ - path = "/usr/lib/libGLES_CM.so.1"; - } - - /* Load dynamic library */ - _this->gl_config.dll_handle = SDL_LoadObject(path); - if (!_this->gl_config.dll_handle) { - /* Failed to load new GL ES library */ - SDL_SetError("GF: Failed to locate OpenGL ES library"); - return -1; - } - - /* Store OpenGL ES library path and name */ - SDL_strlcpy(_this->gl_config.driver_path, path, - SDL_arraysize(_this->gl_config.driver_path)); - - /* New OpenGL ES library is loaded */ - return 0; -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -void * -qnxgf_gl_getprocaddres(_THIS, const char *proc) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - void *function_address; - - /* Try to get function address through the egl interface */ - function_address = eglGetProcAddress(proc); - if (function_address != NULL) { - return function_address; - } - - /* Then try to get function in the OpenGL ES library */ - if (_this->gl_config.dll_handle) { - function_address = - SDL_LoadFunction(_this->gl_config.dll_handle, proc); - if (function_address != NULL) { - return function_address; - } - } - - /* Add emulated OpenGL ES 1.1 functions */ - if (SDL_strcmp(proc, "glTexParameteri") == 0) { - return glTexParameteri; - } - if (SDL_strcmp(proc, "glTexParameteriv") == 0) { - return glTexParameteriv; - } - if (SDL_strcmp(proc, "glColor4ub") == 0) { - return glColor4ub; - } - - /* Failed to get GL ES function address pointer */ - SDL_SetError("GF: Cannot locate OpenGL ES function name"); - return NULL; -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return NULL; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -void -qnxgf_gl_unloadlibrary(_THIS) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - /* Unload OpenGL ES library */ - if (_this->gl_config.dll_handle) { - SDL_UnloadObject(_this->gl_config.dll_handle); - _this->gl_config.dll_handle = NULL; - } -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -SDL_GLContext -qnxgf_gl_createcontext(_THIS, SDL_Window * window) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - SDL_DisplayData *didata = - (SDL_DisplayData *) window->display->driverdata; - EGLBoolean status; - int32_t gfstatus; - EGLint configs; - uint32_t surfaces; - uint32_t attr_pos; - EGLint attr_value; - EGLint cit; - - /* Choose buffeingr scheme */ - if (!_this->gl_config.double_buffer) { - surfaces = 1; - } else { - surfaces = 2; - } - - /* If driver has no support of video memory allocation, then */ - /* disable double buffering, use single buffer present copy */ - if ((didata->caps & SDL_GF_VIDEOMEMORY) != SDL_GF_VIDEOMEMORY) { - surfaces = 1; - } - - /* Free main surface */ - if (didata->surface[0] != NULL) { - gf_surface_free(didata->surface[0]); - didata->surface[0] = NULL; - } - - /* Free back surface */ - if (didata->surface[1] != NULL) { - gf_surface_free(didata->surface[1]); - didata->surface[1] = NULL; - } - - /* Free second back surface */ - if (didata->surface[2] != NULL) { - gf_surface_free(didata->surface[2]); - didata->surface[2] = NULL; - } - - /* Detach layer before switch to new graphics mode */ - if (didata->layer_attached == SDL_TRUE) { - /* Disable layer if hardware supports this */ - gf_layer_disable(didata->layer); - - /* Detach from layer, free it for others */ - gf_layer_detach(didata->layer); - - /* Mark it as detached */ - didata->layer_attached = SDL_FALSE; - } - - /* Attach to main display layer */ - gfstatus = - gf_layer_attach(&didata->layer, didata->display, - didata->display_info.main_layer_index, 0); - if (gfstatus != GF_ERR_OK) { - SDL_SetError("GF: Couldn't attach to main layer, it could be busy"); - - /* Failed to attach to main displayable layer */ - return NULL; - } - - /* Mark main display layer is attached */ - didata->layer_attached = SDL_TRUE; - - /* Set layer source and destination viewport */ - gf_layer_set_src_viewport(didata->layer, 0, 0, didata->current_mode.w - 1, - didata->current_mode.h - 1); - gf_layer_set_dst_viewport(didata->layer, 0, 0, didata->current_mode.w - 1, - didata->current_mode.h - 1); - - /* Create main visible on display surface */ - gfstatus = - gf_surface_create_layer(&didata->surface[0], &didata->layer, 1, 0, - didata->current_mode.w, - didata->current_mode.h, - qnxgf_sdl_to_gf_pixelformat(didata-> - current_mode. - format), NULL, - GF_SURFACE_CREATE_2D_ACCESSIBLE | - GF_SURFACE_CREATE_3D_ACCESSIBLE | - GF_SURFACE_CREATE_SHAREABLE); - if (gfstatus != GF_ERR_OK) { - gf_layer_disable(didata->layer); - gf_layer_detach(didata->layer); - didata->layer_attached = SDL_FALSE; - SDL_SetError("GF: Can't create main layer surface at glctx (%d)\n", - gfstatus); - return NULL; - } - - /* Set just created surface as main visible on the layer */ -// gf_layer_set_surfaces(didata->layer, &didata->surface[0], 1); - - if (surfaces > 1) { - /* Create back display surface */ - gfstatus = - gf_surface_create_layer(&didata->surface[1], &didata->layer, 1, 0, - didata->current_mode.w, - didata->current_mode.h, - qnxgf_sdl_to_gf_pixelformat(didata-> - current_mode. - format), NULL, - GF_SURFACE_CREATE_2D_ACCESSIBLE | - GF_SURFACE_CREATE_3D_ACCESSIBLE | - GF_SURFACE_CREATE_SHAREABLE); - if (gfstatus != GF_ERR_OK) { - gf_surface_free(didata->surface[0]); - gf_layer_disable(didata->layer); - gf_layer_detach(didata->layer); - didata->layer_attached = SDL_FALSE; - SDL_SetError - ("GF: Can't create main layer surface at glctx (%d)\n", - gfstatus); - return NULL; - } - } - - /* Update layer parameters */ - gfstatus = gf_layer_update(didata->layer, GF_LAYER_UPDATE_NO_WAIT_IDLE); - if (gfstatus != GF_ERR_OK) { - /* Free main and back surfaces */ - gf_surface_free(didata->surface[1]); - didata->surface[1] = NULL; - gf_surface_free(didata->surface[0]); - didata->surface[0] = NULL; - - /* Detach layer */ - gf_layer_disable(didata->layer); - gf_layer_detach(didata->layer); - didata->layer_attached = SDL_FALSE; - SDL_SetError("GF: Can't update layer parameters\n"); - return NULL; - } - - /* Enable layer in case if hardware supports layer enable/disable */ - gf_layer_enable(didata->layer); - - /* Prepare attributes list to pass them to OpenGL ES */ - attr_pos = 0; - wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; - wdata->gles_attributes[attr_pos++] = - qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); - wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.red_size; - wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.green_size; - wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.blue_size; - wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; - if (_this->gl_config.alpha_size) { - wdata->gles_attributes[attr_pos++] = _this->gl_config.alpha_size; - } else { - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; - if (_this->gl_config.depth_size) { - wdata->gles_attributes[attr_pos++] = _this->gl_config.depth_size; - } else { - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - if (_this->gl_config.buffer_size) { - wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.buffer_size; - } - if (_this->gl_config.stencil_size) { - wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; - wdata->gles_attributes[attr_pos++] = _this->gl_config.stencil_size; - } - - /* Set number of samples in multisampling */ - if (_this->gl_config.multisamplesamples) { - wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; - wdata->gles_attributes[attr_pos++] = - _this->gl_config.multisamplesamples; - } - - /* Multisample buffers, OpenGL ES 1.0 spec defines 0 or 1 buffer */ - if (_this->gl_config.multisamplebuffers) { - wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; - wdata->gles_attributes[attr_pos++] = - _this->gl_config.multisamplebuffers; - } - - /* Finish attributes list */ - wdata->gles_attributes[attr_pos] = EGL_NONE; - - /* Request first suitable framebuffer configuration */ - status = eglChooseConfig(gfdata->egldisplay, wdata->gles_attributes, - wdata->gles_configs, SDL_VIDEO_GF_OPENGLES_CONFS, - &configs); - if (status != EGL_TRUE) { - SDL_SetError("GF: Can't find closest configuration for OpenGL ES"); - return NULL; - } - - /* Check if nothing has been found, try "don't care" settings */ - if (configs == 0) { - int32_t it; - int32_t jt; - static const GLint depthbits[4] = { 32, 24, 16, EGL_DONT_CARE }; - - for (it = 0; it < 4; it++) { - for (jt = 16; jt >= 0; jt--) { - /* Don't care about color buffer bits, use what exist */ - /* Replace previous data set with EGL_DONT_CARE */ - attr_pos = 0; - wdata->gles_attributes[attr_pos++] = EGL_NATIVE_VISUAL_ID; - wdata->gles_attributes[attr_pos++] = - qnxgf_sdl_to_gf_pixelformat(didata->current_mode.format); - wdata->gles_attributes[attr_pos++] = EGL_RED_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_GREEN_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_BLUE_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_ALPHA_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_BUFFER_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - - /* Try to find requested or smallest depth */ - if (_this->gl_config.depth_size) { - wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; - wdata->gles_attributes[attr_pos++] = depthbits[it]; - } else { - wdata->gles_attributes[attr_pos++] = EGL_DEPTH_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - } - - if (_this->gl_config.stencil_size) { - wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; - wdata->gles_attributes[attr_pos++] = jt; - } else { - wdata->gles_attributes[attr_pos++] = EGL_STENCIL_SIZE; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - - /* exit from stencil loop */ - jt = 0; - } - - /* Don't care about antialiasing */ - wdata->gles_attributes[attr_pos++] = EGL_SAMPLES; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos++] = EGL_SAMPLE_BUFFERS; - wdata->gles_attributes[attr_pos++] = EGL_DONT_CARE; - wdata->gles_attributes[attr_pos] = EGL_NONE; - - /* Request first suitable framebuffer configuration */ - status = - eglChooseConfig(gfdata->egldisplay, - wdata->gles_attributes, - wdata->gles_configs, - SDL_VIDEO_GF_OPENGLES_CONFS, &configs); - if (status != EGL_TRUE) { - SDL_SetError - ("GF: Can't find closest configuration for OpenGL ES"); - return NULL; - } - if (configs != 0) { - break; - } - } - if (configs != 0) { - break; - } - } - - /* No available configs */ - if (configs == 0) { - SDL_SetError("GF: Can't find any configuration for OpenGL ES"); - return NULL; - } - } - - /* Initialize config index */ - wdata->gles_config = 0; - - /* Now check each configuration to find out the best */ - for (cit = 0; cit < configs; cit++) { - uint32_t stencil_found; - uint32_t depth_found; - EGLint cur_depth; - EGLint cur_stencil; - - stencil_found = 0; - depth_found = 0; - - if (_this->gl_config.stencil_size) { - status = - eglGetConfigAttrib(gfdata->egldisplay, - wdata->gles_configs[cit], EGL_STENCIL_SIZE, - &cur_stencil); - if (status == EGL_TRUE) { - if (attr_value != 0) { - stencil_found = 1; - } - } - } else { - stencil_found = 1; - } - - if (_this->gl_config.depth_size) { - status = - eglGetConfigAttrib(gfdata->egldisplay, - wdata->gles_configs[cit], EGL_DEPTH_SIZE, - &cur_depth); - if (status == EGL_TRUE) { - if (attr_value != 0) { - depth_found = 1; - } - } - } else { - depth_found = 1; - } - - /* Exit from loop if found appropriate configuration */ - if ((depth_found != 0) && (stencil_found != 0)) { - /* Store last satisfied configuration id */ - wdata->gles_config = cit; - - if (cur_depth==_this->gl_config.depth_size) - { - /* Exact match on depth bits */ - if (!_this->gl_config.stencil_size) - { - /* Stencil is not required */ - break; - } - else - { - if (cur_stencil==_this->gl_config.stencil_size) - { - /* Exact match on stencil bits */ - break; - } - } - } - } - } - - /* If best could not be found, use first or last satisfied */ - if ((cit == configs) && (wdata->gles_config==0)) { - cit = 0; - wdata->gles_config = cit; - } - - /* Create OpenGL ES context */ - wdata->gles_context = - eglCreateContext(gfdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_NO_CONTEXT, NULL); - if (wdata->gles_context == EGL_NO_CONTEXT) { - SDL_SetError("GF: OpenGL ES context creation has been failed"); - return NULL; - } - - /* Free any 3D target if it was created before */ - if (wdata->target_created == SDL_TRUE) { - gf_3d_target_free(wdata->target); - wdata->target_created == SDL_FALSE; - } - - /* Create surface(s) target for OpenGL ES */ - gfstatus = - gf_3d_target_create(&wdata->target, didata->layer, - &didata->surface[0], surfaces, - didata->current_mode.w, didata->current_mode.h, - qnxgf_sdl_to_gf_pixelformat(didata->current_mode. - format)); - if (gfstatus != GF_ERR_OK) { - /* Destroy just created context */ - eglDestroyContext(gfdata->egldisplay, wdata->gles_context); - wdata->gles_context = EGL_NO_CONTEXT; - - /* Mark 3D target as unallocated */ - wdata->target_created = SDL_FALSE; - SDL_SetError("GF: OpenGL ES target could not be created"); - return NULL; - } else { - wdata->target_created = SDL_TRUE; - } - - /* Create target rendering surface on whole screen */ - wdata->gles_surface = - eglCreateWindowSurface(gfdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - wdata->target, NULL); - if (wdata->gles_surface == EGL_NO_SURFACE) { - /* Destroy 3d target */ - gf_3d_target_free(wdata->target); - wdata->target_created = SDL_FALSE; - - /* Destroy OpenGL ES context */ - eglDestroyContext(gfdata->egldisplay, wdata->gles_context); - wdata->gles_context = EGL_NO_CONTEXT; - - SDL_SetError("GF: OpenGL ES surface could not be created"); - return NULL; - } - - /* Make just created context current */ - status = - eglMakeCurrent(gfdata->egldisplay, wdata->gles_surface, - wdata->gles_surface, wdata->gles_context); - if (status != EGL_TRUE) { - /* Destroy OpenGL ES surface */ - eglDestroySurface(gfdata->egldisplay, wdata->gles_surface); - - /* Destroy 3d target */ - gf_3d_target_free(wdata->target); - wdata->target_created = SDL_FALSE; - - /* Destroy OpenGL ES context */ - eglDestroyContext(gfdata->egldisplay, wdata->gles_context); - wdata->gles_context = EGL_NO_CONTEXT; - - /* Failed to set current GL ES context */ - SDL_SetError("GF: Can't set OpenGL ES context on creation"); - return NULL; - } - - /* Setup into SDL internals state of OpenGL ES: */ - /* it is accelerated or not */ - if ((didata->caps & SDL_GF_ACCELERATED_3D) == SDL_GF_ACCELERATED_3D) { - _this->gl_config.accelerated = 1; - } else { - _this->gl_config.accelerated = 0; - } - - /* Always clear stereo enable, since OpenGL ES do not supports stereo */ - _this->gl_config.stereo = 0; - - /* Get back samples and samplebuffers configurations. Rest framebuffer */ - /* parameters could be obtained through the OpenGL ES API */ - status = - eglGetConfigAttrib(gfdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_SAMPLES, &attr_value); - if (status == EGL_TRUE) { - _this->gl_config.multisamplesamples = attr_value; - } - status = - eglGetConfigAttrib(gfdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_SAMPLE_BUFFERS, &attr_value); - if (status == EGL_TRUE) { - _this->gl_config.multisamplebuffers = attr_value; - } - - /* Get back stencil and depth buffer sizes */ - status = - eglGetConfigAttrib(gfdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_DEPTH_SIZE, &attr_value); - if (status == EGL_TRUE) { - _this->gl_config.depth_size = attr_value; - } - status = - eglGetConfigAttrib(gfdata->egldisplay, - wdata->gles_configs[wdata->gles_config], - EGL_STENCIL_SIZE, &attr_value); - if (status == EGL_TRUE) { - _this->gl_config.stencil_size = attr_value; - } - - /* Restore cursor if it was visible */ - if (didata->cursor_visible == SDL_TRUE) { - gf_cursor_set(didata->display, 0, &didata->cursor); - gf_cursor_enable(didata->display, 0); - } - - /* GL ES context was successfully created */ - return wdata->gles_context; -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return NULL; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -int -qnxgf_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - SDL_WindowData *wdata; - EGLBoolean status; - - if ((window == NULL) && (context == NULL)) { - status = - eglMakeCurrent(gfdata->egldisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, - EGL_NO_CONTEXT); - if (status != EGL_TRUE) { - /* Failed to set current GL ES context */ - SDL_SetError("GF: Can't set OpenGL ES context"); - return -1; - } - } else { - wdata = (SDL_WindowData *) window->driverdata; - status = - eglMakeCurrent(gfdata->egldisplay, wdata->gles_surface, - wdata->gles_surface, wdata->gles_context); - if (status != EGL_TRUE) { - /* Failed to set current GL ES context */ - SDL_SetError("GF: Can't set OpenGL ES context"); - return -1; - } - } - - return 0; -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -int -qnxgf_gl_setswapinterval(_THIS, int interval) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - EGLBoolean status; - - /* Check if OpenGL ES connection has been initialized */ - if (gfdata->egldisplay != EGL_NO_DISPLAY) { - /* Set swap OpenGL ES interval */ - status = eglSwapInterval(gfdata->egldisplay, interval); - if (status == EGL_TRUE) { - /* Return success to upper level */ - gfdata->swapinterval = interval; - return 0; - } - } - - /* Failed to set swap interval */ - SDL_SetError("GF: Cannot set swap interval"); - return -1; -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -int -qnxgf_gl_getswapinterval(_THIS) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - - /* Return default swap interval value */ - return gfdata->swapinterval; -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return -1; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -void -qnxgf_gl_swapwindow(_THIS, SDL_Window * window) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - SDL_WindowData *wdata = (SDL_WindowData *) window->driverdata; - - /* Finish all drawings */ - glFinish(); - - /* Swap buffers */ - eglSwapBuffers(gfdata->egldisplay, wdata->gles_surface); -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -void -qnxgf_gl_deletecontext(_THIS, SDL_GLContext context) -{ -#if defined(SDL_VIDEO_OPENGL_ES) - SDL_VideoData *gfdata = (SDL_VideoData *) _this->driverdata; - EGLBoolean status; - - /* Check if OpenGL ES connection has been initialized */ - if (gfdata->egldisplay != EGL_NO_DISPLAY) { - if (context != EGL_NO_CONTEXT) { - status = eglDestroyContext(gfdata->egldisplay, context); - if (status != EGL_TRUE) { - /* Error during OpenGL ES context destroying */ - SDL_SetError("GF: OpenGL ES context destroy error"); - return; - } - } - } - - return; -#else - SDL_SetError("GF: OpenGL ES support is not compiled in"); - return; -#endif /* SDL_VIDEO_OPENGL_ES */ -} - -/*****************************************************************************/ -/* SDL Event handling function */ -/*****************************************************************************/ -void -qnxgf_pumpevents(_THIS) -{ -} - -/*****************************************************************************/ -/* SDL screen saver related functions */ -/*****************************************************************************/ -void -qnxgf_suspendscreensaver(_THIS) -{ - /* There is no screensaver in pure console, it may exist when running */ - /* GF under Photon, but I do not know, how to disable screensaver */ -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/qnxgf/SDL_qnxgf.h b/project/jni/sdl-1.3/src/video/qnxgf/SDL_qnxgf.h deleted file mode 100644 index 99a2ff917..000000000 --- a/project/jni/sdl-1.3/src/video/qnxgf/SDL_qnxgf.h +++ /dev/null @@ -1,163 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - QNX Graphics Framework SDL driver - Copyright (C) 2009 Mike Gorchak - (mike@malva.ua, lestat@i.com.ua) -*/ - -#ifndef __SDL_QNXGF_H__ -#define __SDL_QNXGF_H__ - -#include "../SDL_sysvideo.h" - -#include -#include - -#if defined(SDL_VIDEO_OPENGL_ES) -#include -#endif /* SDL_VIDEO_OPENGL_ES */ - -typedef struct SDL_VideoData -{ - gf_dev_t gfdev; /* GF device handle */ - gf_dev_info_t gfdev_info; /* GF device information */ - SDL_bool gfinitialized; /* GF device initialization status */ -#if defined(SDL_VIDEO_OPENGL_ES) - EGLDisplay egldisplay; /* OpenGL ES display connection */ - uint32_t egl_refcount; /* OpenGL ES reference count */ - uint32_t swapinterval; /* OpenGL ES default swap interval */ -#endif /* SDL_VIDEO_OPENGL_ES */ -} SDL_VideoData; - -#define SDL_VIDEO_GF_DEVICENAME_MAX 257 -#define SDL_VIDEO_GF_MAX_CURSOR_SIZE 128 - -typedef struct SDL_DisplayData -{ - gf_display_info_t display_info; /* GF display information */ - gf_display_t display; /* GF display handle */ - uint32_t custom_refresh; /* Custom refresh rate for all modes */ - SDL_DisplayMode current_mode; /* Current video mode */ - uint8_t description[SDL_VIDEO_GF_DEVICENAME_MAX]; - /* Device description */ - uint32_t caps; /* Device capabilities */ - SDL_bool layer_attached; /* Layer attach status */ - gf_layer_t layer; /* Graphics layer to which attached */ - gf_surface_t surface[3]; /* Visible surface on the display */ - SDL_bool cursor_visible; /* SDL_TRUE if cursor visible */ - gf_cursor_t cursor; /* Cursor shape which was set last */ -} SDL_DisplayData; - -/* Maximum amount of OpenGL ES framebuffer configurations */ -#define SDL_VIDEO_GF_OPENGLES_CONFS 32 - -typedef struct SDL_WindowData -{ - SDL_bool uses_gles; /* true if window support OpenGL ES */ -#if defined(SDL_VIDEO_OPENGL_ES) - gf_3d_target_t target; /* OpenGL ES window target */ - SDL_bool target_created; /* GF 3D target is created if true */ - EGLConfig gles_configs[SDL_VIDEO_GF_OPENGLES_CONFS]; - /* OpenGL ES framebuffer confs */ - EGLint gles_config; /* Config index in the array of cfgs */ - EGLContext gles_context; /* OpenGL ES context */ - EGLint gles_attributes[256]; /* OpenGL ES attributes for context */ - EGLSurface gles_surface; /* OpenGL ES target rendering surface */ -#endif /* SDL_VIDEO_OPENGL_ES */ -} SDL_WindowData; - -typedef struct SDL_GLDriverData -{ -#if defined(SDL_VIDEO_OPENGL_ES) -#endif /* SDL_VIDEO_OPENGL_ES */ -} SDL_GLDriverData; - -/****************************************************************************/ -/* Low level GF graphics driver capabilities */ -/****************************************************************************/ -typedef struct GF_DeviceCaps -{ - uint8_t *name; - uint32_t caps; -} GF_DeviceCaps; - -#define SDL_GF_UNACCELERATED 0x00000000 /* driver is unaccelerated */ -#define SDL_GF_ACCELERATED 0x00000001 /* driver is accelerated */ -#define SDL_GF_NOLOWRESOLUTION 0x00000000 /* no modes below 640x480 */ -#define SDL_GF_LOWRESOLUTION 0x00000002 /* support modes <640x480 */ -#define SDL_GF_UNACCELERATED_3D 0x00000000 /* software OpenGL ES */ -#define SDL_GF_ACCELERATED_3D 0x00000004 /* hardware acc. OpenGL ES */ -#define SDL_GF_NOVIDEOMEMORY 0x00000000 /* no video memory alloc. */ -#define SDL_GF_VIDEOMEMORY 0x00000008 /* has video memory alloc. */ - -/****************************************************************************/ -/* SDL_VideoDevice functions declaration */ -/****************************************************************************/ - -/* Display and window functions */ -int qnxgf_videoinit(_THIS); -void qnxgf_videoquit(_THIS); -void qnxgf_getdisplaymodes(_THIS); -int qnxgf_setdisplaymode(_THIS, SDL_DisplayMode * mode); -int qnxgf_setdisplaypalette(_THIS, SDL_Palette * palette); -int qnxgf_getdisplaypalette(_THIS, SDL_Palette * palette); -int qnxgf_setdisplaygammaramp(_THIS, Uint16 * ramp); -int qnxgf_getdisplaygammaramp(_THIS, Uint16 * ramp); -int qnxgf_createwindow(_THIS, SDL_Window * window); -int qnxgf_createwindowfrom(_THIS, SDL_Window * window, const void *data); -void qnxgf_setwindowtitle(_THIS, SDL_Window * window); -void qnxgf_setwindowicon(_THIS, SDL_Window * window, SDL_Surface * icon); -void qnxgf_setwindowposition(_THIS, SDL_Window * window); -void qnxgf_setwindowsize(_THIS, SDL_Window * window); -void qnxgf_showwindow(_THIS, SDL_Window * window); -void qnxgf_hidewindow(_THIS, SDL_Window * window); -void qnxgf_raisewindow(_THIS, SDL_Window * window); -void qnxgf_maximizewindow(_THIS, SDL_Window * window); -void qnxgf_minimizewindow(_THIS, SDL_Window * window); -void qnxgf_restorewindow(_THIS, SDL_Window * window); -void qnxgf_setwindowgrab(_THIS, SDL_Window * window); -void qnxgf_destroywindow(_THIS, SDL_Window * window); - -/* Window manager function */ -SDL_bool qnxgf_getwindowwminfo(_THIS, SDL_Window * window, - struct SDL_SysWMinfo *info); - -/* OpenGL/OpenGL ES functions */ -int qnxgf_gl_loadlibrary(_THIS, const char *path); -void *qnxgf_gl_getprocaddres(_THIS, const char *proc); -void qnxgf_gl_unloadlibrary(_THIS); -SDL_GLContext qnxgf_gl_createcontext(_THIS, SDL_Window * window); -int qnxgf_gl_makecurrent(_THIS, SDL_Window * window, SDL_GLContext context); -int qnxgf_gl_setswapinterval(_THIS, int interval); -int qnxgf_gl_getswapinterval(_THIS); -void qnxgf_gl_swapwindow(_THIS, SDL_Window * window); -void qnxgf_gl_deletecontext(_THIS, SDL_GLContext context); - -/* Event handling function */ -void qnxgf_pumpevents(_THIS); - -/* Screen saver related function */ -void qnxgf_suspendscreensaver(_THIS); - -#endif /* __SDL_QNXGF_H__ */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosASM.S b/project/jni/sdl-1.3/src/video/riscos/SDL_riscosASM.S deleted file mode 100644 index 12b9e5e13..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosASM.S +++ /dev/null @@ -1,116 +0,0 @@ -; -; SDL - Simple DirectMedia Layer -; Copyright (C) 1997-2009 Sam Lantinga -; -; This library is free software; you can redistribute it and/or -; modify it under the terms of the GNU Library General Public -; License as published by the Free Software Foundation; either -; version 2 of the License, or (at your option) any later version. -; -; This library is distributed in the hope that it will be useful, -; but WITHOUT ANY WARRANTY; without even the implied warranty of -; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -; Library General Public License for more details. -; -; You should have received a copy of the GNU Library General Public -; License along with this library; if not, write to the Free -; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -; -; Sam Lantinga -; slouken@libsdl.org -; -; Assembler routines for RISC OS display -; - - AREA |C$$CODE| - - EXPORT |RISCOS_Put32| - -; Display 32bpp to 32bpp, 1:1 -; -; Code provided by Adrain Lees -; -; entry a1 -> destination -; a2 = dest width in pixels -; a3 = dest line length in bytes -; a4 = dest height in scanlines -; arg5 -> source -; arg6 = byte offset from end of source line to start of next - -Arg5 * 10*4 -Arg6 * Arg5+4 - -RISCOS_Put32 ROUT - STMFD sp!,{a2,v1-v6,sl,fp,lr} - LDR ip,[sp,#Arg5] - MOV lr,a1 - B ucp64lp - -00 ;tail strip of 1-15 pixels - - LDR v1,[ip],#4 -01 SUBS a2,a2,#1 - STR v1,[lr],#4 - LDRHI v1,[ip],#4 - BHI %01 - B %02 - -ucp64end ADDS a2,a2,#16 - BNE %00 - -02 SUBS a4,a4,#1 ;height-- - LDRHI v1,[sp,#Arg6] - LDRHI a2,[sp] ;reload width - BLS %03 - - ;move to start of next scanline - - ADD lr,a1,a3 - ADD a1,a1,a3 - ADD ip,ip,v1 - -ucp64lp SUBS a2,a2,#16 - BLO ucp64end - - PLD [ip,#64] - - LDR v1,[ip],#4 - LDR v2,[ip],#4 - LDR v3,[ip],#4 - LDR v4,[ip],#4 - LDR v5,[ip],#4 - LDR v6,[ip],#4 - LDR sl,[ip],#4 - LDR fp,[ip],#4 - STR v1,[lr],#4 - STR v2,[lr],#4 - STR v3,[lr],#4 - STR v4,[lr],#4 - STR v5,[lr],#4 - STR v6,[lr],#4 - STR sl,[lr],#4 - STR fp,[lr],#4 - - PLD [ip,#64] - - LDR v1,[ip],#4 - LDR v2,[ip],#4 - LDR v3,[ip],#4 - LDR v4,[ip],#4 - LDR v5,[ip],#4 - LDR v6,[ip],#4 - LDR sl,[ip],#4 - LDR fp,[ip],#4 - STR v1,[lr],#4 - STR v2,[lr],#4 - STR v3,[lr],#4 - STR v4,[lr],#4 - STR v5,[lr],#4 - STR v6,[lr],#4 - STR sl,[lr],#4 - STR fp,[lr],#4 - - B ucp64lp - -03 LDMFD sp!,{a2,v1-v6,sl,fp,pc} - diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosFullScreenVideo.c b/project/jni/sdl-1.3/src/video/riscos/SDL_riscosFullScreenVideo.c deleted file mode 100644 index 687321470..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosFullScreenVideo.c +++ /dev/null @@ -1,802 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability - 27 March 2003 - - Implements RISC OS full screen display. -*/ - -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" - -#include "SDL_riscostask.h" -#include "SDL_riscosvideo.h" -#include "SDL_riscosevents_c.h" -#include "SDL_riscosmouse_c.h" - -#include "kernel.h" -#include "swis.h" -#include "unixlib/os.h" -#include "unixlib/local.h" - -/* Private structures */ -typedef struct tagScreenModeBlock -{ - int flags; // mode selector flags, bit 0 = 1, bit 1-7 format specifier, 8-31 reserved - int x_pixels; - int y_pixels; - int pixel_depth; // 2^pixel_depth = bpp,i.e. 0 = 1, 1 = 2, 4 = 16, 5 = 32 - int frame_rate; // -1 use first match - int mode_vars[5]; // array of index, value pairs terminated by -1 -} SCREENMODEBLOCK; - - -/* Helper functions */ -void FULLSCREEN_SetDeviceMode(_THIS); -int FULLSCREEN_SetMode(int width, int height, int bpp); -void FULLSCREEN_SetupBanks(_THIS); - -/* SDL video device functions for fullscreen mode */ -static int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface * surface); -void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon); -extern int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info); - -/* UpdateRects variants */ -static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect * rects); -static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, - SDL_Rect * rects); -static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect * rects); -static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, - SDL_Rect * rects); -static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, - SDL_Rect * rects); -static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect * rects); - -/* Local helper functions */ -static int cmpmodes(const void *va, const void *vb); -static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h); -void FULLSCREEN_SetWriteBank(int bank); -void FULLSCREEN_SetDisplayBank(int bank); -static void FULLSCREEN_DisableEscape(); -static void FULLSCREEN_EnableEscape(); -void FULLSCREEN_BuildModeList(_THIS); - -/* Following variable is set up in riskosTask.c */ -extern int riscos_backbuffer; /* Create a back buffer in system memory for full screen mode */ - -/* Following is used to create a sprite back buffer */ -extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp); - -/* Fast assembler copy */ -extern void RISCOS_Put32(void *to, int pixels, int pitch, int rows, - void *from, int src_skip_bytes); - -SDL_Surface * -FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) -{ - _kernel_swi_regs regs; - Uint32 Rmask = 0; - Uint32 Gmask = 0; - Uint32 Bmask = 0; - int create_back_buffer = riscos_backbuffer; - - switch (bpp) { - case 8: - flags |= SDL_HWPALETTE; - break; - - case 15: - case 16: - Bmask = 0x00007c00; - Gmask = 0x000003e0; - Rmask = 0x0000001f; - break; - - case 32: - Bmask = 0x00ff0000; - Gmask = 0x0000ff00; - Rmask = 0x000000ff; - break; - - default: - SDL_SetError("Pixel depth not supported"); - return NULL; - break; - } - - if (FULLSCREEN_SetMode(width, height, bpp) == 0) { - SDL_SetError("Couldn't set requested mode"); - return (NULL); - } - -/* printf("Setting mode %dx%d\n", width, height); */ - - /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) { - RISCOS_RestoreWimpMode(); - SDL_SetError("Couldn't allocate new pixel format for requested mode"); - return (NULL); - } - - /* Set up the new mode framebuffer */ - current->w = width; - this->hidden->height = current->h = height; - - regs.r[0] = -1; /* -1 for current screen mode */ - - /* Get screen width in bytes */ - regs.r[1] = 6; // Screen Width in bytes - _kernel_swi(OS_ReadModeVariable, ®s, ®s); - - current->pitch = regs.r[2]; - - if (flags & SDL_DOUBLEBUF) { - regs.r[0] = 2; /* Screen area */ - _kernel_swi(OS_ReadDynamicArea, ®s, ®s); - - /* Reg 1 has amount of memory currently used for display */ - regs.r[0] = 2; /* Screen area */ - regs.r[1] = (current->pitch * height * 2) - regs.r[1]; - if (_kernel_swi(OS_ChangeDynamicArea, ®s, ®s) != NULL) { - /* Can't allocate enough screen memory for double buffer */ - flags &= ~SDL_DOUBLEBUF; - } - } - - current->flags = flags | SDL_FULLSCREEN | SDL_HWSURFACE | SDL_PREALLOC; - - - /* Need to set display banks here for double buffering */ - if (flags & SDL_DOUBLEBUF) { - FULLSCREEN_SetWriteBank(0); - FULLSCREEN_SetDisplayBank(1); - - create_back_buffer = 0; /* Don't need a back buffer for a double buffered display */ - } - - FULLSCREEN_SetupBanks(this); - - if (create_back_buffer) { - /* If not double buffered we may need to create a memory - ** back buffer to simulate processing on other OSes. - ** This is turned on by setting the enviromental variable - ** SDL$$BackBuffer >= 1 - */ - if (riscos_backbuffer == 3) - this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp); - else - this->hidden->bank[0] = SDL_malloc(height * current->pitch); - if (this->hidden->bank[0] == 0) { - RISCOS_RestoreWimpMode(); - SDL_SetError("Couldnt allocate memory for back buffer"); - return (NULL); - } - /* Surface updated in programs is now a software surface */ - current->flags &= ~SDL_HWSURFACE; - } - - /* Store address of allocated screen bank to be freed later */ - if (this->hidden->alloc_bank) - SDL_free(this->hidden->alloc_bank); - if (create_back_buffer) { - this->hidden->alloc_bank = this->hidden->bank[0]; - if (riscos_backbuffer == 3) { - this->hidden->bank[0] += 60; /* Start of sprite data */ - if (bpp == 8) - this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ - } - } else - this->hidden->alloc_bank = 0; - - // Clear both banks to black - SDL_memset(this->hidden->bank[0], 0, height * current->pitch); - SDL_memset(this->hidden->bank[1], 0, height * current->pitch); - - this->hidden->current_bank = 0; - current->pixels = this->hidden->bank[0]; - - /* Have to set the screen here, so SetDeviceMode will pick it up */ - this->screen = current; - - /* Reset device functions for the wimp */ - FULLSCREEN_SetDeviceMode(this); - -/* FULLSCREEN_DisableEscape(); */ - - /* We're done */ - return (current); -} - -/* Reset any device functions that have been changed because we have run in WIMP mode */ -void -FULLSCREEN_SetDeviceMode(_THIS) -{ - /* Update rects is different if we have a backbuffer */ - - if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0) { - switch (riscos_backbuffer) { - case 2: /* ARM code full word copy */ - switch (this->screen->format->BytesPerPixel) { - case 1: /* 8bpp modes */ - this->UpdateRects = FULLSCREEN_UpdateRects8bpp; - break; - case 2: /* 15/16bpp modes */ - this->UpdateRects = FULLSCREEN_UpdateRects16bpp; - break; - case 4: /* 32 bpp modes */ - this->UpdateRects = FULLSCREEN_UpdateRects32bpp; - break; - - default: /* Just default to the memcpy routine */ - this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy; - break; - } - break; - - case 3: /* Use OS sprite plot routine */ - this->UpdateRects = FULLSCREEN_UpdateRectsOS; - break; - - default: /* Old but safe memcpy */ - this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy; - break; - } - } else - this->UpdateRects = FULLSCREEN_UpdateRects; /* Default do nothing implementation */ - - this->SetColors = FULLSCREEN_SetColors; - - this->FlipHWSurface = FULLSCREEN_FlipHWSurface; - - this->SetCaption = FULLSCREEN_SetWMCaption; - this->SetIcon = NULL; - this->IconifyWindow = NULL; - - this->ShowWMCursor = RISCOS_ShowWMCursor; - this->WarpWMCursor = FULLSCREEN_WarpWMCursor; - - this->PumpEvents = FULLSCREEN_PumpEvents; -} - -/* Query for the list of available video modes */ -void -FULLSCREEN_BuildModeList(_THIS) -{ - _kernel_swi_regs regs; - char *enumInfo = NULL; - char *enum_ptr; - int *blockInfo; - int j; - int num_modes; - - /* Find out how much space we need */ - regs.r[0] = 2; /* Reason code */ - regs.r[2] = 0; /* Number of modes to skip */ - regs.r[6] = 0; /* pointer to block or 0 for count */ - regs.r[7] = 0; /* Size of block in bytes */ - _kernel_swi(OS_ScreenMode, ®s, ®s); - - num_modes = -regs.r[2]; - - /* Video memory should be in r[5] */ - this->info.video_mem = regs.r[5] / 1024; - - enumInfo = (unsigned char *) SDL_malloc(-regs.r[7]); - if (enumInfo == NULL) { - SDL_OutOfMemory(); - return; - } - /* Read mode information into block */ - regs.r[2] = 0; - regs.r[6] = (int) enumInfo; - regs.r[7] = -regs.r[7]; - _kernel_swi(OS_ScreenMode, ®s, ®s); - - enum_ptr = enumInfo; - - for (j = 0; j < num_modes; j++) { - blockInfo = (int *) enum_ptr; - if ((blockInfo[1] & 255) == 1) { /* We understand this format */ - switch (blockInfo[4]) { - case 3: /* 8 bits per pixel */ - FULLSCREEN_AddMode(this, 8, blockInfo[2], blockInfo[3]); - break; - case 4: /* 15 bits per pixel */ - FULLSCREEN_AddMode(this, 15, blockInfo[2], blockInfo[3]); - break; - case 5: /* 32 bits per pixel */ - FULLSCREEN_AddMode(this, 32, blockInfo[2], blockInfo[3]); - break; - } - } - - enum_ptr += blockInfo[0]; - } - - SDL_free(enumInfo); - - /* Sort the mode lists */ - for (j = 0; j < NUM_MODELISTS; ++j) { - if (SDL_nummodes[j] > 0) { - SDL_qsort(SDL_modelist[j], SDL_nummodes[j], - sizeof *SDL_modelist[j], cmpmodes); - } - } -} - -static int -FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface * surface) -{ - _kernel_swi_regs regs; - regs.r[0] = 19; - - FULLSCREEN_SetDisplayBank(this->hidden->current_bank); - this->hidden->current_bank ^= 1; - FULLSCREEN_SetWriteBank(this->hidden->current_bank); - surface->pixels = this->hidden->bank[this->hidden->current_bank]; - - /* Wait for Vsync */ - _kernel_swi(OS_Byte, ®s, ®s); - - return (0); -} - -/* Nothing to do if we are writing direct to hardware */ -static void -FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect * rects) -{ -} - -/* Safe but slower Memory copy from our allocated back buffer */ -static void -FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect * rects) -{ - int j; - char *to, *from; - int pitch = this->screen->pitch; - int row; - int xmult = this->screen->format->BytesPerPixel; - for (j = 0; j < numrects; j++) { - from = this->hidden->bank[0] + rects->x * xmult + rects->y * pitch; - to = this->hidden->bank[1] + rects->x * xmult + rects->y * pitch; - for (row = 0; row < rects->h; row++) { - SDL_memcpy(to, from, rects->w * xmult); - from += pitch; - to += pitch; - } - rects++; - } -} - -/* Use optimized assembler memory copy. Deliberately copies extra columns if - necessary to ensure the rectangle is word aligned. */ -static void -FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect * rects) -{ - int j; - char *to, *from; - int pitch = this->screen->pitch; - int width_bytes; - int src_skip_bytes; - - for (j = 0; j < numrects; j++) { - from = this->hidden->bank[0] + rects->x + rects->y * pitch; - to = this->hidden->bank[1] + rects->x + rects->y * pitch; - width_bytes = rects->w; - if ((int) from & 3) { - int extra = ((int) from & 3); - from -= extra; - to -= extra; - width_bytes += extra; - } - if (width_bytes & 3) - width_bytes += 4 - (width_bytes & 3); - src_skip_bytes = pitch - width_bytes; - - RISCOS_Put32(to, (width_bytes >> 2), pitch, (int) rects->h, from, - src_skip_bytes); - rects++; - } -} - -/* Use optimized assembler memory copy. Deliberately copies extra columns if - necessary to ensure the rectangle is word aligned. */ -static void -FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect * rects) -{ - int j; - char *to, *from; - int pitch = this->screen->pitch; - int width_bytes; - int src_skip_bytes; - - for (j = 0; j < numrects; j++) { - from = this->hidden->bank[0] + (rects->x << 1) + rects->y * pitch; - to = this->hidden->bank[1] + (rects->x << 1) + rects->y * pitch; - width_bytes = (((int) rects->w) << 1); - if ((int) from & 3) { - from -= 2; - to -= 2; - width_bytes += 2; - } - if (width_bytes & 3) - width_bytes += 2; - src_skip_bytes = pitch - width_bytes; - - RISCOS_Put32(to, (width_bytes >> 2), pitch, (int) rects->h, from, - src_skip_bytes); - rects++; - } -} - -/* Use optimized assembler memory copy. 32 bpp modes are always word aligned */ -static void -FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect * rects) -{ - int j; - char *to, *from; - int pitch = this->screen->pitch; - int width; - - for (j = 0; j < numrects; j++) { - from = this->hidden->bank[0] + (rects->x << 2) + rects->y * pitch; - to = this->hidden->bank[1] + (rects->x << 2) + rects->y * pitch; - width = (int) rects->w; - - RISCOS_Put32(to, width, pitch, (int) rects->h, from, - pitch - (width << 2)); - rects++; - } -} - -/* Use operating system sprite plots. Currently this is much slower than the - other variants however accelerated sprite plotting can be seen on the horizon - so this prepares for it. */ -static void -FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect * rects) -{ - _kernel_swi_regs regs; - _kernel_oserror *err; - int j; - int y; - - regs.r[0] = 28 + 512; - regs.r[1] = (unsigned int) this->hidden->alloc_bank; - regs.r[2] = (unsigned int) this->hidden->alloc_bank + 16; - regs.r[5] = 0; - - for (j = 0; j < numrects; j++) { - y = this->screen->h - rects->y; /* top of clipping region */ - _kernel_oswrch(24); /* Set graphics clip region */ - _kernel_oswrch((rects->x << this->hidden->xeig) & 0xFF); /* left */ - _kernel_oswrch(((rects->x << this->hidden->xeig) >> 8) & 0xFF); - _kernel_oswrch(((y - rects->h) << this->hidden->yeig) & 0xFF); /* bottom */ - _kernel_oswrch((((y - rects->h) << this->hidden->yeig) >> 8) & 0xFF); - _kernel_oswrch(((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF); /* right */ - _kernel_oswrch((((rects->x + rects->w - - 1) << this->hidden->xeig) >> 8) & 0xFF); - _kernel_oswrch(((y - 1) << this->hidden->yeig) & 0xFF); /* top */ - _kernel_oswrch((((y - 1) << this->hidden->yeig) >> 8) & 0xFF); - - regs.r[3] = 0; - regs.r[4] = 0; - - if ((err = _kernel_swi(OS_SpriteOp, ®s, ®s)) != 0) { - printf("OS_SpriteOp failed \n%s\n", err->errmess); - } - - rects++; - - /* Reset to full screen clipping */ - _kernel_oswrch(24); /* Set graphics clip region */ - _kernel_oswrch(0); /* left */ - _kernel_oswrch(0); - _kernel_oswrch(0); /* bottom */ - _kernel_oswrch(0); - _kernel_oswrch(((this->screen->w - 1) << this->hidden->xeig) & 0xFF); /* right */ - _kernel_oswrch((((this->screen->w - - 1) << this->hidden->xeig) >> 8) & 0xFF); - _kernel_oswrch(((this->screen->h - 1) << this->hidden->yeig) & 0xFF); /* top */ - _kernel_oswrch((((this->screen->h - - 1) << this->hidden->yeig) >> 8) & 0xFF); - } -} - - -int -FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) -{ - _kernel_swi_regs regs; - int palette[256]; - - regs.r[0] = -1; - regs.r[1] = -1; - regs.r[2] = (int) palette; - regs.r[3] = 1024; - regs.r[4] = 0; - _kernel_swi(ColourTrans_ReadPalette, ®s, ®s); - - while (ncolors--) { - palette[firstcolor] = - ((colors->b) << 24) | ((colors->g) << 16) | ((colors->r) << 8); - firstcolor++; - colors++; - } - - regs.r[0] = -1; - regs.r[1] = -1; - regs.r[2] = (int) palette; - regs.r[3] = 0; - regs.r[4] = 0; - _kernel_swi(ColourTrans_WritePalette, ®s, ®s); - - return (1); -} - - -static int -cmpmodes(const void *va, const void *vb) -{ - SDL_Rect *a = *(SDL_Rect **) va; - SDL_Rect *b = *(SDL_Rect **) vb; - if (a->w == b->w) - return b->h - a->h; - else - return b->w - a->w; -} - -static int -FULLSCREEN_AddMode(_THIS, int bpp, int w, int h) -{ - SDL_Rect *mode; - int i, index; - int next_mode; - - /* Check to see if we already have this mode */ - if (bpp < 8) { /* Not supported */ - return (0); - } - index = ((bpp + 7) / 8) - 1; - for (i = 0; i < SDL_nummodes[index]; ++i) { - mode = SDL_modelist[index][i]; - if ((mode->w == w) && (mode->h == h)) { - return (0); - } - } - - /* Set up the new video mode rectangle */ - mode = (SDL_Rect *) SDL_malloc(sizeof *mode); - if (mode == NULL) { - SDL_OutOfMemory(); - return (-1); - } - mode->x = 0; - mode->y = 0; - mode->w = w; - mode->h = h; - - /* Allocate the new list of modes, and fill in the new mode */ - next_mode = SDL_nummodes[index]; - SDL_modelist[index] = (SDL_Rect **) - SDL_realloc(SDL_modelist[index], - (1 + next_mode + 1) * sizeof(SDL_Rect *)); - if (SDL_modelist[index] == NULL) { - SDL_OutOfMemory(); - SDL_nummodes[index] = 0; - SDL_free(mode); - return (-1); - } - SDL_modelist[index][next_mode] = mode; - SDL_modelist[index][next_mode + 1] = NULL; - SDL_nummodes[index]++; - - return (0); -} - -void -FULLSCREEN_SetWriteBank(int bank) -{ - _kernel_swi_regs regs; - regs.r[0] = 112; - regs.r[1] = bank + 1; - _kernel_swi(OS_Byte, ®s, ®s); -} - -void -FULLSCREEN_SetDisplayBank(int bank) -{ - _kernel_swi_regs regs; - regs.r[0] = 113; - regs.r[1] = bank + 1; - _kernel_swi(OS_Byte, ®s, ®s); -} - - -/** Disable special escape key processing */ -static void -FULLSCREEN_DisableEscape() -{ - _kernel_swi_regs regs; - regs.r[0] = 229; - regs.r[1] = 1; - regs.r[2] = 0; - _kernel_swi(OS_Byte, ®s, ®s); - -} - -/** Enable special escape key processing */ -static void -FULLSCREEN_EnableEscape() -{ - _kernel_swi_regs regs; - regs.r[0] = 229; - regs.r[1] = 0; - regs.r[2] = 0; - _kernel_swi(OS_Byte, ®s, ®s); - -} - -/** Store caption in case this is called before we create a window */ -void -FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon) -{ - SDL_strlcpy(this->hidden->title, title, - SDL_arraysize(this->hidden->title)); -} - -/* Set screen mode -* -* Returns 1 if mode is set ok, otherwise 0 -*/ - -int -FULLSCREEN_SetMode(int width, int height, int bpp) -{ - SCREENMODEBLOCK smb; - _kernel_swi_regs regs; - - smb.flags = 1; - smb.x_pixels = width; - smb.y_pixels = height; - smb.mode_vars[0] = -1; - - switch (bpp) { - case 8: - smb.pixel_depth = 3; - /* Note: Need to set ModeFlags to 128 and NColour variables to 255 get full 8 bit palette */ - smb.mode_vars[0] = 0; - smb.mode_vars[1] = 128; /* Mode flags */ - smb.mode_vars[2] = 3; - smb.mode_vars[3] = 255; /* NColour (number of colours -1) */ - smb.mode_vars[4] = -1; /* End of list */ - break; - - case 15: - case 16: - smb.pixel_depth = 4; - break; - - case 32: - smb.pixel_depth = 5; - break; - - default: - SDL_SetError("Pixel depth not supported"); - return 0; - break; - } - - smb.frame_rate = -1; - - regs.r[0] = 0; - regs.r[1] = (int) &smb; - - if (_kernel_swi(OS_ScreenMode, ®s, ®s) != 0) { - SDL_SetError("Couldn't set requested mode"); - return 0; - } - - /* Turn cursor off */ - _kernel_oswrch(23); - _kernel_oswrch(1); - _kernel_oswrch(0); - _kernel_oswrch(0); - _kernel_oswrch(0); - _kernel_oswrch(0); - _kernel_oswrch(0); - _kernel_oswrch(0); - _kernel_oswrch(0); - _kernel_oswrch(0); - _kernel_oswrch(0); - - return 1; -} - -/* Get Start addresses for the screen banks */ -void -FULLSCREEN_SetupBanks(_THIS) -{ - _kernel_swi_regs regs; - int block[5]; - block[0] = 148; /* Write screen start */ - block[1] = 149; /* Display screen start */ - block[2] = 4; /* X eig factor */ - block[3] = 5; /* Y eig factor */ - block[4] = -1; /* End of list of variables to request */ - - regs.r[0] = (int) block; - regs.r[1] = (int) block; - _kernel_swi(OS_ReadVduVariables, ®s, ®s); - - this->hidden->bank[0] = (void *) block[0]; - this->hidden->bank[1] = (void *) block[1]; - this->hidden->xeig = block[2]; - this->hidden->yeig = block[3]; -} - -/* Toggle to full screen mode from the WIMP */ - -int -FULLSCREEN_ToggleFromWimp(_THIS) -{ - int width = this->screen->w; - int height = this->screen->h; - int bpp = this->screen->format->BitsPerPixel; - - RISCOS_StoreWimpMode(); - if (FULLSCREEN_SetMode(width, height, bpp)) { - char *buffer = this->hidden->alloc_bank; /* This is start of sprite data */ - /* Support back buffer mode only */ - if (riscos_backbuffer == 0) - riscos_backbuffer = 1; - - FULLSCREEN_SetupBanks(this); - - this->hidden->bank[0] = buffer + 60; /* Start of sprite data */ - if (bpp == 8) - this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ - - this->hidden->current_bank = 0; - this->screen->pixels = this->hidden->bank[0]; - - /* Copy back buffer to screen memory */ - SDL_memcpy(this->hidden->bank[1], this->hidden->bank[0], - width * height * this->screen->format->BytesPerPixel); - - FULLSCREEN_SetDeviceMode(this); - return 1; - } else - RISCOS_RestoreWimpMode(); - - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosevents.c b/project/jni/sdl-1.3/src/video/riscos/SDL_riscosevents.c deleted file mode 100644 index fc4e4c6a1..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosevents.c +++ /dev/null @@ -1,598 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability - 27 March 2003 - - Implements keyboard setup, event pump and keyboard and mouse polling -*/ - - -#include "../../timer/SDL_timer_c.h" -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" -#include "../SDL_cursor_c.h" -#include "SDL_riscosvideo.h" -#include "SDL_riscosevents_c.h" - -#include "memory.h" -#include "stdlib.h" -#include "ctype.h" - -#include "kernel.h" -#include "swis.h" - -/* The translation table from a RISC OS internal key numbers to a SDL keysym */ -static SDLKey RO_keymap[SDLK_LAST]; - -/* RISC OS Key codes */ -#define ROKEY_SHIFT 0 -#define ROKEY_CTRL 1 -#define ROKEY_ALT 2 -/* Left shift is first key we will check for */ -#define ROKEY_LEFT_SHIFT 3 - -/* Need to ignore mouse buttons as they are processed separately */ -#define ROKEY_LEFT_MOUSE 9 -#define ROKEY_CENTRE_MOUSE 10 -#define ROKEY_RIGHT_MOUSE 11 - -/* No key has been pressed return value*/ -#define ROKEY_NONE 255 - -/* Id of last key in keyboard */ -#define ROKEY_LAST_KEY 124 - -/* Size of array for all keys */ -#define ROKEYBD_ARRAYSIZE 125 - -static char RO_pressed[ROKEYBD_ARRAYSIZE]; - -static SDL_keysym *TranslateKey(int intkey, SDL_keysym * keysym, int pressed); - -void RISCOS_PollMouse(_THIS); -void RISCOS_PollKeyboard(); - -void RISCOS_PollMouseHelper(_THIS, int fullscreen); - -#if SDL_THREADS_DISABLED -extern void DRenderer_FillBuffers(); - -/* Timer running function */ -extern void RISCOS_CheckTimer(); - -#endif - -void -FULLSCREEN_PumpEvents(_THIS) -{ - /* Current implementation requires keyboard and mouse polling */ - RISCOS_PollKeyboard(); - RISCOS_PollMouse(this); -#if SDL_THREADS_DISABLED -// DRenderer_FillBuffers(); - if (SDL_timer_running) - RISCOS_CheckTimer(); -#endif -} - - -void -RISCOS_InitOSKeymap(_THIS) -{ - int i; - - /* Map the VK keysyms */ - for (i = 0; i < SDL_arraysize(RO_keymap); ++i) - RO_keymap[i] = SDLK_UNKNOWN; - - RO_keymap[3] = SDLK_LSHIFT; - RO_keymap[4] = SDLK_LCTRL; - RO_keymap[5] = SDLK_LALT; - RO_keymap[6] = SDLK_RSHIFT; - RO_keymap[7] = SDLK_RCTRL; - RO_keymap[8] = SDLK_RALT; - RO_keymap[16] = SDLK_q; - RO_keymap[17] = SDLK_3; - RO_keymap[18] = SDLK_4; - RO_keymap[19] = SDLK_5; - RO_keymap[20] = SDLK_F4; - RO_keymap[21] = SDLK_8; - RO_keymap[22] = SDLK_F7; - RO_keymap[23] = SDLK_MINUS, RO_keymap[25] = SDLK_LEFT; - RO_keymap[26] = SDLK_KP6; - RO_keymap[27] = SDLK_KP7; - RO_keymap[28] = SDLK_F11; - RO_keymap[29] = SDLK_F12; - RO_keymap[30] = SDLK_F10; - RO_keymap[31] = SDLK_SCROLLOCK; - RO_keymap[32] = SDLK_PRINT; - RO_keymap[33] = SDLK_w; - RO_keymap[34] = SDLK_e; - RO_keymap[35] = SDLK_t; - RO_keymap[36] = SDLK_7; - RO_keymap[37] = SDLK_i; - RO_keymap[38] = SDLK_9; - RO_keymap[39] = SDLK_0; - RO_keymap[41] = SDLK_DOWN; - RO_keymap[42] = SDLK_KP8; - RO_keymap[43] = SDLK_KP9; - RO_keymap[44] = SDLK_BREAK; - RO_keymap[45] = SDLK_BACKQUOTE; -/* RO_keymap[46] = SDLK_currency; TODO: Figure out if this has a value */ - RO_keymap[47] = SDLK_BACKSPACE; - RO_keymap[48] = SDLK_1; - RO_keymap[49] = SDLK_2; - RO_keymap[50] = SDLK_d; - RO_keymap[51] = SDLK_r; - RO_keymap[52] = SDLK_6; - RO_keymap[53] = SDLK_u; - RO_keymap[54] = SDLK_o; - RO_keymap[55] = SDLK_p; - RO_keymap[56] = SDLK_LEFTBRACKET; - RO_keymap[57] = SDLK_UP; - RO_keymap[58] = SDLK_KP_PLUS; - RO_keymap[59] = SDLK_KP_MINUS; - RO_keymap[60] = SDLK_KP_ENTER; - RO_keymap[61] = SDLK_INSERT; - RO_keymap[62] = SDLK_HOME; - RO_keymap[63] = SDLK_PAGEUP; - RO_keymap[64] = SDLK_CAPSLOCK; - RO_keymap[65] = SDLK_a; - RO_keymap[66] = SDLK_x; - RO_keymap[67] = SDLK_f; - RO_keymap[68] = SDLK_y; - RO_keymap[69] = SDLK_j; - RO_keymap[70] = SDLK_k; - RO_keymap[72] = SDLK_SEMICOLON; - RO_keymap[73] = SDLK_RETURN; - RO_keymap[74] = SDLK_KP_DIVIDE; - RO_keymap[76] = SDLK_KP_PERIOD; - RO_keymap[77] = SDLK_NUMLOCK; - RO_keymap[78] = SDLK_PAGEDOWN; - RO_keymap[79] = SDLK_QUOTE; - RO_keymap[81] = SDLK_s; - RO_keymap[82] = SDLK_c; - RO_keymap[83] = SDLK_g; - RO_keymap[84] = SDLK_h; - RO_keymap[85] = SDLK_n; - RO_keymap[86] = SDLK_l; - RO_keymap[87] = SDLK_SEMICOLON; - RO_keymap[88] = SDLK_RIGHTBRACKET; - RO_keymap[89] = SDLK_DELETE; - RO_keymap[90] = SDLK_KP_MINUS; - RO_keymap[91] = SDLK_KP_MULTIPLY; - RO_keymap[93] = SDLK_EQUALS; - RO_keymap[94] = SDLK_BACKSLASH; - RO_keymap[96] = SDLK_TAB; - RO_keymap[97] = SDLK_z; - RO_keymap[98] = SDLK_SPACE; - RO_keymap[99] = SDLK_v; - RO_keymap[100] = SDLK_b; - RO_keymap[101] = SDLK_m; - RO_keymap[102] = SDLK_COMMA; - RO_keymap[103] = SDLK_PERIOD; - RO_keymap[104] = SDLK_SLASH; - RO_keymap[105] = SDLK_END; - RO_keymap[106] = SDLK_KP0; - RO_keymap[107] = SDLK_KP1; - RO_keymap[108] = SDLK_KP3; - RO_keymap[112] = SDLK_ESCAPE; - RO_keymap[113] = SDLK_F1; - RO_keymap[114] = SDLK_F2; - RO_keymap[115] = SDLK_F3; - RO_keymap[116] = SDLK_F5; - RO_keymap[117] = SDLK_F6; - RO_keymap[118] = SDLK_F8; - RO_keymap[119] = SDLK_F9; - RO_keymap[120] = SDLK_HASH; - RO_keymap[121] = SDLK_RIGHT; - RO_keymap[122] = SDLK_KP4; - RO_keymap[123] = SDLK_KP5; - RO_keymap[124] = SDLK_KP2; - - SDL_memset(RO_pressed, 0, ROKEYBD_ARRAYSIZE); -} - - -/* Variable for mouse relative processing */ -int mouse_relative = 0; - -/* Check to see if we need to enter or leave mouse relative mode */ - -void -RISCOS_CheckMouseMode(_THIS) -{ - /* If the mouse is hidden and input is grabbed, we use relative mode */ - if (!(SDL_cursorstate & CURSOR_VISIBLE) && - (this->input_grab != SDL_GRAB_OFF)) { - mouse_relative = 1; - } else { - mouse_relative = 0; - } -} - - -void -RISCOS_PollMouse(_THIS) -{ - RISCOS_PollMouseHelper(this, 1); -} - -extern int mouseInWindow; - -void -WIMP_PollMouse(_THIS) -{ - /* Only poll when mouse is over the window */ - if (!mouseInWindow) - return; - - RISCOS_PollMouseHelper(this, 0); -} - -/* Static variables so only changes are reported */ -static Sint16 last_x = -1, last_y = -1; -static int last_buttons = 0; - -/* Share routine between WIMP and FULLSCREEN for polling mouse and - passing on events */ -void -RISCOS_PollMouseHelper(_THIS, int fullscreen) -{ - _kernel_swi_regs regs; - static int starting = 1; - - if (_kernel_swi(OS_Mouse, ®s, ®s) == NULL) { - Sint16 new_x = regs.r[0]; /* Initialy get as OS units */ - Sint16 new_y = regs.r[1]; - - /* Discard mouse events until they let go of the mouse after starting */ - if (starting && regs.r[2] != 0) - return; - else - starting = 0; - - if (new_x != last_x || new_y != last_y || last_buttons != regs.r[2]) { - /* Something changed so generate appropriate events */ - int topLeftX, topLeftY; /* Top left OS units */ - int x, y; /* Mouse position in SDL pixels */ - - if (fullscreen) { - topLeftX = 0; - topLeftY = (this->hidden->height << this->hidden->yeig) - 1; - } else { - int window_state[9]; - - /* Get current window state */ - window_state[0] = this->hidden->window_handle; - regs.r[1] = (unsigned int) window_state; - _kernel_swi(Wimp_GetWindowState, ®s, ®s); - - topLeftX = window_state[1]; - topLeftY = window_state[4]; - } - - /* Convert co-ordinates to workspace */ - x = new_x - topLeftX; - y = topLeftY - new_y; /* Y goes from top of window/screen */ - - /* Convert OS units to pixels */ - x >>= this->hidden->xeig; - y >>= this->hidden->yeig; - - if (last_x != new_x || last_y != new_y) { - if (mouse_relative) { - int centre_x = SDL_VideoSurface->w / 2; - int centre_y = SDL_VideoSurface->h / 2; - - if (centre_x != x || centre_y != y) { - if (SDL_VideoSurface) - SDL_PrivateMouseMotion(0, 1, - x - centre_x, - y - centre_y); - last_x = topLeftX + (centre_x << this->hidden->xeig); - last_y = topLeftY - (centre_y << this->hidden->yeig); - - /* Re-centre the mouse pointer, so we still get relative - movement when the mouse is at the edge of the window - or screen. - */ - { - unsigned char block[5]; - - block[0] = 3; /* OSWORD move pointer sub-reason code */ - block[1] = last_x & 0xFF; - block[2] = (last_x >> 8) & 0xFF; - block[3] = last_y & 0xFF; - block[4] = (last_y >> 8) & 0xFF; - - regs.r[0] = 21; /* OSWORD pointer stuff code */ - regs.r[1] = (int) block; - _kernel_swi(OS_Word, ®s, ®s); - } - } - } else { - last_x = new_x; - last_y = new_y; - SDL_PrivateMouseMotion(0, 0, x, y); - } - } - - if (last_buttons != regs.r[2]) { - int changed = last_buttons ^ regs.r[2]; - last_buttons = regs.r[2]; - if (changed & 4) - SDL_PrivateMouseButton((last_buttons & 4) ? - SDL_PRESSED : SDL_RELEASED, - SDL_BUTTON_LEFT, 0, 0); - if (changed & 2) - SDL_PrivateMouseButton((last_buttons & 2) ? - SDL_PRESSED : SDL_RELEASED, - SDL_BUTTON_MIDDLE, 0, 0); - if (changed & 1) - SDL_PrivateMouseButton((last_buttons & 1) ? - SDL_PRESSED : SDL_RELEASED, - SDL_BUTTON_RIGHT, 0, 0); - } - } - } -} - -void -RISCOS_PollKeyboard() -{ - int which_key = ROKEY_LEFT_SHIFT; - int j; - int min_key, max_key; - SDL_keysym key; - - /* Scan the keyboard to see what is pressed */ - while (which_key <= ROKEY_LAST_KEY) { - which_key = (_kernel_osbyte(121, which_key, 0) & 0xFF); - if (which_key != ROKEY_NONE) { - switch (which_key) { - /* Skip over mouse keys */ - case ROKEY_LEFT_MOUSE: - case ROKEY_CENTRE_MOUSE: - case ROKEY_RIGHT_MOUSE: - which_key = ROKEY_RIGHT_MOUSE; - break; - - /* Ignore keys that cause 2 internal number to be generated */ - case 71: - case 24: - case 87: - case 40: - break; - - /* Ignore break as it can be latched on */ - case 44: - break; - - default: - RO_pressed[which_key] += 2; - break; - } - which_key++; - } - } - - /* Generate key released messages */ - min_key = ROKEY_LAST_KEY + 1; - max_key = ROKEY_LEFT_SHIFT; - - for (j = ROKEY_LEFT_SHIFT; j <= ROKEY_LAST_KEY; j++) { - if (RO_pressed[j]) { - if (RO_pressed[j] == 1) { - RO_pressed[j] = 0; - SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(j, &key, 0)); - } else { - if (j < min_key) - min_key = j; - if (j > max_key) - max_key = j; - } - } - } - - /* Generate key pressed messages */ - for (j = min_key; j <= max_key; j++) { - if (RO_pressed[j]) { - if (RO_pressed[j] == 2) { - SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(j, &key, 1)); - } - RO_pressed[j] = 1; - } - } -} - -static SDL_keysym * -TranslateKey(int intkey, SDL_keysym * keysym, int pressed) -{ - /* Set the keysym information */ - keysym->scancode = (unsigned char) intkey; - keysym->sym = RO_keymap[intkey]; - keysym->mod = KMOD_NONE; - keysym->unicode = 0; - if (pressed && SDL_TranslateUNICODE) { - int state; - int ch; - - state = (_kernel_osbyte(202, 0, 255) & 0xFF); - - /*TODO: Take into account other keyboard layouts */ - - ch = keysym->sym; /* This should handle most unshifted keys */ - - if (intkey < 9 || ch == SDLK_UNKNOWN) { - ch = 0; - - } else if (state & 64) { /* Control on */ - ch = ch & 31; - - } else { - int topOfKey = 0; - if (state & 8) { /* Shift on */ - topOfKey = 1; - } - - if ((state & 16) == 0) { /* Caps lock is on */ - if (ch >= SDLK_a && ch <= SDLK_z) { - if ((state & 128) == 0) { /* Shift Enable off */ - /* All letter become upper case */ - topOfKey = 1; - } else { - /* Shift+Letters gives lower case */ - topOfKey = 1 - topOfKey; - } - } - } - - if (topOfKey) { - /* Key produced with shift held down */ - - /* Letters just give upper case version */ - if (ch >= SDLK_a && ch <= SDLK_z) - ch = toupper(ch); - else { - switch (ch) { - case SDLK_HASH: - ch = '~'; - break; - case SDLK_QUOTE: - ch = '@'; - break; - case SDLK_COMMA: - ch = '<'; - break; - case SDLK_MINUS: - ch = '_'; - break; - case SDLK_PERIOD: - ch = '>'; - break; - case SDLK_SLASH: - ch = '?'; - break; - - case SDLK_0: - ch = ')'; - break; - case SDLK_1: - ch = '!'; - break; - case SDLK_2: - ch = '"'; - break; - case SDLK_3: - ch = '£'; - break; - case SDLK_4: - ch = '$'; - break; - case SDLK_5: - ch = '%'; - break; - case SDLK_6: - ch = '^'; - break; - case SDLK_7: - ch = '&'; - break; - case SDLK_8: - ch = '*'; - break; - case SDLK_9: - ch = '('; - break; - - case SDLK_SEMICOLON: - ch = ':'; - break; - case SDLK_EQUALS: - ch = '+'; - break; - case SDLK_LEFTBRACKET: - ch = '{'; - break; - case SDLK_BACKSLASH: - ch = '|'; - break; - case SDLK_RIGHTBRACKET: - ch = '}'; - break; - case SDLK_BACKQUOTE: - ch = '¬'; - break; - - default: - ch = 0; /* Map to zero character if we don't understand it */ - break; - } - } - - } else if (ch > 126) { - /* SDL key code < 126 map directly onto their Unicode equivalents */ - /* Keypad 0 to 9 maps to numeric equivalent */ - if (ch >= SDLK_KP0 && ch <= SDLK_KP9) - ch = ch - SDLK_KP0 + '0'; - else { - /* Following switch maps other keys that produce an Ascii value */ - switch (ch) { - case SDLK_KP_PERIOD: - ch = '.'; - break; - case SDLK_KP_DIVIDE: - ch = '/'; - break; - case SDLK_KP_MULTIPLY: - ch = '*'; - break; - case SDLK_KP_MINUS: - ch = '-'; - break; - case SDLK_KP_PLUS: - ch = '+'; - break; - case SDLK_KP_EQUALS: - ch = '='; - break; - - default: - /* If we don't know what it is set the Unicode to 0 */ - ch = 0; - break; - } - } - } - } - - keysym->unicode = ch; - } - return (keysym); -} - -/* end of SDL_riscosevents.c ... */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosevents_c.h b/project/jni/sdl-1.3/src/video/riscos/SDL_riscosevents_c.h deleted file mode 100644 index e0da64d78..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosevents_c.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_riscosvideo.h" - -/* Variables and functions exported by SDL_sysevents.c to other parts - of the native video subsystem (SDL_sysvideo.c) -*/ -extern void RISCOS_InitOSKeymap(_THIS); -extern void FULLSCREEN_PumpEvents(_THIS); -extern void WIMP_PumpEvents(_THIS); - -/* end of SDL_nullevents_c.h ... */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosmouse.c b/project/jni/sdl-1.3/src/video/riscos/SDL_riscosmouse.c deleted file mode 100644 index f18939d10..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosmouse.c +++ /dev/null @@ -1,380 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability - 27 March 2003 - - Implements mouse cursor shape definitions and positioning -*/ - -#include "SDL_mouse.h" -#include "../../events/SDL_events_c.h" - -#include "SDL_riscosmouse_c.h" - -#include "kernel.h" -#include "swis.h" - -static WMcursor *current_cursor = NULL; -static WMcursor *defined_cursor = NULL; - -extern int mouseInWindow; - -/* Area to save cursor palette colours changed by SDL. - Actual values will be read before we change to the SDL cursor */ -static Uint8 wimp_cursor_palette[2][5] = { - {1, 25, 255, 255, 255}, - {3, 25, 255, 255, 255} -}; - -static int cursor_palette_saved = 0; - -void WIMP_SaveCursorPalette(); -void WIMP_RestoreWimpCursor(); -void WIMP_SetSDLCursorPalette(); - - -void -RISCOS_FreeWMCursor(_THIS, WMcursor * cursor) -{ - SDL_free(cursor->data); - SDL_free(cursor); -} - -WMcursor * -RISCOS_CreateWMCursor(_THIS, - Uint8 * data, Uint8 * mask, int w, int h, int hot_x, - int hot_y) -{ - WMcursor *cursor; - Uint8 *cursor_data; - Uint8 *ptr; - int i, j, k; - int data_byte, mask_byte; - - /* Check to make sure the cursor size is okay */ - if ((w > 32) || (h > 32)) { - SDL_SetError("Only with width and height <= 32 pixels are allowed"); - return (NULL); - } - - /* Allocate the cursor */ - cursor = (WMcursor *) SDL_malloc(sizeof(*cursor)); - if (cursor == NULL) { - SDL_SetError("Out of memory"); - return (NULL); - } - - /* Note: SDL says width must be a multiple of 8 */ - cursor_data = SDL_malloc(w / 4 * h); - if (cursor_data == NULL) { - SDL_free(cursor); - SDL_SetError("Out of memory"); - return (NULL); - } - - cursor->w = w; - cursor->h = h; - cursor->hot_x = hot_x; - cursor->hot_y = hot_y; - cursor->data = cursor_data; - - -/* Data / Mask Resulting pixel on screen - 0 / 1 White - 1 / 1 Black - 0 / 0 Transparent - 1 / 0 Inverted color if possible, black if not. -*/ - ptr = cursor_data; - - for (i = 0; i < h; ++i) { - for (j = 0; j < w / 8; ++j) { - data_byte = *data; - mask_byte = *mask; - *ptr++ = 0; /* Sets whole byte transparent */ - *ptr = 0; - for (k = 0; k < 8; k++) { - (*ptr) <<= 2; - if (data_byte & 1) - *ptr |= 3; /* Black or inverted */ - else if (mask_byte & 1) - *ptr |= 1; /* White */ - if ((k & 3) == 3) - ptr--; - data_byte >>= 1; - mask_byte >>= 1; - } - - ptr += 3; - data++; - mask++; - } - } - - return (cursor); -} - -int -RISCOS_ShowWMCursor(_THIS, WMcursor * cursor) -{ - current_cursor = cursor; - - if (cursor == NULL) { - _kernel_osbyte(106, 0, 0); - defined_cursor = NULL; - } else { - WMcursor *old_cursor = defined_cursor; - - if (cursor != defined_cursor) { - Uint8 cursor_def[10]; - - cursor_def[0] = 0; - cursor_def[1] = 2; /* Use shape number 2 */ - cursor_def[2] = cursor->w / 4; /* Width in bytes */ - cursor_def[3] = cursor->h; /* Height (h) in pixels */ - cursor_def[4] = cursor->hot_x; /* ActiveX in pixels from left */ - cursor_def[5] = cursor->hot_y; /* ActiveY in pixels from top */ - cursor_def[6] = ((int) (cursor->data) & 0xFF); /* Least significant byte of pointer to data */ - cursor_def[7] = ((int) (cursor->data) >> 8) & 0xFF; /* ... */ - cursor_def[8] = ((int) (cursor->data) >> 16) & 0xFF; /* ... */ - cursor_def[9] = ((int) (cursor->data) >> 24) & 0xFF; /* Most significant byte of pointer to data */ - - if (_kernel_osword(21, (int *) cursor_def) != 0) { - SDL_SetError("RISCOS couldn't create the cursor to show"); - return (0); - } - defined_cursor = cursor; - } - - if (old_cursor == NULL) { - /* First time or reshow in window, so save/setup palette */ - if (!cursor_palette_saved) { - WIMP_SaveCursorPalette(); - } - WIMP_SetSDLCursorPalette(); - } - - _kernel_osbyte(106, 2, 0); - } - - return (1); -} - -void -FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y) -{ - Uint8 move_block[5]; - int eig_block[3]; - _kernel_swi_regs regs; - int os_x, os_y; - - eig_block[0] = 4; /* X eig factor */ - eig_block[1] = 5; /* Y eig factor */ - eig_block[2] = -1; /* End of list of variables to request */ - - regs.r[0] = (int) eig_block; - regs.r[1] = (int) eig_block; - _kernel_swi(OS_ReadVduVariables, ®s, ®s); - - os_x = x << eig_block[0]; - os_y = y << eig_block[1]; - - move_block[0] = 3; /* Move cursor */ - move_block[1] = os_x & 0xFF; - move_block[2] = (os_x >> 8) & 0xFF; - move_block[3] = os_y & 0xFF; - move_block[4] = (os_y >> 8) & 0xFF; - - _kernel_osword(21, (int *) move_block); - SDL_PrivateMouseMotion(0, 0, x, y); -} - - -/* Reshow cursor when mouse re-enters the window */ -void -WIMP_ReshowCursor(_THIS) -{ - defined_cursor = NULL; - cursor_palette_saved = 0; - RISCOS_ShowWMCursor(this, current_cursor); -} - -void -WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y) -{ - _kernel_swi_regs regs; - int window_state[9]; - char block[5]; - int osX, osY; - - window_state[0] = this->hidden->window_handle; - regs.r[1] = (unsigned int) window_state; - _kernel_swi(Wimp_GetWindowState, ®s, ®s); - - osX = (x << this->hidden->xeig) + window_state[1]; - osY = window_state[4] - (y << this->hidden->yeig); - - block[0] = 3; - block[1] = osX & 0xFF; - block[2] = (osX >> 8) & 0xFF; - block[3] = osY & 0xFF; - block[4] = (osY >> 8) & 0xFF; - - regs.r[0] = 21; - regs.r[1] = (int) block; - _kernel_swi(OS_Word, ®s, ®s); - SDL_PrivateMouseMotion(0, 0, x, y); -} - -int -WIMP_ShowWMCursor(_THIS, WMcursor * cursor) -{ - if (mouseInWindow) - return RISCOS_ShowWMCursor(this, cursor); - else - current_cursor = cursor; - - return 1; -} - -SDL_GrabMode -RISCOS_GrabInput(_THIS, SDL_GrabMode mode) -{ - /* In fullscreen mode we don't need to do anything */ - if (mode < SDL_GRAB_FULLSCREEN) { - _kernel_swi_regs regs; - unsigned char block[9]; - block[0] = 1; /* Define mouse cursor bounding block */ - - if (mode == SDL_GRAB_OFF) { - /* Clip to whole screen */ - - int r = (this->hidden->screen_width << this->hidden->xeig) - 1; - int t = (this->hidden->screen_height << this->hidden->yeig) - 1; - - block[1] = 0; - block[2] = 0; /* Left */ - block[3] = 0; - block[4] = 0; /* Bottom */ - block[5] = r & 0xFF; - block[6] = (r >> 8) & 0xFF; /* Right */ - block[7] = t & 0xFF; - block[8] = (t >> 8) & 0xFF; /* Top */ - } else { - /* Clip to window */ - unsigned char window_state[36]; - - *((int *) window_state) = this->hidden->window_handle; - regs.r[1] = (unsigned int) window_state; - _kernel_swi(Wimp_GetWindowState, ®s, ®s); - - block[1] = window_state[4]; - block[2] = window_state[5]; - block[3] = window_state[8]; - block[4] = window_state[9]; - block[5] = window_state[12]; - block[6] = window_state[13]; - block[7] = window_state[16]; - block[8] = window_state[17]; - - } - - regs.r[0] = 21; /* OS word code */ - regs.r[1] = (int) block; - _kernel_swi(OS_Word, ®s, ®s); - } - - return mode; -} - -/* Save mouse cursor palette to be restore when we are no longer - defining a cursor */ - -void -WIMP_SaveCursorPalette() -{ - _kernel_swi_regs regs; - int colour; - - for (colour = 0; colour < 2; colour++) { - regs.r[0] = (int) wimp_cursor_palette[colour][0]; - regs.r[1] = 25; - /* Read settings with OS_ReadPalette */ - if (_kernel_swi(0x2f, ®s, ®s) == NULL) { - wimp_cursor_palette[colour][2] = - (unsigned char) ((regs.r[2] >> 8) & 0xFF); - wimp_cursor_palette[colour][3] = - (unsigned char) ((regs.r[2] >> 16) & 0xFF); - wimp_cursor_palette[colour][4] = - (unsigned char) ((regs.r[2] >> 24) & 0xFF); - } - } - - cursor_palette_saved = 1; -} - -/* Restore the WIMP's cursor when we leave the SDL window */ -void -WIMP_RestoreWimpCursor() -{ - int colour; - - /* Reset to pointer shape 1 */ - _kernel_osbyte(106, 1, 0); - - /* Reset pointer colours */ - if (cursor_palette_saved) { - for (colour = 0; colour < 2; colour++) { - _kernel_osword(12, (int *) wimp_cursor_palette[colour]); - } - } - cursor_palette_saved = 0; -} - -/* Set palette used for SDL mouse cursors */ -void -WIMP_SetSDLCursorPalette() -{ - /* First time set up the mouse colours */ - Uint8 block[5]; - - /* Set up colour 1 as white */ - block[0] = 1; /* Colour to change 1 - 3 */ - block[1] = 25; /* Set pointer colour */ - block[2] = 255; /* red component */ - block[3] = 255; /* green component */ - block[4] = 255; /* blue component */ - _kernel_osword(12, (int *) block); - - /* Set colour 3 to back */ - block[0] = 3; /* Colour to change 1 - 3 */ - block[1] = 25; /* Set pointer colour */ - block[2] = 0; /* red component */ - block[3] = 0; /* green component */ - block[4] = 0; /* blue component */ - _kernel_osword(12, (int *) block); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosmouse_c.h b/project/jni/sdl-1.3/src/video/riscos/SDL_riscosmouse_c.h deleted file mode 100644 index 0ba7ea6cb..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosmouse_c.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_riscosvideo.h" - -/* The implementation dependent data for the window manager cursor */ -struct WMcursor -{ - int w; - int h; - int hot_x; - int hot_y; - Uint8 *data; -}; - -/* Functions to be exported */ -void RISCOS_FreeWMCursor(_THIS, WMcursor * cursor); -WMcursor *RISCOS_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, int w, - int h, int hot_x, int hot_y); - -int RISCOS_ShowWMCursor(_THIS, WMcursor * cursor); -void FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y); - -int WIMP_ShowWMCursor(_THIS, WMcursor * cursor); -void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscossprite.c b/project/jni/sdl-1.3/src/video/riscos/SDL_riscossprite.c deleted file mode 100644 index f542cc2ff..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscossprite.c +++ /dev/null @@ -1,263 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability - 27 March 2003 - - Implements Sprite plotting code for wimp display.window -*/ - -#include "kernel.h" -#include "swis.h" - -#include "SDL_stdinc.h" -#include "SDL_riscosvideo.h" - -extern void WIMP_ReadModeInfo(_THIS); - -void WIMP_PaletteChanged(_THIS); - - -/* Create sprite buffer for screen */ - -unsigned char * -WIMP_CreateBuffer(int width, int height, int bpp) -{ - int size; - char sprite_name[12] = "display"; - unsigned char *buffer; - _kernel_swi_regs regs; - int bytesPerPixel; - int bytesPerRow; - int offsetToSpriteData = 60; - - switch (bpp) { - case 32: - bytesPerPixel = 4; - break; - case 16: - bytesPerPixel = 2; - break; - case 8: - bytesPerPixel = 1; - offsetToSpriteData += 2048; /* Add in size of palette */ - break; - default: - return NULL; - break; - } - - bytesPerRow = bytesPerPixel * width; - - if ((bytesPerRow & 3) != 0) { - bytesPerRow += 4 - (bytesPerRow & 3); - } - size = bytesPerRow * height; - - buffer = SDL_malloc((size_t) size + offsetToSpriteData); - if (!buffer) - return NULL; - - /* Initialise a sprite area */ - - *(unsigned int *) buffer = size + offsetToSpriteData; - *(unsigned int *) (buffer + 8) = 16; - - regs.r[0] = 256 + 9; - regs.r[1] = (unsigned int) buffer; - _kernel_swi(OS_SpriteOp, ®s, ®s); - - regs.r[0] = 256 + 15; - regs.r[1] = (unsigned int) buffer; - regs.r[2] = (unsigned int) &sprite_name; - regs.r[3] = 0; /* Palette flag: 0 = no palette */ - regs.r[4] = width; - regs.r[5] = height; - if (bpp == 8) { - /* Use old style mode number */ - regs.r[6] = 28; /* 8bpp 90x90dpi */ - } else { - regs.r[6] = (((bpp == 16) ? 5 : 6) << 27) /* Type 6 = 32bpp sprite, 5 = 16bpp sprite */ - |(90 << 14) /* Vertical dpi */ - |(90 << 1) /* Horizontal dpi */ - |1; /* Marker to distinguish between mode selectors and sprite modes */ - } - if (_kernel_swi(OS_SpriteOp, ®s, ®s) == NULL) { - if (bpp == 8) { - /* Modify sprite to take into account 256 colour palette */ - int *sprite = (int *) (buffer + 16); - /* Adjust sprite offsets */ - sprite[0] += 2048; - sprite[8] += 2048; - sprite[9] += 2048; - /* Adjust sprite area next free pointer */ - (*(int *) (buffer + 12)) += 2048; - - /* Don't need to set up palette as SDL sets up the default - 256 colour palette */ -/* { - int *pal = sprite + 11; - unsigned int j; - unsigned int entry; - for (j = 0; j < 255; j++) - { - entry = (j << 24) | (j << 16) | (j << 8); - *pal++ = entry; - *pal++ = entry; - } - } -*/ - } - } else { - SDL_free(buffer); - buffer = NULL; - } - - return buffer; -} - - -/* Setup translation buffers for the sprite plotting */ - -void -WIMP_SetupPlotInfo(_THIS) -{ - _kernel_swi_regs regs; - int *sprite = ((int *) this->hidden->bank[1]) + 4; - - regs.r[0] = (unsigned int) this->hidden->bank[1]; - regs.r[1] = (unsigned int) sprite; - regs.r[2] = -1; /* Current mode */ - regs.r[3] = -1; /* Current palette */ - regs.r[4] = 0; /* Get size of buffer */ - regs.r[5] = 1 | 2 | 16; /* R1 - pointer to sprite and can use full palette words */ - regs.r[6] = 0; - regs.r[7] = 0; - - if (this->hidden->pixtrans) - SDL_free(this->hidden->pixtrans); - this->hidden->pixtrans = 0; - - /* Get the size required for the buffer */ - _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); - if (regs.r[4]) { - this->hidden->pixtrans = SDL_malloc(regs.r[4]); - - regs.r[4] = (unsigned int) this->hidden->pixtrans; - /* Actually read the buffer */ - _kernel_swi(ColourTrans_GenerateTable, ®s, ®s); - } -} - -/* Plot the sprite in the given context */ -void -WIMP_PlotSprite(_THIS, int x, int y) -{ - _kernel_swi_regs regs; - _kernel_oserror *err; - - regs.r[0] = 52 + 512; - regs.r[1] = (unsigned int) this->hidden->bank[1]; - regs.r[2] = (unsigned int) this->hidden->bank[1] + 16; - regs.r[3] = x; - regs.r[4] = y; - regs.r[5] = 0 | 32; /* Overwrite screen and pixtrans contains wide colour entries */ - regs.r[6] = 0; /* No scale factors i.e. 1:1 */ - regs.r[7] = (int) this->hidden->pixtrans; - - if ((err = _kernel_swi(OS_SpriteOp, ®s, ®s)) != 0) { - int *p = (int *) this->hidden->pixtrans; - printf("OS_SpriteOp failed \n%s\n", err->errmess); - printf("pixtrans %d\n", (int) this->hidden->pixtrans); - printf("%x %x %x\n", p[0], p[1], p[2]); - } -} - - -/* Wimp mode has changes so update colour mapping and pixel sizes - of windows and the sprites they plot */ - -void -WIMP_ModeChanged(_THIS) -{ - int oldXeig = this->hidden->xeig; - int oldYeig = this->hidden->yeig; - - WIMP_ReadModeInfo(this); - - if (oldXeig == this->hidden->xeig && oldYeig == this->hidden->yeig) { - /* Only need to update the palette */ - WIMP_PaletteChanged(this); - } else { - _kernel_swi_regs regs; - int window_state[9]; - int extent[4]; - int currWidth, currHeight; - int newWidth, newHeight; - - /* Need to resize windows and update the palette */ - WIMP_SetupPlotInfo(this); - - - window_state[0] = this->hidden->window_handle; - regs.r[1] = (unsigned int) window_state; - _kernel_swi(Wimp_GetWindowState, ®s, ®s); - - currWidth = window_state[3] - window_state[1]; - currHeight = window_state[4] - window_state[2]; - - newWidth = (currWidth >> oldXeig) << this->hidden->xeig; - newHeight = (currHeight >> oldYeig) << this->hidden->yeig; - /* Need to avoid extent getting too small for visible part - of window */ - extent[0] = 0; - if (currHeight <= newHeight) { - extent[1] = -newHeight; - } else { - extent[1] = -currHeight; - } - if (currWidth <= newWidth) { - extent[2] = newWidth; - } else { - extent[2] = currWidth; - } - extent[3] = 0; - - regs.r[0] = this->hidden->window_handle; - regs.r[1] = (int) extent; - _kernel_swi(Wimp_SetExtent, ®s, ®s); - - /*TODO: May need to set flag to resize window on next open */ - } -} - -/* Palette has changed so update palettes used for windows sprites */ - -void -WIMP_PaletteChanged(_THIS) -{ - WIMP_SetupPlotInfo(this); -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscostask.c b/project/jni/sdl-1.3/src/video/riscos/SDL_riscostask.c deleted file mode 100644 index 960bfdd89..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscostask.c +++ /dev/null @@ -1,367 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS - 26 March 2003 - - File includes routines for: - Setting up as a WIMP Task - Reading information about the current desktop - Storing information before a switch to full screen - Restoring desktop after switching to full screen -*/ - -#include "kernel.h" -#include "swis.h" - -#include "SDL_stdinc.h" -#include "SDL_riscostask.h" - -#if !SDL_THREADS_DISABLED -#include -pthread_t main_thread; -#endif - -/* RISC OS variables */ - -static int task_handle = 0; -static int wimp_version = 0; - -/* RISC OS variables to help compatability with certain programs */ -int riscos_backbuffer = 0; /* Create a back buffer in system memory for full screen mode */ -int riscos_closeaction = 1; /* Close icon action */ - -static int stored_mode = -1; /* -1 when in desktop, mode number or pointer when full screen */ - -extern int mouseInWindow; /* Mouse is in WIMP window */ - -/* Local function */ - -static int RISCOS_GetTaskName(char *task_name, size_t maxlen); - -/* Uncomment next line to copy mode changes/restores to stderr */ -/* #define DUMP_MODE */ -#ifdef DUMP_MODE -#include "stdio.h" -static void -dump_mode() -{ - fprintf(stderr, "mode %d\n", stored_mode); - if (stored_mode < -1 || stored_mode >= 256) { - int blockSize = 0; - int *storeBlock = (int *) stored_mode; - - while (blockSize < 5 || storeBlock[blockSize] != -1) { - fprintf(stderr, " %d\n", storeBlock[blockSize++]); - } - } -} -#endif - -/****************************************************************** - - Initialise as RISC OS Wimp task - -*******************************************************************/ - -int -RISCOS_InitTask() -{ - char task_name[32]; - _kernel_swi_regs regs; - int messages[4]; - - if (RISCOS_GetTaskName(task_name, SDL_arraysize(task_name)) == 0) - return 0; - - messages[0] = 9; /* Palette changed */ - messages[1] = 0x400c1; /* Mode changed */ - messages[2] = 8; /* Pre quit */ - messages[2] = 0; - - regs.r[0] = (unsigned int) 360; /* Minimum version 3.6 */ - regs.r[1] = (unsigned int) 0x4b534154; - regs.r[2] = (unsigned int) task_name; - regs.r[3] = (unsigned int) messages; - - if (_kernel_swi(Wimp_Initialise, ®s, ®s) == 0) { - wimp_version = regs.r[0]; - task_handle = regs.r[1]; - return 1; - } -#if !SDL_THREADS_DISABLED - main_thread = pthread_self(); -#endif - - return 0; -} - -/********************************************************************* - - Close down application on exit. - -**********************************************************************/ - -void -RISCOS_ExitTask() -{ - _kernel_swi_regs regs; - - if (stored_mode == -1) { - /* Ensure cursor is put back to standard pointer shape if - we have been running in a window */ - _kernel_osbyte(106, 1, 0); - } - - /* Ensure we end up back in the wimp */ - RISCOS_RestoreWimpMode(); - - /* Neatly exit the task */ - regs.r[0] = task_handle; - regs.r[1] = (unsigned int) 0x4b534154; - _kernel_swi(Wimp_CloseDown, ®s, ®s); - task_handle = 0; -} - -/************************************************************************** - - Get the name of the task for the desktop. - - Param: task_name - name of task 32 characters. - - Returns: 1 is successful, otherwise 0 - - Notes: Works by getting using OS_GetEnv to get the command line - used to run the program and then parsing a name from it - as follows. - - 1. Use name after final period if not !RunImage - 2. If name is !RunImage then process item before the period - in front of !RunImage. - 3. If directory name use that - 4. if in form use the XXX. - - Finally once this value has been retrieved use it unless - there is a variable set up in the form SDL$$TaskName - in which case the value of this variable will be used. - - Now also gets other RISC OS configuration varibles - SDL$$BackBuffer - set to 1 to use a system memory backbuffer in fullscreen mode - so updates wait until a call to SDL_UpdateRects. (default 0) - This is required for programmes where they have assumed this is - always the case which is contrary to the documentation. - SDL$$CloseAction - 0 Don't show close icon - 1 Show close icon - -***************************************************************************/ - -int -RISCOS_GetTaskName(char *task_name, size_t maxlen) -{ - _kernel_swi_regs regs; - - task_name[0] = 0; - - /* Figure out a sensible task name */ - if (_kernel_swi(OS_GetEnv, ®s, ®s) == 0) { - char *command_line = (char *) regs.r[0]; - size_t len = SDL_strlen(command_line) + 1; - char *buffer = SDL_stack_alloc(char, len); - char *env_var; - char *p; - - SDL_strlcpy(buffer, command_line, len); - p = SDL_strchr(buffer, ' '); - if (p) - *p = 0; - p = SDL_strrchr(buffer, '.'); - if (p == 0) - p = buffer; - if (stricmp(p + 1, "!RunImage") == 0) { - *p = 0; - p = SDL_strrchr(buffer, '.'); - if (p == 0) - p = buffer; - } - if (*p == '.') - p++; - if (*p == '!') - p++; /* Skip "!" at beginning of application directories */ - - if (*p == '<') { - // Probably in the form - char *q = SDL_strchr(p, '$'); - if (q == 0) - q = SDL_strchr(p, '>'); /* Use variable name if not */ - if (q) - *q = 0; - p++; /* Move over the < */ - } - - if (*p) { - /* Read variables that effect the RISC OS SDL engine for this task */ - len = SDL_strlen(p) + 18; /* 18 is larger than the biggest variable name */ - env_var = SDL_stack_alloc(char, len); - if (env_var) { - char *env_val; - - /* See if a variable of form SDL$$TaskName exists */ - - SDL_strlcpy(env_var, "SDL$", len); - SDL_strlcat(env_var, p, len); - SDL_strlcat(env_var, "$TaskName", len); - - env_val = SDL_getenv(env_var); - if (env_val) - SDL_strlcpy(task_name, env_val, maxlen); - - SDL_strlcpy(env_var, "SDL$", len); - SDL_strlcat(env_var, p, len); - SDL_strlcat(env_var, "$BackBuffer", len); - - env_val = SDL_getenv(env_var); - if (env_val) - riscos_backbuffer = atoi(env_val); - - SDL_strlcpy(env_var, "SDL$", len); - SDL_strlcat(env_var, p, len); - SDL_strlcat(env_var, "$CloseAction", len); - - env_val = SDL_getenv(env_var); - if (env_val && SDL_strcmp(env_val, "0") == 0) - riscos_closeaction = 0; - - SDL_stack_free(env_var); - } - - if (!*task_name) - SDL_strlcpy(task_name, p, maxlen); - } - - SDL_stack_free(buffer); - } - - if (task_name[0] == 0) - SDL_strlcpy(task_name, "SDL Task", maxlen); - - return 1; -} - -/***************************************************************** - - Store the current desktop screen mode if we are in the desktop. - -******************************************************************/ - -void -RISCOS_StoreWimpMode() -{ - _kernel_swi_regs regs; - - /* Don't store if in full screen mode */ - if (stored_mode != -1) - return; - - regs.r[0] = 1; - _kernel_swi(OS_ScreenMode, ®s, ®s); - if (regs.r[1] >= 0 && regs.r[1] < 256) - stored_mode = regs.r[1]; - else { - int blockSize = 0; - int *retBlock = (int *) regs.r[1]; - int *storeBlock; - int j; - - while (blockSize < 5 || retBlock[blockSize] != -1) - blockSize++; - blockSize++; - storeBlock = (int *) SDL_malloc(blockSize * sizeof(int)); - retBlock = (int *) regs.r[1]; - for (j = 0; j < blockSize; j++) - storeBlock[j] = retBlock[j]; - - stored_mode = (int) storeBlock; - } -#if DUMP_MODE - fprintf(stderr, "Stored "); - dump_mode(); -#endif -} - -/***************************************************************** - - Restore desktop screen mode if we are in full screen mode. - -*****************************************************************/ - -void -RISCOS_RestoreWimpMode() -{ - _kernel_swi_regs regs; - - /* Only need to restore if we are in full screen mode */ - if (stored_mode == -1) - return; - -#if DUMP_MODE - fprintf(stderr, "Restored"); - dump_mode(); -#endif - - regs.r[0] = stored_mode; - _kernel_swi(Wimp_SetMode, ®s, ®s); - if (stored_mode < 0 || stored_mode > 256) { - SDL_free((int *) stored_mode); - } - stored_mode = -1; - - /* Flush keyboard buffer to dump the keystrokes we've already polled */ - regs.r[0] = 21; - regs.r[1] = 0; /* Keyboard buffer number */ - _kernel_swi(OS_Byte, ®s, ®s); - - mouseInWindow = 0; - -} - -/********************************************************************* - - Get version of Wimp running when task was initialised. - -*********************************************************************/ - -int -RISCOS_GetWimpVersion() -{ - return wimp_version; -} - -int -RISCOS_GetTaskHandle() -{ - return task_handle; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscostask.h b/project/jni/sdl-1.3/src/video/riscos/SDL_riscostask.h deleted file mode 100644 index 8eadb87b4..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscostask.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS - 26 March 2003 -*/ - -/* Task initialisation/Clean up */ - -extern int RISCOS_InitTask(); -extern void RISCOS_ExitTask(); -extern int RISCOS_GetWimpVersion(); -extern int RISCOS_GetTaskHandle(); - - -/* Wimp mode saveing/restoring */ -extern void RISCOS_StoreWimpMode(); -extern void RISCOS_RestoreWimpMode(); - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosvideo.c b/project/jni/sdl-1.3/src/video/riscos/SDL_riscosvideo.c deleted file mode 100644 index c36c3d542..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosvideo.c +++ /dev/null @@ -1,337 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability - 23 March 2003 - - Implements RISC OS display device management. - Routines for full screen and wimp modes are split - into other source files. -*/ - -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "SDL_syswm.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" - -#include "SDL_riscostask.h" -#include "SDL_riscosvideo.h" -#include "SDL_riscosevents_c.h" -#include "SDL_riscosmouse_c.h" - -#include "kernel.h" -#include "swis.h" - -#define RISCOSVID_DRIVER_NAME "riscos" - -/* Initialization/Query functions */ -static int RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat); -static void RISCOS_VideoQuit(_THIS); - -static SDL_Rect **RISCOS_ListModes(_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *RISCOS_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); - -int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info); - -int RISCOS_ToggleFullScreen(_THIS, int fullscreen); -/* Mouse checking */ -void RISCOS_CheckMouseMode(_THIS); -extern SDL_GrabMode RISCOS_GrabInput(_THIS, SDL_GrabMode mode); - -/* Fullscreen mode functions */ -extern SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -extern void FULLSCREEN_BuildModeList(_THIS); -extern void FULLSCREEN_SetDeviceMode(_THIS); -extern int FULLSCREEN_ToggleFromWimp(_THIS); - -/* Wimp mode functions */ -extern SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -extern void WIMP_DeleteWindow(_THIS); -extern int WIMP_ToggleFromFullScreen(_THIS); - -/* Hardware surface functions - common to WIMP and FULLSCREEN */ -static int RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface); -static int RISCOS_LockHWSurface(_THIS, SDL_Surface * surface); -static void RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface); -static void RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface); - -/* RISC OS driver bootstrap functions */ - -static int -RISCOS_Available(void) -{ - return (1); -} - -static void -RISCOS_DeleteDevice(SDL_VideoDevice * device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_VideoDevice * -RISCOS_CreateDevice(int devindex) -{ - SDL_VideoDevice *device; - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); - if (device) { - SDL_memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *device->hidden)); - } - if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } - return (0); - } - SDL_memset(device->hidden, 0, (sizeof *device->hidden)); - - /* Set the function pointers */ - device->VideoInit = RISCOS_VideoInit; - device->VideoQuit = RISCOS_VideoQuit; - - device->ListModes = RISCOS_ListModes; - device->SetVideoMode = RISCOS_SetVideoMode; - device->CreateYUVOverlay = NULL; - device->AllocHWSurface = RISCOS_AllocHWSurface; - device->CheckHWBlit = NULL; - device->FillHWRect = NULL; - device->SetHWColorKey = NULL; - device->SetHWAlpha = NULL; - device->LockHWSurface = RISCOS_LockHWSurface; - device->UnlockHWSurface = RISCOS_UnlockHWSurface; - device->FreeHWSurface = RISCOS_FreeHWSurface; - - device->FreeWMCursor = RISCOS_FreeWMCursor; - device->CreateWMCursor = RISCOS_CreateWMCursor; - device->CheckMouseMode = RISCOS_CheckMouseMode; - device->GrabInput = RISCOS_GrabInput; - - device->InitOSKeymap = RISCOS_InitOSKeymap; - - device->GetWMInfo = RISCOS_GetWmInfo; - - device->free = RISCOS_DeleteDevice; - -/* Can't get Toggle screen to work if program starts up in Full screen mode so - disable it here and re-enable it when a wimp screen is chosen */ - device->ToggleFullScreen = NULL; /*RISCOS_ToggleFullScreen; */ - - /* Set other entries for fullscreen mode */ - FULLSCREEN_SetDeviceMode(device); - - /* Mouse pointer needs to use the WIMP ShowCursor version so - that it doesn't modify the pointer until the SDL Window is - entered or the application goes full screen */ - device->ShowWMCursor = WIMP_ShowWMCursor; - - return device; -} - -VideoBootStrap RISCOS_bootstrap = { - RISCOSVID_DRIVER_NAME, "RISC OS video driver", - RISCOS_Available, RISCOS_CreateDevice -}; - - -int -RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat) -{ - _kernel_swi_regs regs; - int vars[4], vals[3]; - - if (RISCOS_InitTask() == 0) { - SDL_SetError("Unable to start task"); - return 0; - } - - vars[0] = 9; /* Log base 2 bpp */ - vars[1] = 11; /* XWndLimit - num x pixels -1 */ - vars[2] = 12; /* YWndLimit - num y pixels -1 */ - vars[3] = -1; /* Terminate list */ - regs.r[0] = (int) vars; - regs.r[1] = (int) vals; - - _kernel_swi(OS_ReadVduVariables, ®s, ®s); - vformat->BitsPerPixel = (1 << vals[0]); - - /* Determine the current screen size */ - this->info.current_w = vals[1] + 1; - this->info.current_h = vals[2] + 1; - - /* Minimum bpp for SDL is 8 */ - if (vformat->BitsPerPixel < 8) - vformat->BitsPerPixel = 8; - - - switch (vformat->BitsPerPixel) { - case 15: - case 16: - vformat->Bmask = 0x00007c00; - vformat->Gmask = 0x000003e0; - vformat->Rmask = 0x0000001f; - vformat->BitsPerPixel = 16; /* SDL wants actual number of bits used */ - vformat->BytesPerPixel = 2; - break; - - case 24: - case 32: - vformat->Bmask = 0x00ff0000; - vformat->Gmask = 0x0000ff00; - vformat->Rmask = 0x000000ff; - vformat->BytesPerPixel = 4; - break; - - default: - vformat->Bmask = 0; - vformat->Gmask = 0; - vformat->Rmask = 0; - vformat->BytesPerPixel = 1; - break; - } - - /* Fill in some window manager capabilities */ - this->info.wm_available = 1; - - /* We're done! */ - return (0); -} - -/* Note: If we are terminated, this could be called in the middle of - another SDL video routine -- notably UpdateRects. -*/ -void -RISCOS_VideoQuit(_THIS) -{ - RISCOS_ExitTask(); - - if (this->hidden->alloc_bank) - SDL_free(this->hidden->alloc_bank); - this->hidden->alloc_bank = 0; -} - - -SDL_Rect ** -RISCOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) -{ - if (flags & SDL_FULLSCREEN) { - /* Build mode list when first required. */ - if (SDL_nummodes[0] == 0) - FULLSCREEN_BuildModeList(this); - - return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); - } else - return (SDL_Rect **) - 1; -} - - -/* Set up video mode */ -SDL_Surface * -RISCOS_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) -{ - if (flags & SDL_FULLSCREEN) { - RISCOS_StoreWimpMode(); - /* Dump wimp window on switch to full screen */ - if (this->hidden->window_handle) - WIMP_DeleteWindow(this); - - return FULLSCREEN_SetVideoMode(this, current, width, height, bpp, - flags); - } else { - RISCOS_RestoreWimpMode(); - return WIMP_SetVideoMode(this, current, width, height, bpp, flags); - } -} - - -/* We don't actually allow hardware surfaces other than the main one */ -static int -RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface) -{ - return (-1); -} - -static void -RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface) -{ - return; -} - -/* We need to wait for vertical retrace on page flipped displays */ -static int -RISCOS_LockHWSurface(_THIS, SDL_Surface * surface) -{ - return (0); -} - -static void -RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface) -{ - return; -} - - -int -RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info) -{ - SDL_VERSION(&(info->version)); - info->wimpVersion = RISCOS_GetWimpVersion(); - info->taskHandle = RISCOS_GetTaskHandle(); - info->window = this->hidden->window_handle; - - return 1; -} - -/* Toggle full screen mode. - Returns 1 if successful otherwise 0 -*/ - -int -RISCOS_ToggleFullScreen(_THIS, int fullscreen) -{ - if (fullscreen) { - return FULLSCREEN_ToggleFromWimp(this); - } else { - return WIMP_ToggleFromFullScreen(this); - } - - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosvideo.h b/project/jni/sdl-1.3/src/video/riscos/SDL_riscosvideo.h deleted file mode 100644 index 5858a99ba..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_riscosvideo.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_riscosvideo_h -#define _SDL_riscosvideo_h - -#include "SDL_mouse.h" -#include "SDL_mutex.h" -#include "../SDL_sysvideo.h" - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *this - - -/* Private display data */ - -struct SDL_PrivateVideoData -{ - unsigned char *bank[2]; - int current_bank; - unsigned char *alloc_bank; - int height; - int xeig; - int yeig; - int screen_bpp; - int screen_width; - int screen_height; - char *pixtrans; - - /* Wimp variables */ - unsigned int window_handle; - char title[256]; - -#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ - int SDL_nummodes[NUM_MODELISTS]; - SDL_Rect **SDL_modelist[NUM_MODELISTS]; -}; - -/* Old variable names */ -#define SDL_nummodes (this->hidden->SDL_nummodes) -#define SDL_modelist (this->hidden->SDL_modelist) - -#endif /* _SDL_risosvideo_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_wimppoll.c b/project/jni/sdl-1.3/src/video/riscos/SDL_wimppoll.c deleted file mode 100644 index 31d0fda58..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_wimppoll.c +++ /dev/null @@ -1,334 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability - 27 March 2003 - - Implements Pumping of events and WIMP polling -*/ - -#include "SDL_syswm.h" -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" -#include "SDL_riscosvideo.h" -#include "SDL_riscosevents_c.h" -#include "SDL_riscosmouse_c.h" -#include "../../timer/SDL_timer_c.h" - -#include "memory.h" -#include "stdlib.h" -#include "ctype.h" - -#include "kernel.h" -#include "swis.h" -#include "unixlib/os.h" - -#if !SDL_THREADS_DISABLED -#include -#endif - -/* Local functions */ -void WIMP_Poll(_THIS, int waitTime); -void WIMP_SetFocus(int win); - -/* SDL_riscossprite functions */ -void WIMP_PlotSprite(_THIS, int x, int y); -void WIMP_ModeChanged(_THIS); -void WIMP_PaletteChanged(_THIS); - - -extern void WIMP_PollMouse(_THIS); -extern void RISCOS_PollKeyboard(); - -#if SDL_THREADS_DISABLED -/* Timer running function */ -extern void RISCOS_CheckTimer(); -#else -extern int riscos_using_threads; -#endif - -/* Mouse cursor handling */ -extern void WIMP_ReshowCursor(_THIS); -extern void WIMP_RestoreWimpCursor(); - -int hasFocus = 0; -int mouseInWindow = 0; - -/* Flag to ensure window is correct size after a mode change */ -static int resizeOnOpen = 0; - -void -WIMP_PumpEvents(_THIS) -{ - WIMP_Poll(this, 0); - if (hasFocus) - RISCOS_PollKeyboard(); - if (mouseInWindow) - WIMP_PollMouse(this); -#if SDL_THREADS_DISABLED - if (SDL_timer_running) - RISCOS_CheckTimer(); -#endif -} - - -void -WIMP_Poll(_THIS, int waitTime) -{ - _kernel_swi_regs regs; - int message[64]; - unsigned int code; - int pollMask = 0; - int doPoll = 1; - int sysEvent; - int sdlWindow = this->hidden->window_handle; - - if (this->PumpEvents != WIMP_PumpEvents) - return; - - if (waitTime > 0) { - _kernel_swi(OS_ReadMonotonicTime, ®s, ®s); - waitTime += regs.r[0]; - } - - while (doPoll) { -#if !SDL_THREADS_DISABLED - /* Stop thread callbacks while program is paged out */ - if (riscos_using_threads) - __pthread_stop_ticker(); -#endif - - if (waitTime <= 0) { - regs.r[0] = pollMask; /* Poll Mask */ - /* For no wait time mask out null event so we wait until something happens */ - if (waitTime < 0) - regs.r[0] |= 1; - regs.r[1] = (int) message; - _kernel_swi(Wimp_Poll, ®s, ®s); - } else { - regs.r[0] = pollMask; - regs.r[1] = (int) message; - regs.r[2] = waitTime; - _kernel_swi(Wimp_PollIdle, ®s, ®s); - } - - /* Flag to specify if we post a SDL_SysWMEvent */ - sysEvent = 0; - - code = (unsigned int) regs.r[0]; - - switch (code) { - case 0: /* Null Event - drop out for standard processing */ - doPoll = 0; - break; - - case 1: /* Redraw window */ - _kernel_swi(Wimp_RedrawWindow, ®s, ®s); - if (message[0] == sdlWindow) { - while (regs.r[0]) { - WIMP_PlotSprite(this, message[1], message[2]); - _kernel_swi(Wimp_GetRectangle, ®s, ®s); - } - } else { - /* TODO: Currently we just eat them - we may need to pass them on */ - while (regs.r[0]) { - _kernel_swi(Wimp_GetRectangle, ®s, ®s); - } - } - break; - - case 2: /* Open window */ - if (resizeOnOpen && message[0] == sdlWindow) { - /* Ensure window is correct size */ - resizeOnOpen = 0; - message[3] = - message[1] + (this->screen->w << this->hidden->xeig); - message[4] = - message[2] + (this->screen->h << this->hidden->yeig); - } - _kernel_swi(Wimp_OpenWindow, ®s, ®s); - break; - - case 3: /* Close window */ - if (message[0] == sdlWindow) { - /* Documentation makes it looks as if the following line is correct: - ** if (SDL_PrivateQuit() == 1) _kernel_swi(Wimp_CloseWindow, ®s, ®s); - ** However some programs don't process this message and so sit there invisibly - ** in the background so I just post the quit message and hope the application - ** does the correct thing. - */ - SDL_PrivateQuit(); - } else - sysEvent = 1; - doPoll = 0; - break; - - case 4: /* Pointer_Leaving_Window */ - if (message[0] == sdlWindow) { - mouseInWindow = 0; - //TODO: Lose buttons / dragging - /* Reset to default pointer */ - WIMP_RestoreWimpCursor(); - SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS); - } else - sysEvent = 1; - break; - - case 5: /* Pointer_Entering_Window */ - if (message[0] == sdlWindow) { - mouseInWindow = 1; - WIMP_ReshowCursor(this); - SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS); - } else - sysEvent = 1; - break; - - case 6: /* Mouse_Click */ - if (hasFocus == 0) { - /* First click gives focus if it's not a menu */ - /* we only count non-menu clicks on a window that has the focus */ - WIMP_SetFocus(message[3]); - } else - doPoll = 0; // So PollMouse gets a chance to pick it up - break; - - case 7: /* User_Drag_Box - Used for mouse release */ - //TODO: May need to implement this in the future - sysEvent = 1; - break; - - case 8: /* Keypressed */ - doPoll = 0; /* PollKeyboard should pick it up */ - if (message[0] != sdlWindow) - sysEvent = 1; - /*TODO: May want to always pass F12 etc to the wimp - { - regs.r[0] = message[6]; - _kernel_swi(Wimp_ProcessKey, ®s, ®s); - } - */ - break; - - case 11: /* Lose Caret */ - hasFocus = 0; - if (message[0] == sdlWindow) - SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS); - else - sysEvent = 1; - break; - - case 12: /* Gain Caret */ - hasFocus = 1; - if (message[0] == sdlWindow) - SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS); - else - sysEvent = 1; - break; - - case 17: - case 18: - sysEvent = 1; /* All messages are passed on */ - - switch (message[4]) { - case 0: /* Quit Event */ - /* No choice - have to quit */ - SDL_Quit(); - exit(0); - break; - - case 8: /* Pre Quit */ - SDL_PrivateQuit(); - break; - - case 0x400c1: /* Mode change */ - WIMP_ModeChanged(this); - resizeOnOpen = 1; - break; - - case 9: /* Palette changed */ - WIMP_PaletteChanged(this); - break; - } - break; - - default: - /* Pass unknown events on */ - sysEvent = 1; - break; - } - - if (sysEvent) { - SDL_SysWMmsg wmmsg; - - SDL_VERSION(&wmmsg.version); - wmmsg.eventCode = code; - SDL_memcpy(wmmsg.pollBlock, message, 64 * sizeof(int)); - - /* Fall out of polling loop if message is successfully posted */ - if (SDL_PrivateSysWMEvent(&wmmsg)) - doPoll = 0; - } -#if !SDL_THREADS_DISABLED - if (riscos_using_threads) { - /* Restart ticker here so other thread can not interfere - with the Redraw processing */ - if (riscos_using_threads) - __pthread_start_ticker(); - /* Give other threads a better chance of running */ - pthread_yield(); - } -#endif - } -} - -/* Set focus to specified window */ -void -WIMP_SetFocus(int win) -{ - _kernel_swi_regs regs; - - regs.r[0] = win; - regs.r[1] = -1; /* Icon handle */ - regs.r[2] = 0; /* X-offset we just put it at position 0 */ - regs.r[3] = 0; /* Y-offset as above */ - regs.r[4] = 1 << 25; /* Caret is invisible */ - regs.r[5] = 0; /* index into string */ - - _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); -} - -/** Run background task while in a sleep command */ -void -RISCOS_BackgroundTasks(void) -{ - if (current_video && current_video->hidden->window_handle) { - WIMP_Poll(current_video, 0); - } -#if SDL_THREADS_DISABLED - if (SDL_timer_running) - RISCOS_CheckTimer(); -#endif -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/riscos/SDL_wimpvideo.c b/project/jni/sdl-1.3/src/video/riscos/SDL_wimpvideo.c deleted file mode 100644 index 3b6104f56..000000000 --- a/project/jni/sdl-1.3/src/video/riscos/SDL_wimpvideo.c +++ /dev/null @@ -1,511 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* - File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability - 27 March 2003 - - Implements RISC OS Wimp display. -*/ - -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" - -#include "SDL_riscostask.h" -#include "SDL_riscosvideo.h" -#include "SDL_riscosevents_c.h" -#include "SDL_riscosmouse_c.h" - -#include "kernel.h" -#include "swis.h" - -/* Initialization/Query functions */ -SDL_Rect **WIMP_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); -SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -int WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors); -void WIMP_SetWMCaption(_THIS, const char *title, const char *icon); - - -extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp); -extern void WIMP_PumpEvents(_THIS); -extern void WIMP_PlotSprite(_THIS, int x, int y); -extern void WIMP_SetupPlotInfo(_THIS); -extern void WIMP_SetFocus(int win); - -/* etc. */ -static void WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects); - -/* RISC OS Wimp handling helpers */ -void WIMP_ReadModeInfo(_THIS); -unsigned int WIMP_SetupWindow(_THIS, SDL_Surface * surface); -void WIMP_SetDeviceMode(_THIS); -void WIMP_DeleteWindow(_THIS); - -/* FULLSCREEN function required for wimp/fullscreen toggling */ -extern int FULLSCREEN_SetMode(int width, int height, int bpp); - -/* Currently need to set this up here as it only works if you - start up in a Wimp mode */ -extern int RISCOS_ToggleFullScreen(_THIS, int fullscreen); - -extern int riscos_backbuffer; -extern int mouseInWindow; -extern int riscos_closeaction; - -/* Following needed to ensure window is shown immediately */ -extern int hasFocus; -extern void WIMP_Poll(_THIS, int waitTime); - -SDL_Surface * -WIMP_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) -{ - Uint32 Rmask = 0; - Uint32 Gmask = 0; - Uint32 Bmask = 0; - char *buffer = NULL; - int bytesPerPixel = 1; - - /* Don't support double buffering in Wimp mode */ - flags &= ~SDL_DOUBLEBUF; - flags &= ~SDL_HWSURFACE; - - switch (bpp) { - case 8: - /* Emulated palette using ColourTrans */ - flags |= SDL_HWPALETTE; - break; - - case 15: - case 16: - Bmask = 0x00007c00; - Gmask = 0x000003e0; - Rmask = 0x0000001f; - bytesPerPixel = 2; - break; - - case 32: - Bmask = 0x00ff0000; - Gmask = 0x0000ff00; - Rmask = 0x000000ff; - bytesPerPixel = 4; - break; - - default: - SDL_SetError("Pixel depth not supported"); - return NULL; - break; - } - -/* printf("Setting mode %dx%d\n", width, height);*/ - - /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) { - SDL_SetError("Couldn't allocate new pixel format for requested mode"); - return (NULL); - } - - /* Set up the new mode framebuffer */ - current->w = width; - this->hidden->height = current->h = height; - - if (bpp == 15) - bpp = 16; - buffer = WIMP_CreateBuffer(width, height, bpp); - if (buffer == NULL) { - SDL_SetError("Couldn't create sprite for video memory"); - return (NULL); - } - - this->hidden->bank[0] = buffer + 60; /* Start of sprite data */ - if (bpp == 8) - this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ - - this->hidden->bank[1] = buffer; /* Start of buffer */ - - /* Remember sprite buffer so it can be freed later */ - if (this->hidden->alloc_bank) - SDL_free(this->hidden->alloc_bank); - this->hidden->alloc_bank = buffer; - - current->pitch = width * bytesPerPixel; - if ((current->pitch & 3)) { - /* Sprites are 32bit word aligned */ - current->pitch += (4 - (current->pitch & 3)); - } - - current->flags = flags | SDL_PREALLOC; - - WIMP_ReadModeInfo(this); - - SDL_memset(this->hidden->bank[0], 0, height * current->pitch); - - this->hidden->current_bank = 0; - current->pixels = this->hidden->bank[0]; - - - if (WIMP_SetupWindow(this, current) == 0) { - SDL_SetError("Unable to create window to display surface"); - return NULL; - } - - /* Reset device functions for the wimp */ - WIMP_SetDeviceMode(this); - - /* Needs to set up plot info after window has been created */ - /* Not sure why, but plots don't work if I do it earlier */ - WIMP_SetupPlotInfo(this); - - /* Poll until window is shown */ - { - /* We wait until it gets the focus, but give up after 5 seconds - in case the focus is prevented in any way. - */ - Uint32 now = SDL_GetTicks(); - while (!hasFocus && SDL_GetTicks() - now < 5000) { - WIMP_Poll(this, 0); - } - } - - /* We're done */ - return (current); -} - - -void -WIMP_ReadModeInfo(_THIS) -{ - _kernel_swi_regs regs; - int vars[6]; - int vals[5]; - - vars[0] = 4; /* XEig */ - vars[1] = 5; /* YEig */ - vars[2] = 9; /* Log base 2 bpp */ - vars[3] = 11; /* Screen Width - 1 */ - vars[4] = 12; /* Screen Depth - 1 */ - vars[5] = -1; /* Terminate list */ - - regs.r[0] = (int) vars; - regs.r[1] = (int) vals; - _kernel_swi(OS_ReadVduVariables, ®s, ®s); - this->hidden->xeig = vals[0]; - this->hidden->yeig = vals[1]; - this->hidden->screen_bpp = 1 << vals[2]; - this->hidden->screen_width = vals[3] + 1; - this->hidden->screen_height = vals[4] + 1; -} - -/* Set device function to call the correct versions for running - in a wimp window */ - -void -WIMP_SetDeviceMode(_THIS) -{ - if (this->UpdateRects == WIMP_UpdateRects) - return; /* Already set up */ - - this->SetColors = WIMP_SetColors; - this->UpdateRects = WIMP_UpdateRects; - - this->FlipHWSurface = NULL; - - this->SetCaption = WIMP_SetWMCaption; - this->SetIcon = NULL; - this->IconifyWindow = NULL; - - this->ShowWMCursor = WIMP_ShowWMCursor; - this->WarpWMCursor = WIMP_WarpWMCursor; - - this->ToggleFullScreen = RISCOS_ToggleFullScreen; - - this->PumpEvents = WIMP_PumpEvents; -} - -/* Setup the Window to display the surface */ -unsigned int -WIMP_SetupWindow(_THIS, SDL_Surface * surface) -{ - _kernel_swi_regs regs; - int window_data[23]; - int *window_block = window_data + 1; - int x = (this->hidden->screen_width - surface->w) / 2; - int y = (this->hidden->screen_height - surface->h) / 2; - int xeig = this->hidden->xeig; - int yeig = this->hidden->yeig; - - mouseInWindow = 0; - - /* Always delete the window and recreate on a change */ - if (this->hidden->window_handle) - WIMP_DeleteWindow(this); - - /* Setup window co-ordinates */ - window_block[0] = x << xeig; - window_block[1] = y << yeig; - window_block[2] = window_block[0] + (surface->w << xeig); - window_block[3] = window_block[1] + (surface->h << yeig); - - - window_block[4] = 0; /* Scroll offsets */ - window_block[5] = 0; - window_block[6] = -1; /* Open on top of window stack */ - - window_block[7] = 0x85040042; /* Window flags */ - if (riscos_closeaction != 0) - window_block[7] |= 0x2000000; - - /* TODO: Take into account surface->flags */ - - window_block[8] = 0xff070207; /* Window colours */ - window_block[9] = 0x000c0103; - window_block[10] = 0; /* Work area minimum */ - window_block[11] = -surface->h << yeig; - window_block[12] = surface->w << xeig; /* Work area maximum */ - window_block[13] = 0; - window_block[14] = 0x2700013d; /* Title icon flags */ - window_block[15] = 0x00003000; /* Work area flags - Mouse click down reported */ - window_block[16] = 1; /* Sprite area control block pointer */ - window_block[17] = 0x00100010; /* Minimum window size (width & height) (16x16) */ - window_block[18] = (int) this->hidden->title; /* Title data */ - window_block[19] = -1; - window_block[20] = 256; - window_block[21] = 0; /* Number of icons */ - - regs.r[1] = (unsigned int) (window_block); - - /* Create the window */ - if (_kernel_swi(Wimp_CreateWindow, ®s, ®s) == NULL) { - this->hidden->window_handle = window_data[0] = regs.r[0]; - - /* Show the window on the screen */ - regs.r[1] = (unsigned int) window_data; - if (_kernel_swi(Wimp_OpenWindow, ®s, ®s) == NULL) { - WIMP_SetFocus(this->hidden->window_handle); - } else { - WIMP_DeleteWindow(this); - } - } - - return this->hidden->window_handle; -} - -/* Destroy the Window */ - -void -WIMP_DeleteWindow(_THIS) -{ - _kernel_swi_regs regs; - regs.r[1] = (unsigned int) &(this->hidden->window_handle); - _kernel_swi(Wimp_DeleteWindow, ®s, ®s); - this->hidden->window_handle = 0; -} - - -void -WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects) -{ - _kernel_swi_regs regs; - int update_block[12]; - int xeig = this->hidden->xeig; - int yeig = this->hidden->yeig; - int j; - update_block[0] = this->hidden->window_handle; - - for (j = 0; j < numrects; j++) { - update_block[1] = rects[j].x << xeig; /* Min X */ - update_block[4] = -(rects[j].y << yeig); - update_block[3] = update_block[1] + (rects[j].w << xeig); - update_block[2] = update_block[4] - (rects[j].h << yeig); - - regs.r[1] = (int) update_block; - /* Update window can fail if called before first poll */ - if (_kernel_swi(Wimp_UpdateWindow, ®s, ®s) == 0) { - while (regs.r[0]) { - WIMP_PlotSprite(this, update_block[1], update_block[2]); - _kernel_swi(Wimp_GetRectangle, ®s, ®s); - } - } - } -} - - -int -WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) -{ - unsigned int *pal = (unsigned int *) (this->hidden->bank[1] + 60); - int j; - SDL_Rect update; - - pal += firstcolor * 2; - for (j = 0; j < ncolors; j++) { - *pal = (((unsigned int) colors->r) << 8) - + (((unsigned int) colors->g) << 16) - + (((unsigned int) colors->b) << 24); - pal[1] = *pal; - pal += 2; - colors++; - } - - WIMP_SetupPlotInfo(this); - - /* Need to refresh the window */ - update.x = 0; - update.y = 0; - update.w = SDL_VideoSurface->w; - update.h = SDL_VideoSurface->h; - WIMP_UpdateRects(this, 1, &update); - - return 1; -} - -void -WIMP_SetWMCaption(_THIS, const char *title, const char *icon) -{ - _kernel_swi_regs regs; - - SDL_strlcpy(this->hidden->title, title, - SDL_arraysize(this->hidden->title)); - - if (RISCOS_GetWimpVersion() < 380) { - int block[6]; - - regs.r[1] = (int) block; - _kernel_swi(Wimp_GetCaretPosition, ®s, ®s); - if (block[0] == (int) this->hidden->window_handle) { - regs.r[0] = -1; - _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); - } else { - regs.r[0] = this->hidden->window_handle; - regs.r[1] = -1; - regs.r[2] = -1; - regs.r[3] = -1; - _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); - } - regs.r[0] = block[0]; - regs.r[1] = block[1]; - regs.r[2] = block[2]; - regs.r[3] = block[3]; - regs.r[4] = block[4]; - regs.r[5] = block[5]; - _kernel_swi(Wimp_SetCaretPosition, ®s, ®s); - } else { - regs.r[0] = this->hidden->window_handle; - regs.r[1] = 0x4b534154; /* "TASK" */ - regs.r[2] = 3; /* Redraw title */ - _kernel_swi(Wimp_ForceRedraw, ®s, ®s); - } -} - -void -WIMP_RefreshDesktop(_THIS) -{ - int width = this->hidden->screen_width << this->hidden->xeig; - int height = this->hidden->screen_height << this->hidden->yeig; - _kernel_swi_regs regs; - regs.r[0] = -1; /* Whole screen */ - regs.r[1] = 0; - regs.r[2] = 0; - regs.r[3] = width; - regs.r[4] = height; - _kernel_swi(Wimp_ForceRedraw, ®s, ®s); -} - -/* Toggle to window from full screen */ -int -WIMP_ToggleFromFullScreen(_THIS) -{ - int width = this->screen->w; - int height = this->screen->h; - int bpp = this->screen->format->BitsPerPixel; - char *buffer = NULL; - char *old_bank[2]; - char *old_alloc_bank; - - /* Ensure flags are OK */ - this->screen->flags &= ~(SDL_DOUBLEBUF | SDL_HWSURFACE); - - if (this->hidden->bank[0] == this->hidden->alloc_bank - || riscos_backbuffer == 0) { - /* Need to create a sprite for the screen and copy the data to it */ - char *data; - buffer = WIMP_CreateBuffer(width, height, bpp); - data = buffer + 60; /* Start of sprite data */ - if (bpp == 8) - data += 2048; /* 8bpp sprite have palette first */ - - if (buffer == NULL) - return 0; - SDL_memcpy(data, this->hidden->bank[0], - width * height * this->screen->format->BytesPerPixel); - } - /* else We've switch to full screen before so we already have a sprite */ - - old_bank[0] = this->hidden->bank[0]; - old_bank[1] = this->hidden->bank[1]; - old_alloc_bank = this->hidden->alloc_bank; - - if (buffer != NULL) - this->hidden->alloc_bank = buffer; - - this->hidden->bank[1] = this->hidden->alloc_bank; - this->hidden->bank[0] = this->hidden->bank[1] + 60; /* Start of sprite data */ - if (bpp == 8) - this->hidden->bank[0] += 2048; /* 8bpp sprite have palette first */ - - this->hidden->current_bank = 0; - this->screen->pixels = this->hidden->bank[0]; - - RISCOS_RestoreWimpMode(); - WIMP_ReadModeInfo(this); - if (WIMP_SetupWindow(this, this->screen)) { - WIMP_SetDeviceMode(this); - WIMP_SetupPlotInfo(this); - - if (riscos_backbuffer == 0) - riscos_backbuffer = 1; - - if (buffer && old_alloc_bank) - SDL_free(old_alloc_bank); - - return 1; - } else { - /* Drop back to full screen mode on failure */ - this->hidden->bank[0] = old_bank[0]; - this->hidden->bank[1] = old_bank[1]; - this->hidden->alloc_bank = old_alloc_bank; - if (buffer) - SDL_free(buffer); - - RISCOS_StoreWimpMode(); - FULLSCREEN_SetMode(width, height, bpp); - } - - return 0; -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/sdlgenblit.pl b/project/jni/sdl-1.3/src/video/sdlgenblit.pl index 6062b4f8a..4b53beec0 100755 --- a/project/jni/sdl-1.3/src/video/sdlgenblit.pl +++ b/project/jni/sdl-1.3/src/video/sdlgenblit.pl @@ -9,7 +9,6 @@ use strict; my %file; # The formats potentially supported by this script: -# SDL_PIXELFORMAT_INDEX8 # SDL_PIXELFORMAT_RGB332 # SDL_PIXELFORMAT_RGB444 # SDL_PIXELFORMAT_RGB555 @@ -82,25 +81,24 @@ sub open_file { print FILE <<__EOF__; /* DO NOT EDIT! This file is generated by sdlgenblit.pl */ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken\@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -238,14 +236,7 @@ __EOF__ ${s}B = (${s}B * ${s}A) / 255; } } - switch (flags & (SDL_COPY_MASK|SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { - case SDL_COPY_MASK: - if (${s}A) { - ${d}R = ${s}R; - ${d}G = ${s}G; - ${d}B = ${s}B; - } - break; + switch (flags & (SDL_COPY_BLEND|SDL_COPY_ADD|SDL_COPY_MOD)) { case SDL_COPY_BLEND: ${d}R = ${s}R + ((255 - ${s}A) * ${d}R) / 255; ${d}G = ${s}G + ((255 - ${s}A) * ${d}G) / 255; @@ -282,8 +273,12 @@ sub output_copyfunc output_copyfuncname("static void", $src, $dst, $modulate, $blend, $scale, 1, "\n"); print FILE <<__EOF__; { +__EOF__ + if ( $modulate || $blend ) { + print FILE <<__EOF__; const int flags = info->flags; __EOF__ + } if ( $modulate ) { print FILE <<__EOF__; const Uint32 modulateR = info->r; @@ -317,7 +312,7 @@ __EOF__ incx = (info->src_w << 16) / info->dst_w; while (info->dst_h--) { - $format_type{$src} *src; + $format_type{$src} *src = 0; $format_type{$dst} *dst = ($format_type{$dst} *)info->dst; int n = info->dst_w; srcx = -1; @@ -410,7 +405,7 @@ __EOF__ } } if ( $blend ) { - $flag = "SDL_COPY_MASK | SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD"; + $flag = "SDL_COPY_BLEND | SDL_COPY_ADD | SDL_COPY_MOD"; if ( $flags eq "" ) { $flags = $flag; } else { diff --git a/project/jni/sdl-1.3/src/video/svga/SDL_svgaevents.c b/project/jni/sdl-1.3/src/video/svga/SDL_svgaevents.c deleted file mode 100644 index 4e6eaf54f..000000000 --- a/project/jni/sdl-1.3/src/video/svga/SDL_svgaevents.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Handle the event stream, converting X11 events into SDL events */ - -#include -#include -#include -#if defined(__LINUX__) -#include -#include -#elif defined(__FREEBSD__) -#include -#else -#error You must choose your operating system here -#endif - -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" -#include "SDL_svgavideo.h" -#include "SDL_svgaevents_c.h" - -/* The translation tables from a console scancode to a SDL keysym */ -#if defined(linux) -#define NUM_VGAKEYMAPS (1<scancode = scancode; - keysym->sym = keymap[scancode]; - keysym->mod = KMOD_NONE; - - /* If UNICODE is on, get the UNICODE value for the key */ - keysym->unicode = 0; - if (SDL_TranslateUNICODE) { - int map; - SDLMod modstate; - - modstate = SDL_GetModState(); - map = 0; - if (modstate & KMOD_SHIFT) { - map |= (1 << KG_SHIFT); - } - if (modstate & KMOD_CTRL) { - map |= (1 << KG_CTRL); - } - if (modstate & KMOD_ALT) { - map |= (1 << KG_ALT); - } - if (modstate & KMOD_MODE) { - map |= (1 << KG_ALTGR); - } - if (KTYP(vga_keymap[map][scancode]) == KT_LETTER) { - if (modstate & KMOD_CAPS) { - map ^= (1 << KG_SHIFT); - } - } - if (KTYP(vga_keymap[map][scancode]) == KT_PAD) { - if (modstate & KMOD_NUM) { - keysym->unicode = KVAL(vga_keymap[map][scancode]); - } - } else { - keysym->unicode = KVAL(vga_keymap[map][scancode]); - } - } - return (keysym); -} -#elif defined(__FREEBSD__) -static SDL_keysym * -TranslateKey(int scancode, SDL_keysym * keysym) -{ - /* Set the keysym information */ - keysym->scancode = scancode; - keysym->sym = keymap[scancode]; - keysym->mod = KMOD_NONE; - - /* If UNICODE is on, get the UNICODE value for the key */ - keysym->unicode = 0; - if (SDL_TranslateUNICODE && vga_keymap) { - int map; - SDLMod modstate; - - modstate = SDL_GetModState(); - map = 0; - if (modstate & KMOD_SHIFT) { - map += 1; - } - if (modstate & KMOD_CTRL) { - map += 2; - } - if (modstate & KMOD_ALT) { - map += 4; - } - if (!(vga_keymap->key[scancode].spcl & (0x80 >> map))) { - keysym->unicode = vga_keymap->key[scancode].map[map]; - } - - } - return (keysym); -} -#else -#error You must choose your operating system here -#endif -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/svga/SDL_svgaevents_c.h b/project/jni/sdl-1.3/src/video/svga/SDL_svgaevents_c.h deleted file mode 100644 index 91f4f7cdf..000000000 --- a/project/jni/sdl-1.3/src/video/svga/SDL_svgaevents_c.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_svgavideo.h" - -/* Variables and functions exported by SDL_sysevents.c to other parts - of the native video subsystem (SDL_sysvideo.c) -*/ -extern int SVGA_initkeymaps(int fd); -extern void SVGA_mousecallback(int button, int dx, int dy, - int u1, int u2, int u3, int u4); -extern void SVGA_keyboardcallback(int scancode, int pressed); - -extern void SVGA_InitOSKeymap(_THIS); -extern void SVGA_PumpEvents(_THIS); -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/svga/SDL_svgamouse.c b/project/jni/sdl-1.3/src/video/svga/SDL_svgamouse.c deleted file mode 100644 index e40e23f13..000000000 --- a/project/jni/sdl-1.3/src/video/svga/SDL_svgamouse.c +++ /dev/null @@ -1,35 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_mouse.h" -#include "../../events/SDL_events_c.h" -#include "SDL_svgavideo.h" -#include "SDL_svgamouse_c.h" - - -/* The implementation dependent data for the window manager cursor */ -struct WMcursor -{ - int unused; -}; -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/svga/SDL_svgamouse_c.h b/project/jni/sdl-1.3/src/video/svga/SDL_svgamouse_c.h deleted file mode 100644 index 1cd27846c..000000000 --- a/project/jni/sdl-1.3/src/video/svga/SDL_svgamouse_c.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_svgavideo.h" - -/* Functions to be exported */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/svga/SDL_svgavideo.c b/project/jni/sdl-1.3/src/video/svga/SDL_svgavideo.c deleted file mode 100644 index 111c90871..000000000 --- a/project/jni/sdl-1.3/src/video/svga/SDL_svgavideo.c +++ /dev/null @@ -1,604 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* SVGAlib based SDL video driver implementation. -*/ - -#include -#include -#include -#include -#include - -#if defined(__LINUX__) -#include -#elif defined(__FREEBSD__) -#include -#else -#error You must choose your operating system here -#endif -#include -#include -#include - -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" -#include "SDL_svgavideo.h" -#include "SDL_svgaevents_c.h" -#include "SDL_svgamouse_c.h" - -/* Initialization/Query functions */ -static int SVGA_VideoInit(_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **SVGA_ListModes(_THIS, SDL_PixelFormat * format, - Uint32 flags); -static SDL_Surface *SVGA_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, - Uint32 flags); -static int SVGA_SetColors(_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void SVGA_VideoQuit(_THIS); - -/* Hardware surface functions */ -static int SVGA_AllocHWSurface(_THIS, SDL_Surface * surface); -static int SVGA_LockHWSurface(_THIS, SDL_Surface * surface); -static int SVGA_FlipHWSurface(_THIS, SDL_Surface * surface); -static void SVGA_UnlockHWSurface(_THIS, SDL_Surface * surface); -static void SVGA_FreeHWSurface(_THIS, SDL_Surface * surface); - -/* SVGAlib driver bootstrap functions */ - -static int -SVGA_Available(void) -{ - /* Check to see if we are root and stdin is a virtual console */ - int console; - - /* SVGALib 1.9.x+ doesn't require root (via /dev/svga) */ - int svgalib2 = -1; - - /* See if we are connected to a virtual terminal */ - console = STDIN_FILENO; -#if 0 /* This is no longer needed, SVGAlib can switch consoles for us */ - if (console >= 0) { - struct stat sb; - struct vt_mode dummy; - - if ((fstat(console, &sb) < 0) || - (ioctl(console, VT_GETMODE, &dummy) < 0)) { - console = -1; - } - } -#endif /* 0 */ - - /* See if SVGAlib 2.0 is available */ - svgalib2 = open("/dev/svga", O_RDONLY); - if (svgalib2 != -1) { - close(svgalib2); - } - - return (((svgalib2 != -1) || (geteuid() == 0)) && (console >= 0)); -} - -static void -SVGA_DeleteDevice(SDL_VideoDevice * device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_VideoDevice * -SVGA_CreateDevice(int devindex) -{ - SDL_VideoDevice *device; - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); - if (device) { - SDL_memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *device->hidden)); - } - if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } - return (0); - } - SDL_memset(device->hidden, 0, (sizeof *device->hidden)); - - /* Set the function pointers */ - device->VideoInit = SVGA_VideoInit; - device->ListModes = SVGA_ListModes; - device->SetVideoMode = SVGA_SetVideoMode; - device->SetColors = SVGA_SetColors; - device->UpdateRects = NULL; - device->VideoQuit = SVGA_VideoQuit; - device->AllocHWSurface = SVGA_AllocHWSurface; - device->CheckHWBlit = NULL; - device->FillHWRect = NULL; - device->SetHWColorKey = NULL; - device->SetHWAlpha = NULL; - device->LockHWSurface = SVGA_LockHWSurface; - device->UnlockHWSurface = SVGA_UnlockHWSurface; - device->FlipHWSurface = SVGA_FlipHWSurface; - device->FreeHWSurface = SVGA_FreeHWSurface; - device->SetCaption = NULL; - device->SetIcon = NULL; - device->IconifyWindow = NULL; - device->GrabInput = NULL; - device->GetWMInfo = NULL; - device->InitOSKeymap = SVGA_InitOSKeymap; - device->PumpEvents = SVGA_PumpEvents; - - device->free = SVGA_DeleteDevice; - - return device; -} - -VideoBootStrap SVGALIB_bootstrap = { - "svgalib", "SVGAlib", - SVGA_Available, SVGA_CreateDevice -}; - -static int -SVGA_AddMode(_THIS, int mode, int actually_add) -{ - int i, j; - vga_modeinfo *modeinfo; - - modeinfo = vga_getmodeinfo(mode); - - i = modeinfo->bytesperpixel - 1; - if (i < 0) { - return 0; - } - if (actually_add) { - SDL_Rect saved_rect[2]; - int saved_mode[2]; - int b; - - /* Add the mode, sorted largest to smallest */ - b = 0; - j = 0; - while ((SDL_modelist[i][j]->w > modeinfo->width) || - (SDL_modelist[i][j]->h > modeinfo->height)) { - ++j; - } - /* Skip modes that are already in our list */ - if ((SDL_modelist[i][j]->w == modeinfo->width) && - (SDL_modelist[i][j]->h == modeinfo->height)) { - return (0); - } - /* Insert the new mode */ - saved_rect[b] = *SDL_modelist[i][j]; - saved_mode[b] = SDL_vgamode[i][j]; - SDL_modelist[i][j]->w = modeinfo->width; - SDL_modelist[i][j]->h = modeinfo->height; - SDL_vgamode[i][j] = mode; - /* Everybody scoot down! */ - if (saved_rect[b].w && saved_rect[b].h) { - for (++j; SDL_modelist[i][j]->w; ++j) { - saved_rect[!b] = *SDL_modelist[i][j]; - saved_mode[!b] = SDL_vgamode[i][j]; - *SDL_modelist[i][j] = saved_rect[b]; - SDL_vgamode[i][j] = saved_mode[b]; - b = !b; - } - *SDL_modelist[i][j] = saved_rect[b]; - SDL_vgamode[i][j] = saved_mode[b]; - } - } else { - ++SDL_nummodes[i]; - } - return (1); -} - -static void -SVGA_UpdateVideoInfo(_THIS) -{ - vga_modeinfo *modeinfo; - - this->info.wm_available = 0; - this->info.hw_available = (banked ? 0 : 1); - modeinfo = vga_getmodeinfo(vga_getcurrentmode()); - this->info.video_mem = modeinfo->memory; - /* FIXME: Add hardware accelerated blit information */ -#ifdef SVGALIB_DEBUG - printf("Hardware accelerated blit: %savailable\n", - modeinfo->haveblit ? "" : "not "); -#endif -} - -int -SVGA_VideoInit(_THIS, SDL_PixelFormat * vformat) -{ - int keyboard; - int i, j; - int mode, total_modes; - - /* Initialize all variables that we clean on shutdown */ - for (i = 0; i < NUM_MODELISTS; ++i) { - SDL_nummodes[i] = 0; - SDL_modelist[i] = NULL; - SDL_vgamode[i] = NULL; - } - - /* Initialize the library */ - vga_disabledriverreport(); - if (vga_init() < 0) { - SDL_SetError("Unable to initialize SVGAlib"); - return (-1); - } - vga_setmode(TEXT); - - /* Enable mouse and keyboard support */ - vga_setmousesupport(1); - keyboard = keyboard_init_return_fd(); - if (keyboard < 0) { - SDL_SetError("Unable to initialize keyboard"); - return (-1); - } - if (SVGA_initkeymaps(keyboard) < 0) { - return (-1); - } - keyboard_seteventhandler(SVGA_keyboardcallback); - - /* Determine the current screen size */ - this->info.current_w = 0; - this->info.current_h = 0; - - /* Determine the screen depth (use default 8-bit depth) */ - vformat->BitsPerPixel = 8; - - /* Enumerate the available fullscreen modes */ - total_modes = 0; - for (mode = vga_lastmodenumber(); mode; --mode) { - if (vga_hasmode(mode)) { - if (SVGA_AddMode(this, mode, 0)) { - ++total_modes; - } - } - } - if (SVGA_AddMode(this, G320x200x256, 0)) - ++total_modes; - if (total_modes == 0) { - SDL_SetError("No linear video modes available"); - return (-1); - } - for (i = 0; i < NUM_MODELISTS; ++i) { - SDL_vgamode[i] = (int *) SDL_malloc(SDL_nummodes[i] * sizeof(int)); - if (SDL_vgamode[i] == NULL) { - SDL_OutOfMemory(); - return (-1); - } - SDL_modelist[i] = (SDL_Rect **) - SDL_malloc((SDL_nummodes[i] + 1) * sizeof(SDL_Rect *)); - if (SDL_modelist[i] == NULL) { - SDL_OutOfMemory(); - return (-1); - } - for (j = 0; j < SDL_nummodes[i]; ++j) { - SDL_modelist[i][j] = (SDL_Rect *) SDL_malloc(sizeof(SDL_Rect)); - if (SDL_modelist[i][j] == NULL) { - SDL_OutOfMemory(); - return (-1); - } - SDL_memset(SDL_modelist[i][j], 0, sizeof(SDL_Rect)); - } - SDL_modelist[i][j] = NULL; - } - for (mode = vga_lastmodenumber(); mode; --mode) { - if (vga_hasmode(mode)) { - SVGA_AddMode(this, mode, 1); - } - } - SVGA_AddMode(this, G320x200x256, 1); - - /* Free extra (duplicated) modes */ - for (i = 0; i < NUM_MODELISTS; ++i) { - j = 0; - while (SDL_modelist[i][j] && SDL_modelist[i][j]->w) { - j++; - } - while (SDL_modelist[i][j]) { - SDL_free(SDL_modelist[i][j]); - SDL_modelist[i][j] = NULL; - j++; - } - } - - /* Fill in our hardware acceleration capabilities */ - SVGA_UpdateVideoInfo(this); - - /* We're done! */ - return (0); -} - -SDL_Rect ** -SVGA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) -{ - return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]); -} - -/* Various screen update functions available */ -static void SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); -static void SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect * rects); - -SDL_Surface * -SVGA_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) -{ - int mode; - int vgamode; - vga_modeinfo *modeinfo; - int screenpage_len; - - /* Free old pixels if we were in banked mode */ - if (banked && current->pixels) { - free(current->pixels); - current->pixels = NULL; - } - - /* Try to set the requested linear video mode */ - bpp = (bpp + 7) / 8 - 1; - for (mode = 0; SDL_modelist[bpp][mode]; ++mode) { - if ((SDL_modelist[bpp][mode]->w == width) && - (SDL_modelist[bpp][mode]->h == height)) { - break; - } - } - if (SDL_modelist[bpp][mode] == NULL) { - SDL_SetError("Couldn't find requested mode in list"); - return (NULL); - } - vgamode = SDL_vgamode[bpp][mode]; - vga_setmode(vgamode); - vga_setpage(0); - - if ((vga_setlinearaddressing() < 0) && (vgamode != G320x200x256)) { - banked = 1; - } else { - banked = 0; - } - - modeinfo = vga_getmodeinfo(SDL_vgamode[bpp][mode]); - - /* Update hardware acceleration info */ - SVGA_UpdateVideoInfo(this); - - /* Allocate the new pixel format for the screen */ - bpp = (bpp + 1) * 8; - if ((bpp == 16) && (modeinfo->colors == 32768)) { - bpp = 15; - } - if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) { - return (NULL); - } - - /* Set up the new mode framebuffer */ - current->flags = SDL_FULLSCREEN; - if (!banked) { - current->flags |= SDL_HWSURFACE; - } - if (bpp == 8) { - /* FIXME: What about DirectColor? */ - current->flags |= SDL_HWPALETTE; - } - current->w = width; - current->h = height; - current->pitch = modeinfo->linewidth; - if (banked) { - current->pixels = SDL_malloc(current->h * current->pitch); - if (!current->pixels) { - SDL_OutOfMemory(); - return (NULL); - } - } else { - current->pixels = vga_getgraphmem(); - } - - /* set double-buffering */ - if ((flags & SDL_DOUBLEBUF) && !banked) { - /* length of one screen page in bytes */ - screenpage_len = current->h * modeinfo->linewidth; - - /* if start address should be aligned */ - if (modeinfo->linewidth_unit) { - if (screenpage_len % modeinfo->linewidth_unit) { - screenpage_len += - modeinfo->linewidth_unit - - (screenpage_len % modeinfo->linewidth_unit); - } - } - - /* if we heve enough videomemory = ak je dost videopamete */ - if (modeinfo->memory > (screenpage_len * 2 / 1024)) { - current->flags |= SDL_DOUBLEBUF; - flip_page = 0; - flip_offset[0] = 0; - flip_offset[1] = screenpage_len; - flip_address[0] = vga_getgraphmem(); - flip_address[1] = flip_address[0] + screenpage_len; - SVGA_FlipHWSurface(this, current); - } - } - - /* Set the blit function */ - if (banked) { - this->UpdateRects = SVGA_BankedUpdate; - } else { - this->UpdateRects = SVGA_DirectUpdate; - } - - /* Set up the mouse handler again (buggy SVGAlib 1.40) */ - mouse_seteventhandler(SVGA_mousecallback); - - /* We're done */ - return (current); -} - -/* We don't actually allow hardware surfaces other than the main one */ -static int -SVGA_AllocHWSurface(_THIS, SDL_Surface * surface) -{ - return (-1); -} - -static void -SVGA_FreeHWSurface(_THIS, SDL_Surface * surface) -{ - return; -} - -/* We need to wait for vertical retrace on page flipped displays */ -static int -SVGA_LockHWSurface(_THIS, SDL_Surface * surface) -{ - /* The waiting is done in SVGA_FlipHWSurface() */ - return (0); -} - -static void -SVGA_UnlockHWSurface(_THIS, SDL_Surface * surface) -{ - return; -} - -static int -SVGA_FlipHWSurface(_THIS, SDL_Surface * surface) -{ - if (!banked) { - vga_setdisplaystart(flip_offset[flip_page]); - flip_page = !flip_page; - surface->pixels = flip_address[flip_page]; - vga_waitretrace(); - } - return (0); -} - -static void -SVGA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) -{ - return; -} - -static void -SVGA_BankedUpdate(_THIS, int numrects, SDL_Rect * rects) -{ - int i, j; - SDL_Rect *rect; - int page, vp; - int x, y, w, h; - unsigned char *src; - unsigned char *dst; - int bpp = this->screen->format->BytesPerPixel; - int pitch = this->screen->pitch; - - dst = vga_getgraphmem(); - for (i = 0; i < numrects; ++i) { - rect = &rects[i]; - x = rect->x; - y = rect->y; - w = rect->w * bpp; - h = rect->h; - - vp = y * pitch + x * bpp; - src = (unsigned char *) this->screen->pixels + vp; - page = vp >> 16; - vp &= 0xffff; - vga_setpage(page); - for (j = 0; j < h; j++) { - if (vp + w > 0x10000) { - if (vp >= 0x10000) { - page++; - vga_setpage(page); - vp &= 0xffff; - } else { - SDL_memcpy(dst + vp, src, 0x10000 - vp); - page++; - vga_setpage(page); - SDL_memcpy(dst, src + 0x10000 - vp, (vp + w) & 0xffff); - vp = (vp + pitch) & 0xffff; - src += pitch; - continue; - } - } - SDL_memcpy(dst + vp, src, w); - src += pitch; - vp += pitch; - } - } -} - -int -SVGA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) -{ - int i; - - for (i = 0; i < ncolors; i++) { - vga_setpalette(firstcolor + i, - colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2); - } - return (1); -} - -/* Note: If we are terminated, this could be called in the middle of - another SDL video routine -- notably UpdateRects. -*/ -void -SVGA_VideoQuit(_THIS) -{ - int i, j; - - /* Reset the console video mode */ - if (this->screen && (this->screen->w && this->screen->h)) { - vga_setmode(TEXT); - } - keyboard_close(); - - /* Free video mode lists */ - for (i = 0; i < NUM_MODELISTS; ++i) { - if (SDL_modelist[i] != NULL) { - for (j = 0; SDL_modelist[i][j]; ++j) - SDL_free(SDL_modelist[i][j]); - SDL_free(SDL_modelist[i]); - SDL_modelist[i] = NULL; - } - if (SDL_vgamode[i] != NULL) { - SDL_free(SDL_vgamode[i]); - SDL_vgamode[i] = NULL; - } - } - if (this->screen) { - if (banked && this->screen->pixels) { - SDL_free(this->screen->pixels); - } - this->screen->pixels = NULL; - } -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/svga/SDL_svgavideo.h b/project/jni/sdl-1.3/src/video/svga/SDL_svgavideo.h deleted file mode 100644 index 85bb7f87e..000000000 --- a/project/jni/sdl-1.3/src/video/svga/SDL_svgavideo.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_svgavideo_h -#define _SDL_svgavideo_h - -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *this - -/* Private display data */ -struct SDL_PrivateVideoData -{ -#define NUM_MODELISTS 4 /* 8, 16, 24, and 32 bits-per-pixel */ - int SDL_nummodes[NUM_MODELISTS]; - SDL_Rect **SDL_modelist[NUM_MODELISTS]; - int *SDL_vgamode[NUM_MODELISTS]; - - /* information for double-buffering */ - int flip_page; - int flip_offset[2]; - Uint8 *flip_address[2]; - - /* Set to 1 if we're in banked video mode */ - int banked; -}; -/* Old variable names */ -#define SDL_nummodes (this->hidden->SDL_nummodes) -#define SDL_modelist (this->hidden->SDL_modelist) -#define SDL_vgamode (this->hidden->SDL_vgamode) -#define flip_page (this->hidden->flip_page) -#define flip_offset (this->hidden->flip_offset) -#define flip_address (this->hidden->flip_address) -#define banked (this->hidden->banked) - -#endif /* _SDL_svgavideo_h */ -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitappdelegate.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitappdelegate.h index 359d37774..6668d1aa1 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitappdelegate.h +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitappdelegate.h @@ -1,33 +1,32 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #import -#import "SDL_uikitopenglview.h" -/* *INDENT-OFF* */ -@interface SDLUIKitDelegate:NSObject { +@interface SDLUIKitDelegate : NSObject { } -+(SDLUIKitDelegate *)sharedAppDelegate; ++ (id) sharedAppDelegate; ++ (NSString *)getAppDelegateClassName; @end -/* *INDENT-ON* */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitappdelegate.m b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitappdelegate.m index 5b18e27f2..5b7965562 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitappdelegate.m +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitappdelegate.m @@ -1,26 +1,31 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #import "../SDL_sysvideo.h" +#import "SDL_assert.h" +#import "SDL_hints.h" +#import "../../SDL_hints_c.h" #import "SDL_uikitappdelegate.h" #import "SDL_uikitopenglview.h" @@ -34,72 +39,93 @@ extern int SDL_main(int argc, char *argv[]); static int forward_argc; static char **forward_argv; +static int exit_status; -int main(int argc, char **argv) { +int main(int argc, char **argv) +{ + int i; + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - int i; - NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - - /* store arguments */ - forward_argc = argc; - forward_argv = (char **)malloc((argc+1) * sizeof(char *)); - for (i=0; inum_displays; i++) { - const SDL_VideoDisplay *display = &_this->displays[i]; - SDL_Window *window; - for (window = display->windows; window != nil; window = window->next) { - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); - } + SDL_Window *window; + for (window = _this->windows; window != nil; window = window->next) { + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_MINIMIZED, 0, 0); } } @@ -132,14 +154,14 @@ afterDelay:0.0]; return; } - int i; - for (i = 0; i < _this->num_displays; i++) { - const SDL_VideoDisplay *display = &_this->displays[i]; - SDL_Window *window; - for (window = display->windows; window != nil; window = window->next) { - SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); - } + SDL_Window *window; + for (window = _this->windows; window != nil; window = window->next) { + SDL_SendWindowEvent(window, SDL_WINDOWEVENT_RESTORED, 0, 0); } } @end + +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitevents.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitevents.h index 2df18b11c..23e3d1385 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitevents.h +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitevents.h @@ -1,28 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" +#ifndef _SDL_uikitevents_h +#define _SDL_uikitevents_h -#include "SDL_uikitvideo.h" +#include "../SDL_sysvideo.h" extern void UIKit_PumpEvents(_THIS); +#endif /* _SDL_uikitevents_h */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitevents.m b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitevents.m index 12b1e281b..fb91ba233 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitevents.m +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitevents.m @@ -1,27 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "../../events/SDL_sysevents.h" +#if SDL_VIDEO_DRIVER_UIKIT + #include "../../events/SDL_events_c.h" #include "SDL_uikitvideo.h" @@ -33,25 +33,26 @@ void UIKit_PumpEvents(_THIS) { - /* - When the user presses the 'home' button on the iPod - the application exits -- immediatly. - - Unlike in Mac OS X, it appears there is no way to cancel the termination. - - This doesn't give the SDL user's application time to respond to an SDL_Quit event. - So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate), - when the delegate receives the ApplicationWillTerminate message, we execute - a longjmp statement to get back here, preventing an immediate exit. - */ - if (setjmp(*jump_env()) == 0) { - /* if we're setting the jump, rather than jumping back */ - SInt32 result; - do { - result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE); - } while(result == kCFRunLoopRunHandledSource); - } + /* + When the user presses the 'home' button on the iPod + the application exits -- immediatly. + Unlike in Mac OS X, it appears there is no way to cancel the termination. + + This doesn't give the SDL user's application time to respond to an SDL_Quit event. + So what we do is that in the UIApplicationDelegate class (SDLUIApplicationDelegate), + when the delegate receives the ApplicationWillTerminate message, we execute + a longjmp statement to get back here, preventing an immediate exit. + */ + if (setjmp(*jump_env()) == 0) { + /* if we're setting the jump, rather than jumping back */ + SInt32 result; + do { + result = CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0, TRUE); + } while (result == kCFRunLoopRunHandledSource); + } } +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitkeyboard.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitkeyboard.h index 1ebda908b..700c173c7 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitkeyboard.h +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitkeyboard.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef sdl_uikitkeyboard_h @@ -29,3 +28,5 @@ extern DECLSPEC SDL_bool SDLCALL SDL_iPhoneKeyboardIsShown(SDL_Window * window); extern DECLSPEC int SDLCALL SDL_iPhoneKeyboardToggle(SDL_Window * window); #endif + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopengles.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopengles.h index 2e971db28..16d538a49 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopengles.h +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopengles.h @@ -1,31 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ - -#include "SDL_config.h" - #ifndef _SDL_uikitopengles #define _SDL_uikitopengles -#include "SDL_uikitvideo.h" +#include "../SDL_sysvideo.h" extern int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context); @@ -36,3 +32,5 @@ extern void *UIKit_GL_GetProcAddress(_THIS, const char *proc); extern int UIKit_GL_LoadLibrary(_THIS, const char *path); #endif + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopengles.m b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopengles.m index 8d9839daf..85ce14d0a 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopengles.m +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopengles.m @@ -1,24 +1,26 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - */ + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #include "SDL_uikitopengles.h" #include "SDL_uikitopenglview.h" @@ -28,6 +30,7 @@ #include "SDL_sysvideo.h" #include "../../events/SDL_keyboard_c.h" #include "../../events/SDL_mouse_c.h" +#include "../../power/uikit/SDL_syspower.h" #include "SDL_loadso.h" #include @@ -35,114 +38,119 @@ static int UIKit_GL_Initialize(_THIS); void * UIKit_GL_GetProcAddress(_THIS, const char *proc) -{ - /* Look through all SO's for the proc symbol. Here's why: - -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator. - -We don't know that the path won't change in the future. - */ - return SDL_LoadFunction(RTLD_DEFAULT, proc); +{ + /* Look through all SO's for the proc symbol. Here's why: + -Looking for the path to the OpenGL Library seems not to work in the iPhone Simulator. + -We don't know that the path won't change in the future. + */ + return dlsym(RTLD_DEFAULT, proc); } /* - note that SDL_GL_Delete context makes it current without passing the window + note that SDL_GL_Delete context makes it current without passing the window */ int UIKit_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) { - - if (context) { - SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - [data->view setCurrentContext]; - } - else { - [EAGLContext setCurrentContext: nil]; - } - + if (context) { + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + [data->view setCurrentContext]; + } + else { + [EAGLContext setCurrentContext: nil]; + } + return 0; } int UIKit_GL_LoadLibrary(_THIS, const char *path) { - /* - shouldn't be passing a path into this function - why? Because we've already loaded the library - and because the SDK forbids loading an external SO - */ + /* + shouldn't be passing a path into this function + why? Because we've already loaded the library + and because the SDK forbids loading an external SO + */ if (path != NULL) { - SDL_SetError("iPhone GL Load Library just here for compatibility"); - return -1; + SDL_SetError("iPhone GL Load Library just here for compatibility"); + return -1; } return 0; } -extern void SDL_UIKit_UpdateBatteryMonitoring(void); - void UIKit_GL_SwapWindow(_THIS, SDL_Window * window) { - #ifdef SDL_POWER_UIKIT +#if SDL_POWER_UIKIT // Check once a frame to see if we should turn off the battery monitor. SDL_UIKit_UpdateBatteryMonitoring(); - #endif +#endif - SDL_WindowData *data = (SDL_WindowData *)window->driverdata; - - if (nil == data->view) { - return; - } - [data->view swapBuffers]; - /* since now we've got something to draw - make the window visible */ - [data->uiwindow makeKeyAndVisible]; + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + + if (nil == data->view) { + return; + } + [data->view swapBuffers]; + /* since now we've got something to draw + make the window visible */ + [data->uiwindow makeKeyAndVisible]; + + /* we need to let the event cycle run, or the OS won't update the OpenGL view! */ + SDL_PumpEvents(); - /* we need to let the event cycle run, or the OS won't update the OpenGL view! */ - SDL_PumpEvents(); - } SDL_GLContext UIKit_GL_CreateContext(_THIS, SDL_Window * window) { - SDL_uikitopenglview *view; - SDL_WindowData *data = (SDL_WindowData *) window->driverdata; - UIScreen *uiscreen = (UIScreen *) window->display->driverdata; - UIWindow *uiwindow = data->uiwindow; + SDL_uikitopenglview *view; + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + UIWindow *uiwindow = data->uiwindow; /* construct our view, passing in SDL's OpenGL configuration data */ - view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds] \ - retainBacking: _this->gl_config.retained_backing \ - rBits: _this->gl_config.red_size \ - gBits: _this->gl_config.green_size \ - bBits: _this->gl_config.blue_size \ - aBits: _this->gl_config.alpha_size \ - depthBits: _this->gl_config.depth_size]; - - data->view = view; - - /* add the view to our window */ - [uiwindow addSubview: view ]; - - /* Don't worry, the window retained the view */ - [view release]; - - if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) { + view = [[SDL_uikitopenglview alloc] initWithFrame: [uiwindow bounds] + retainBacking: _this->gl_config.retained_backing + rBits: _this->gl_config.red_size + gBits: _this->gl_config.green_size + bBits: _this->gl_config.blue_size + aBits: _this->gl_config.alpha_size + depthBits: _this->gl_config.depth_size + stencilBits: _this->gl_config.stencil_size + majorVersion: _this->gl_config.major_version]; + + data->view = view; + view->viewcontroller = data->viewcontroller; + if (view->viewcontroller != nil) { + [view->viewcontroller setView:view]; + [view->viewcontroller retain]; + } + + /* add the view to our window */ + [uiwindow addSubview: view ]; + + if ( UIKit_GL_MakeCurrent(_this, window, view) < 0 ) { UIKit_GL_DeleteContext(_this, view); return NULL; } - /* Make this window the current mouse focus for touch input */ - SDL_SetMouseFocus(window); - SDL_SetKeyboardFocus(window); + /* Make this window the current mouse focus for touch input */ + /* !!! FIXME: only do this if this is the primary screen. */ + SDL_SetMouseFocus(window); + SDL_SetKeyboardFocus(window); - return view; + return view; } void UIKit_GL_DeleteContext(_THIS, SDL_GLContext context) { - /* the delegate has retained the view, this will release him */ - SDL_uikitopenglview *view = (SDL_uikitopenglview *)context; - /* this will also delete it */ - [view removeFromSuperview]; - - return; + /* the delegate has retained the view, this will release him */ + SDL_uikitopenglview *view = (SDL_uikitopenglview *)context; + if (view->viewcontroller) { + [view->viewcontroller setView:nil]; + [view->viewcontroller release]; + } + [view removeFromSuperview]; + [view release]; } +#endif /* SDL_VIDEO_DRIVER_UIKIT */ +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopenglview.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopenglview.h index 62d9beee4..71edf55ae 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopenglview.h +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopenglview.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #import @@ -26,26 +25,27 @@ #import #import "SDL_uikitview.h" /* - This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. - The view content is basically an EAGL surface you render your OpenGL scene into. - Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. + This class wraps the CAEAGLLayer from CoreAnimation into a convenient UIView subclass. + The view content is basically an EAGL surface you render your OpenGL scene into. + Note that setting the view non-opaque will only work if the EAGL surface has an alpha channel. */ -/* *INDENT-OFF* */ @interface SDL_uikitopenglview : SDL_uikitview { - + @private - /* The pixel dimensions of the backbuffer */ - GLint backingWidth; - GLint backingHeight; - - EAGLContext *context; - - /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ - GLuint viewRenderbuffer, viewFramebuffer; - - /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ - GLuint depthRenderbuffer; - + /* The pixel dimensions of the backbuffer */ + GLint backingWidth; + GLint backingHeight; + + EAGLContext *context; + + /* OpenGL names for the renderbuffer and framebuffers used to render to this view */ + GLuint viewRenderbuffer, viewFramebuffer; + + /* OpenGL name for the depth buffer that is attached to viewFramebuffer, if it exists (0 if it does not exist) */ + GLuint depthRenderbuffer; + + /* format of depthRenderbuffer */ + GLenum depthBufferFormat; } @property (nonatomic, retain, readonly) EAGLContext *context; @@ -54,12 +54,17 @@ - (void)setCurrentContext; - (id)initWithFrame:(CGRect)frame - retainBacking:(BOOL)retained \ - rBits:(int)rBits \ - gBits:(int)gBits \ - bBits:(int)bBits \ - aBits:(int)aBits \ - depthBits:(int)depthBits; + retainBacking:(BOOL)retained + rBits:(int)rBits + gBits:(int)gBits + bBits:(int)bBits + aBits:(int)aBits + depthBits:(int)depthBits + stencilBits:(int)stencilBits + majorVersion:(int)majorVersion; + +- (void)updateFrame; @end -/* *INDENT-ON* */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopenglview.m b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopenglview.m index bcf892c24..fb06d4ed0 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopenglview.m +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitopenglview.m @@ -1,164 +1,195 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - */ + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #import #import #import "SDL_uikitopenglview.h" -@interface SDL_uikitopenglview (privateMethods) - -- (BOOL) createFramebuffer; -- (void) destroyFramebuffer; - -@end - @implementation SDL_uikitopenglview @synthesize context; -+ (Class)layerClass { - return [CAEAGLLayer class]; -} - -- (id)initWithFrame:(CGRect)frame \ - retainBacking:(BOOL)retained \ - rBits:(int)rBits \ - gBits:(int)gBits \ - bBits:(int)bBits \ - aBits:(int)aBits \ - depthBits:(int)depthBits \ ++ (Class)layerClass { - - NSString *colorFormat=nil; - GLuint depthBufferFormat; - BOOL useDepthBuffer; - - if (rBits == 8 && gBits == 8 && bBits == 8) { - /* if user specifically requests rbg888 or some color format higher than 16bpp */ - colorFormat = kEAGLColorFormatRGBA8; - } - else { - /* default case (faster) */ - colorFormat = kEAGLColorFormatRGB565; - } - - if (depthBits == 24) { - useDepthBuffer = YES; - depthBufferFormat = GL_DEPTH_COMPONENT24_OES; - } - else if (depthBits == 0) { - useDepthBuffer = NO; - } - else { - /* default case when depth buffer is not disabled */ - /* - strange, even when we use this, we seem to get a 24 bit depth buffer on iPhone. - perhaps that's the only depth format iPhone actually supports - */ - useDepthBuffer = YES; - depthBufferFormat = GL_DEPTH_COMPONENT16_OES; - } - - if ((self = [super initWithFrame:frame])) { - // Get the layer - CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; - - eaglLayer.opaque = YES; - eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: - [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil]; - - context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1]; - - if (!context || ![EAGLContext setCurrentContext:context]) { - [self release]; - return nil; - } - - /* create the buffers */ - glGenFramebuffersOES(1, &viewFramebuffer); - glGenRenderbuffersOES(1, &viewRenderbuffer); - - glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); - [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); - - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); - glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); - - if (useDepthBuffer) { - glGenRenderbuffersOES(1, &depthRenderbuffer); - glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); - glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); - glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); - } - - if(glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { - return NO; - } - /* end create buffers */ - } - return self; + return [CAEAGLLayer class]; } -- (void)setCurrentContext { - [EAGLContext setCurrentContext:context]; +- (id)initWithFrame:(CGRect)frame + retainBacking:(BOOL)retained + rBits:(int)rBits + gBits:(int)gBits + bBits:(int)bBits + aBits:(int)aBits + depthBits:(int)depthBits + stencilBits:(int)stencilBits + majorVersion:(int)majorVersion +{ + depthBufferFormat = 0; + + if ((self = [super initWithFrame:frame])) { + const BOOL useStencilBuffer = (stencilBits != 0); + const BOOL useDepthBuffer = (depthBits != 0); + NSString *colorFormat = nil; + + if (rBits == 8 && gBits == 8 && bBits == 8) { + /* if user specifically requests rbg888 or some color format higher than 16bpp */ + colorFormat = kEAGLColorFormatRGBA8; + } else { + /* default case (faster) */ + colorFormat = kEAGLColorFormatRGB565; + } + + /* Get the layer */ + CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer; + + eaglLayer.opaque = YES; + eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys: + [NSNumber numberWithBool: retained], kEAGLDrawablePropertyRetainedBacking, colorFormat, kEAGLDrawablePropertyColorFormat, nil]; + + if (majorVersion > 1) { + context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES2]; + } else { + context = [[EAGLContext alloc] initWithAPI: kEAGLRenderingAPIOpenGLES1]; + } + if (!context || ![EAGLContext setCurrentContext:context]) { + [self release]; + return nil; + } + + // !!! FIXME: use the screen this is on! + /* Use the main screen scale (for retina display support) */ + if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)]) + self.contentScaleFactor = [UIScreen mainScreen].scale; + + /* create the buffers */ + glGenFramebuffersOES(1, &viewFramebuffer); + glGenRenderbuffersOES(1, &viewRenderbuffer); + + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); + + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + + if ((useDepthBuffer) || (useStencilBuffer)) { + if (useStencilBuffer) { + /* Apparently you need to pack stencil and depth into one buffer. */ + depthBufferFormat = GL_DEPTH24_STENCIL8_OES; + } else if (useDepthBuffer) { + /* iOS only has 24-bit depth buffers, even with GL_DEPTH_COMPONENT16_OES */ + depthBufferFormat = GL_DEPTH_COMPONENT24_OES; + } + + glGenRenderbuffersOES(1, &depthRenderbuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); + glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); + if (useDepthBuffer) { + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_DEPTH_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); + } + if (useStencilBuffer) { + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_STENCIL_ATTACHMENT_OES, GL_RENDERBUFFER_OES, depthRenderbuffer); + } + } + + if (glCheckFramebufferStatusOES(GL_FRAMEBUFFER_OES) != GL_FRAMEBUFFER_COMPLETE_OES) { + return NO; + } + /* end create buffers */ + + self.autoresizingMask = 0; // don't allow autoresize, since we need to do some magic in -(void)updateFrame. + } + return self; +} + +- (void)updateFrame +{ + glBindFramebufferOES(GL_FRAMEBUFFER_OES, viewFramebuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, 0); + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, 0); + glDeleteRenderbuffersOES(1, &viewRenderbuffer); + + glGenRenderbuffersOES(1, &viewRenderbuffer); + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context renderbufferStorage:GL_RENDERBUFFER_OES fromDrawable:(CAEAGLLayer*)self.layer]; + glFramebufferRenderbufferOES(GL_FRAMEBUFFER_OES, GL_COLOR_ATTACHMENT0_OES, GL_RENDERBUFFER_OES, viewRenderbuffer); + + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_WIDTH_OES, &backingWidth); + glGetRenderbufferParameterivOES(GL_RENDERBUFFER_OES, GL_RENDERBUFFER_HEIGHT_OES, &backingHeight); + + if (depthRenderbuffer != 0) { + glBindRenderbufferOES(GL_RENDERBUFFER_OES, depthRenderbuffer); + glRenderbufferStorageOES(GL_RENDERBUFFER_OES, depthBufferFormat, backingWidth, backingHeight); + } +} + +- (void)setCurrentContext +{ + [EAGLContext setCurrentContext:context]; } -- (void)swapBuffers { - glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); - [context presentRenderbuffer:GL_RENDERBUFFER_OES]; +- (void)swapBuffers +{ + glBindRenderbufferOES(GL_RENDERBUFFER_OES, viewRenderbuffer); + [context presentRenderbuffer:GL_RENDERBUFFER_OES]; } -- (void)layoutSubviews { - [EAGLContext setCurrentContext:context]; +- (void)layoutSubviews +{ + [EAGLContext setCurrentContext:context]; } -- (void)destroyFramebuffer { - - glDeleteFramebuffersOES(1, &viewFramebuffer); - viewFramebuffer = 0; - glDeleteRenderbuffersOES(1, &viewRenderbuffer); - viewRenderbuffer = 0; - - if (depthRenderbuffer) { - glDeleteRenderbuffersOES(1, &depthRenderbuffer); - depthRenderbuffer = 0; - } +- (void)destroyFramebuffer +{ + glDeleteFramebuffersOES(1, &viewFramebuffer); + viewFramebuffer = 0; + glDeleteRenderbuffersOES(1, &viewRenderbuffer); + viewRenderbuffer = 0; + + if (depthRenderbuffer) { + glDeleteRenderbuffersOES(1, &depthRenderbuffer); + depthRenderbuffer = 0; + } } -- (void)dealloc { - - [self destroyFramebuffer]; - if ([EAGLContext currentContext] == context) { - [EAGLContext setCurrentContext:nil]; - } - [context release]; - [super dealloc]; - +- (void)dealloc +{ + [self destroyFramebuffer]; + if ([EAGLContext currentContext] == context) { + [EAGLContext setCurrentContext:nil]; + } + [context release]; + [super dealloc]; } @end + +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitvideo.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitvideo.h index 398749a3b..5a1eb42e9 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitvideo.h +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitvideo.h @@ -1,31 +1,26 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" - #ifndef _SDL_uikitvideo_h #define _SDL_uikitvideo_h -#include "../SDL_sysvideo.h" - #include extern BOOL SDL_UIKit_supports_multiple_displays; diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitvideo.m b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitvideo.m index 1d9a6e75a..354e35fb4 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitvideo.m +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitvideo.m @@ -1,29 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #import -#include "SDL_config.h" - #include "SDL_video.h" #include "SDL_mouse.h" #include "../SDL_sysvideo.h" @@ -35,9 +35,6 @@ #include "SDL_uikitwindow.h" #include "SDL_uikitopengles.h" -#include "SDL_renderer_sw.h" -#include "SDL_renderer_gles.h" - #include "SDL_assert.h" #define UIKITVID_DRIVER_NAME "uikit" @@ -56,7 +53,7 @@ BOOL SDL_UIKit_supports_multiple_displays = NO; static int UIKit_Available(void) { - return (1); + return 1; } static void UIKit_DeleteDevice(SDL_VideoDevice * device) @@ -85,21 +82,23 @@ UIKit_CreateDevice(int devindex) device->GetDisplayModes = UIKit_GetDisplayModes; device->SetDisplayMode = UIKit_SetDisplayMode; device->PumpEvents = UIKit_PumpEvents; - device->CreateWindow = UIKit_CreateWindow; - device->DestroyWindow = UIKit_DestroyWindow; - - - /* OpenGL (ES) functions */ - device->GL_MakeCurrent = UIKit_GL_MakeCurrent; - device->GL_SwapWindow = UIKit_GL_SwapWindow; - device->GL_CreateContext = UIKit_GL_CreateContext; - device->GL_DeleteContext = UIKit_GL_DeleteContext; - device->GL_GetProcAddress = UIKit_GL_GetProcAddress; - device->GL_LoadLibrary = UIKit_GL_LoadLibrary; - device->free = UIKit_DeleteDevice; + device->CreateWindow = UIKit_CreateWindow; + device->SetWindowFullscreen = UIKit_SetWindowFullscreen; + device->DestroyWindow = UIKit_DestroyWindow; + device->GetWindowWMInfo = UIKit_GetWindowWMInfo; + + + /* OpenGL (ES) functions */ + device->GL_MakeCurrent = UIKit_GL_MakeCurrent; + device->GL_SwapWindow = UIKit_GL_SwapWindow; + device->GL_CreateContext = UIKit_GL_CreateContext; + device->GL_DeleteContext = UIKit_GL_DeleteContext; + device->GL_GetProcAddress = UIKit_GL_GetProcAddress; + device->GL_LoadLibrary = UIKit_GL_LoadLibrary; + device->free = UIKit_DeleteDevice; + + device->gl_config.accelerated = 1; - device->gl_config.accelerated = 1; - return device; } @@ -133,27 +132,36 @@ UIKit_GetDisplayModes(_THIS, SDL_VideoDisplay * display) if (!SDL_UIKit_supports_multiple_displays) { const CGRect rect = [uiscreen bounds]; mode.format = SDL_PIXELFORMAT_ABGR8888; - mode.w = (int) rect.size.width; - mode.h = (int) rect.size.height; mode.refresh_rate = 0; mode.driverdata = NULL; + + mode.w = (int) rect.size.width; + mode.h = (int) rect.size.height; + SDL_AddDisplayMode(display, &mode); + + mode.w = (int) rect.size.height; // swap the orientation, add again. + mode.h = (int) rect.size.width; SDL_AddDisplayMode(display, &mode); return; } - const NSArray *modes = [uiscreen availableModes]; - const NSUInteger mode_count = [modes count]; - NSUInteger i; - for (i = 0; i < mode_count; i++) { - UIScreenMode *uimode = (UIScreenMode *) [modes objectAtIndex:i]; - const CGSize size = [uimode size]; + for (UIScreenMode *uimode in [uiscreen availableModes]) { + CGSize size = [uimode size]; mode.format = SDL_PIXELFORMAT_ABGR8888; - mode.w = (int) size.width; - mode.h = (int) size.height; mode.refresh_rate = 0; mode.driverdata = uimode; - [uimode retain]; - SDL_AddDisplayMode(display, &mode); + mode.w = (int) size.width; + mode.h = (int) size.height; + if (SDL_AddDisplayMode(display, &mode)) + [uimode retain]; // retain is needed because of mode.driverdata + + if (uiscreen == [UIScreen mainScreen]) { + // Add the mode with swapped width/height + mode.w = (int) size.height; + mode.h = (int) size.width; + if (SDL_AddDisplayMode(display, &mode)) + [uimode retain]; + } } } @@ -169,6 +177,15 @@ UIKit_AddDisplay(UIScreen *uiscreen, int w, int h) mode.h = h; mode.refresh_rate = 0; + // UIScreenMode showed up in 3.2 (the iPad and later). We're + // misusing this supports_multiple_displays flag here for that. + if (SDL_UIKit_supports_multiple_displays) { + UIScreenMode *uimode = [uiscreen currentMode]; + [uimode retain]; // once for the desktop_mode + [uimode retain]; // once for the current_mode + mode.driverdata = uimode; + } + SDL_zero(display); display.desktop_mode = mode; display.current_mode = mode; @@ -184,28 +201,24 @@ UIKit_VideoInit(_THIS) { _this->gl_config.driver_loaded = 1; - NSString *reqSysVer = @"3.2"; - NSString *currSysVer = [[UIDevice currentDevice] systemVersion]; - if ([currSysVer compare:reqSysVer options:NSNumericSearch] != NSOrderedAscending) - SDL_UIKit_supports_multiple_displays = YES; + // this tells us whether we are running on ios >= 3.2 + SDL_UIKit_supports_multiple_displays = [UIScreen instancesRespondToSelector:@selector(currentMode)]; + + // Add the main screen. + UIScreen *uiscreen = [UIScreen mainScreen]; + const CGSize size = [uiscreen bounds].size; + UIKit_AddDisplay(uiscreen, (int)size.width, (int)size.height); // If this is iPhoneOS < 3.2, all devices are one screen, 320x480 pixels. // The iPad added both a larger main screen and the ability to use - // external displays. - if (!SDL_UIKit_supports_multiple_displays) { - // Just give 'em the whole main screen. - UIScreen *uiscreen = [UIScreen mainScreen]; - const CGRect rect = [uiscreen bounds]; - UIKit_AddDisplay(uiscreen, (int)rect.size.width, (int)rect.size.height); - } else { - const NSArray *screens = [UIScreen screens]; - const NSUInteger screen_count = [screens count]; - NSUInteger i; - for (i = 0; i < screen_count; i++) { - // the main screen is the first element in the array. - UIScreen *uiscreen = (UIScreen *) [screens objectAtIndex:i]; - const CGSize size = [[uiscreen currentMode] size]; - UIKit_AddDisplay(uiscreen, (int) size.width, (int) size.height); + // external displays. So, add the other displays (screens in UI speak). + if (SDL_UIKit_supports_multiple_displays) { + for (UIScreen *uiscreen in [UIScreen screens]) { + // Only add the other screens + if (uiscreen != [UIScreen mainScreen]) { + const CGSize size = [uiscreen bounds].size; + UIKit_AddDisplay(uiscreen, (int)size.width, (int)size.height); + } } } @@ -223,11 +236,31 @@ UIKit_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) } else { UIScreenMode *uimode = (UIScreenMode *) mode->driverdata; [uiscreen setCurrentMode:uimode]; + + CGSize size = [uimode size]; + if (size.width >= size.height) { + [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight animated:NO]; + } else { + [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO]; + } } return 0; } +static void +UIKit_ReleaseUIScreenMode(SDL_DisplayMode * mode) +{ + if (!SDL_UIKit_supports_multiple_displays) { + // Not on at least iPhoneOS 3.2 (versions prior to iPad). + SDL_assert(mode->driverdata == NULL); + } else { + UIScreenMode *uimode = (UIScreenMode *) mode->driverdata; + [uimode release]; + mode->driverdata = NULL; + } +} + void UIKit_VideoQuit(_THIS) { @@ -238,15 +271,15 @@ UIKit_VideoQuit(_THIS) UIScreen *uiscreen = (UIScreen *) display->driverdata; [uiscreen release]; display->driverdata = NULL; + UIKit_ReleaseUIScreenMode(&display->desktop_mode); + UIKit_ReleaseUIScreenMode(&display->current_mode); for (j = 0; j < display->num_display_modes; j++) { SDL_DisplayMode *mode = &display->display_modes[j]; - UIScreenMode *uimode = (UIScreenMode *) mode->driverdata; - if (uimode) { - [uimode release]; - mode->driverdata = NULL; - } + UIKit_ReleaseUIScreenMode(mode); } } } +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitview.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitview.h index 4c79268b3..862855e0d 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitview.h +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitview.h @@ -1,27 +1,26 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #import -#include "SDL_stdinc.h" -#include "SDL_events.h" +#import "SDL_uikitviewcontroller.h" #define IPHONE_TOUCH_EFFICIENT_DANGEROUS #define FIXED_MULTITOUCH @@ -30,7 +29,6 @@ #define MAX_SIMULTANEOUS_TOUCHES 5 #endif -/* *INDENT-OFF* */ #if SDL_IPHONE_KEYBOARD @interface SDL_uikitview : UIView { #else @@ -38,18 +36,21 @@ #endif #ifdef FIXED_MULTITOUCH - long touchId; + long touchId; #ifndef IPHONE_TOUCH_EFFICIENT_DANGEROUS - UITouch *finger[MAX_SIMULTANEOUS_TOUCHES]; + UITouch *finger[MAX_SIMULTANEOUS_TOUCHES]; #endif #endif #if SDL_IPHONE_KEYBOARD - UITextField *textField; - BOOL keyboardVisible; -#endif - + UITextField *textField; + BOOL keyboardVisible; +#endif + +@public + SDL_uikitviewcontroller *viewcontroller; } +- (CGPoint)touchLocation:(UITouch *)touch; - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event; @@ -59,7 +60,8 @@ - (void)hideKeyboard; - (void)initializeKeyboard; @property (readonly) BOOL keyboardVisible; -#endif +#endif @end -/* *INDENT-ON* */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitview.m b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitview.m index 74045359b..452c49a0a 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitview.m +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitview.m @@ -1,24 +1,26 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - */ + /* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT #import "SDL_uikitview.h" @@ -29,279 +31,293 @@ #if SDL_IPHONE_KEYBOARD #import "keyinfotable.h" #import "SDL_uikitappdelegate.h" +#import "SDL_uikitkeyboard.h" #import "SDL_uikitwindow.h" #endif @implementation SDL_uikitview -- (void)dealloc { +- (void)dealloc +{ + [super dealloc]; +} + +- (id)initWithFrame:(CGRect)frame +{ + self = [super initWithFrame: frame]; + #if SDL_IPHONE_KEYBOARD - [textField release]; + [self initializeKeyboard]; #endif - [super dealloc]; -} - -- (id)initWithFrame:(CGRect)frame { - - self = [super initWithFrame: frame]; - -#if SDL_IPHONE_KEYBOARD - [self initializeKeyboard]; -#endif #ifdef FIXED_MULTITOUCH - SDL_Touch touch; - touch.id = 0; //TODO: Should be -1? + self.multipleTouchEnabled = YES; - //touch.driverdata = SDL_malloc(sizeof(EventTouchData)); - //EventTouchData* data = (EventTouchData*)(touch.driverdata); - - touch.x_min = 0; - touch.x_max = frame.size.width; - touch.native_xres = touch.x_max - touch.x_min; - touch.y_min = 0; - touch.y_max = frame.size.height; - touch.native_yres = touch.y_max - touch.y_min; - touch.pressure_min = 0; - touch.pressure_max = 1; - touch.native_pressureres = touch.pressure_max - touch.pressure_min; + SDL_Touch touch; + touch.id = 0; //TODO: Should be -1? + + //touch.driverdata = SDL_malloc(sizeof(EventTouchData)); + //EventTouchData* data = (EventTouchData*)(touch.driverdata); + + touch.x_min = 0; + touch.x_max = 1; + touch.native_xres = touch.x_max - touch.x_min; + touch.y_min = 0; + touch.y_max = 1; + touch.native_yres = touch.y_max - touch.y_min; + touch.pressure_min = 0; + touch.pressure_max = 1; + touch.native_pressureres = touch.pressure_max - touch.pressure_min; - touchId = SDL_AddTouch(&touch, "IPHONE SCREEN"); + touchId = SDL_AddTouch(&touch, "IPHONE SCREEN"); #endif - return self; + return self; } -- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { +- (CGPoint)touchLocation:(UITouch *)touch +{ + CGPoint point = [touch locationInView: self]; + CGRect frame = [self frame]; - NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch = (UITouch*)[enumerator nextObject]; - - //NSLog("Click"); - - if (touch) { - CGPoint locationInView = [touch locationInView: self]; - - /* send moved event */ - SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); + frame = CGRectApplyAffineTransform(frame, [self transform]); + point.x /= frame.size.width; + point.y /= frame.size.height; + return point; +} - /* send mouse down event */ - SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); - } +- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event +{ + NSEnumerator *enumerator = [touches objectEnumerator]; + UITouch *touch = (UITouch*)[enumerator nextObject]; + + if (touch) { + CGPoint locationInView = [touch locationInView: self]; + + /* send moved event */ + SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); + + /* send mouse down event */ + SDL_SendMouseButton(NULL, SDL_PRESSED, SDL_BUTTON_LEFT); + } #ifdef FIXED_MULTITOUCH - while(touch) { - CGPoint locationInView = [touch locationInView: self]; - + while(touch) { + CGPoint locationInView = [self touchLocation:touch]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS - //FIXME: TODO: Using touch as the fingerId is potentially dangerous - //It is also much more efficient than storing the UITouch pointer - //and comparing it to the incoming event. - SDL_SendFingerDown(touchId,(long)touch, - SDL_TRUE,locationInView.x,locationInView.y, - 1); + //FIXME: TODO: Using touch as the fingerId is potentially dangerous + //It is also much more efficient than storing the UITouch pointer + //and comparing it to the incoming event. + SDL_SendFingerDown(touchId, (long)touch, + SDL_TRUE, locationInView.x, locationInView.y, + 1); #else - int i; - for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { - if(finger[i] == NULL) { - finger[i] = touch; - SDL_SendFingerDown(touchId,i, - SDL_TRUE,locationInView.x,locationInView.y, - 1); - break; - } - } + int i; + for(i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) { + if (finger[i] == NULL) { + finger[i] = touch; + SDL_SendFingerDown(touchId, i, + SDL_TRUE, locationInView.x, locationInView.y, + 1); + break; + } + } #endif - - - - touch = (UITouch*)[enumerator nextObject]; - } + touch = (UITouch*)[enumerator nextObject]; + } #endif } -- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - - NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch = (UITouch*)[enumerator nextObject]; - - if (touch) { - /* send mouse up */ - SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); - } +- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event +{ + NSEnumerator *enumerator = [touches objectEnumerator]; + UITouch *touch = (UITouch*)[enumerator nextObject]; + + if (touch) { + /* send mouse up */ + SDL_SendMouseButton(NULL, SDL_RELEASED, SDL_BUTTON_LEFT); + } #ifdef FIXED_MULTITOUCH - while(touch) { - CGPoint locationInView = [touch locationInView: self]; - + while(touch) { + CGPoint locationInView = [self touchLocation:touch]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS - SDL_SendFingerDown(touchId,(long)touch, - SDL_FALSE,locationInView.x,locationInView.y, - 1); + SDL_SendFingerDown(touchId, (long)touch, + SDL_FALSE, locationInView.x, locationInView.y, + 1); #else - int i; - for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { - if(finger[i] == touch) { - SDL_SendFingerDown(touchId,i, - SDL_FALSE,locationInView.x,locationInView.y, - 1); - break; - } - } + int i; + for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) { + if (finger[i] == touch) { + SDL_SendFingerDown(touchId, i, + SDL_FALSE, locationInView.x, locationInView.y, + 1); + finger[i] = NULL; + break; + } + } #endif - touch = (UITouch*)[enumerator nextObject]; - } + touch = (UITouch*)[enumerator nextObject]; + } #endif } -- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event { - /* - this can happen if the user puts more than 5 touches on the screen - at once, or perhaps in other circumstances. Usually (it seems) - all active touches are canceled. - */ - [self touchesEnded: touches withEvent: event]; +- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event +{ + /* + this can happen if the user puts more than 5 touches on the screen + at once, or perhaps in other circumstances. Usually (it seems) + all active touches are canceled. + */ + [self touchesEnded: touches withEvent: event]; } -- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { - - NSEnumerator *enumerator = [touches objectEnumerator]; - UITouch *touch = (UITouch*)[enumerator nextObject]; - - if (touch) { - CGPoint locationInView = [touch locationInView: self]; +- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event +{ + NSEnumerator *enumerator = [touches objectEnumerator]; + UITouch *touch = (UITouch*)[enumerator nextObject]; - /* send moved event */ - SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); - } + if (touch) { + CGPoint locationInView = [touch locationInView: self]; + + /* send moved event */ + SDL_SendMouseMotion(NULL, 0, locationInView.x, locationInView.y); + } #ifdef FIXED_MULTITOUCH - while(touch) { - CGPoint locationInView = [touch locationInView: self]; - + while(touch) { + CGPoint locationInView = [self touchLocation:touch]; #ifdef IPHONE_TOUCH_EFFICIENT_DANGEROUS - SDL_SendTouchMotion(touchId,(long)touch, - SDL_FALSE,locationInView.x,locationInView.y, - 1); + SDL_SendTouchMotion(touchId, (long)touch, + SDL_FALSE, locationInView.x, locationInView.y, + 1); #else - int i; - for(i = 0;i < MAX_SIMULTANEOUS_TOUCHES;i++) { - if(finger[i] == touch) { - SDL_SendTouchMotion(touchId,i, - SDL_FALSE,locationInView.x,locationInView.y, - 1); - break; - } - } + int i; + for (i = 0; i < MAX_SIMULTANEOUS_TOUCHES; i++) { + if (finger[i] == touch) { + SDL_SendTouchMotion(touchId, i, + SDL_FALSE, locationInView.x, locationInView.y, + 1); + break; + } + } #endif - touch = (UITouch*)[enumerator nextObject]; - } + touch = (UITouch*)[enumerator nextObject]; + } #endif } /* - ---- Keyboard related functionality below this line ---- + ---- Keyboard related functionality below this line ---- */ #if SDL_IPHONE_KEYBOARD /* Is the iPhone virtual keyboard visible onscreen? */ -- (BOOL)keyboardVisible { - return keyboardVisible; +- (BOOL)keyboardVisible +{ + return keyboardVisible; } /* Set ourselves up as a UITextFieldDelegate */ -- (void)initializeKeyboard { - - textField = [[[UITextField alloc] initWithFrame: CGRectZero] autorelease]; - textField.delegate = self; - /* placeholder so there is something to delete! */ - textField.text = @" "; - - /* set UITextInputTrait properties, mostly to defaults */ - textField.autocapitalizationType = UITextAutocapitalizationTypeNone; - textField.autocorrectionType = UITextAutocorrectionTypeNo; - textField.enablesReturnKeyAutomatically = NO; - textField.keyboardAppearance = UIKeyboardAppearanceDefault; - textField.keyboardType = UIKeyboardTypeDefault; - textField.returnKeyType = UIReturnKeyDefault; - textField.secureTextEntry = NO; - - textField.hidden = YES; - keyboardVisible = NO; - /* add the UITextField (hidden) to our view */ - [self addSubview: textField]; +- (void)initializeKeyboard +{ + textField = [[UITextField alloc] initWithFrame: CGRectZero]; + textField.delegate = self; + /* placeholder so there is something to delete! */ + textField.text = @" "; + + /* set UITextInputTrait properties, mostly to defaults */ + textField.autocapitalizationType = UITextAutocapitalizationTypeNone; + textField.autocorrectionType = UITextAutocorrectionTypeNo; + textField.enablesReturnKeyAutomatically = NO; + textField.keyboardAppearance = UIKeyboardAppearanceDefault; + textField.keyboardType = UIKeyboardTypeDefault; + textField.returnKeyType = UIReturnKeyDefault; + textField.secureTextEntry = NO; + + textField.hidden = YES; + keyboardVisible = NO; + /* add the UITextField (hidden) to our view */ + [self addSubview: textField]; + [textField release]; } /* reveal onscreen virtual keyboard */ -- (void)showKeyboard { - keyboardVisible = YES; - [textField becomeFirstResponder]; +- (void)showKeyboard +{ + keyboardVisible = YES; + [textField becomeFirstResponder]; } /* hide onscreen virtual keyboard */ -- (void)hideKeyboard { - keyboardVisible = NO; - [textField resignFirstResponder]; +- (void)hideKeyboard +{ + keyboardVisible = NO; + [textField resignFirstResponder]; } /* UITextFieldDelegate method. Invoked when user types something. */ -- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { - - if ([string length] == 0) { - /* it wants to replace text with nothing, ie a delete */ - SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); - SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); - } - else { - /* go through all the characters in the string we've been sent - and convert them to key presses */ - int i; - for (i=0; i<[string length]; i++) { - - unichar c = [string characterAtIndex: i]; - - Uint16 mod = 0; - SDL_scancode code; - - if (c < 127) { - /* figure out the SDL_scancode and SDL_keymod for this unichar */ - code = unicharToUIKeyInfoTable[c].code; - mod = unicharToUIKeyInfoTable[c].mod; - } - else { - /* we only deal with ASCII right now */ - code = SDL_SCANCODE_UNKNOWN; - mod = 0; - } - - if (mod & KMOD_SHIFT) { - /* If character uses shift, press shift down */ - SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); - } - /* send a keydown and keyup even for the character */ - SDL_SendKeyboardKey(SDL_PRESSED, code); - SDL_SendKeyboardKey(SDL_RELEASED, code); - if (mod & KMOD_SHIFT) { - /* If character uses shift, press shift back up */ - SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); - } - } - } - return NO; /* don't allow the edit! (keep placeholder text there) */ +- (BOOL)textField:(UITextField *)_textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string +{ + if ([string length] == 0) { + /* it wants to replace text with nothing, ie a delete */ + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_DELETE); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_DELETE); + } + else { + /* go through all the characters in the string we've been sent + and convert them to key presses */ + int i; + for (i = 0; i < [string length]; i++) { + + unichar c = [string characterAtIndex: i]; + + Uint16 mod = 0; + SDL_Scancode code; + + if (c < 127) { + /* figure out the SDL_Scancode and SDL_keymod for this unichar */ + code = unicharToUIKeyInfoTable[c].code; + mod = unicharToUIKeyInfoTable[c].mod; + } + else { + /* we only deal with ASCII right now */ + code = SDL_SCANCODE_UNKNOWN; + mod = 0; + } + + if (mod & KMOD_SHIFT) { + /* If character uses shift, press shift down */ + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_LSHIFT); + } + /* send a keydown and keyup even for the character */ + SDL_SendKeyboardKey(SDL_PRESSED, code); + SDL_SendKeyboardKey(SDL_RELEASED, code); + if (mod & KMOD_SHIFT) { + /* If character uses shift, press shift back up */ + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_LSHIFT); + } + } + SDL_SendKeyboardText([string UTF8String]); + } + return NO; /* don't allow the edit! (keep placeholder text there) */ } /* Terminates the editing session */ -- (BOOL)textFieldShouldReturn:(UITextField*)_textField { - [self hideKeyboard]; - return YES; +- (BOOL)textFieldShouldReturn:(UITextField*)_textField +{ + SDL_SendKeyboardKey(SDL_PRESSED, SDL_SCANCODE_RETURN); + SDL_SendKeyboardKey(SDL_RELEASED, SDL_SCANCODE_RETURN); + [self hideKeyboard]; + return YES; } #endif @@ -311,124 +327,100 @@ /* iPhone keyboard addition functions */ #if SDL_IPHONE_KEYBOARD -int SDL_iPhoneKeyboardShow(SDL_Window * window) { - - SDL_WindowData *data; - SDL_uikitview *view; - - if (NULL == window) { - SDL_SetError("Window does not exist"); - return -1; - } - - data = (SDL_WindowData *)window->driverdata; - view = data->view; - - if (nil == view) { - SDL_SetError("Window has no view"); - return -1; - } - else { - [view showKeyboard]; - return 0; - } +static SDL_uikitview * getWindowView(SDL_Window * window) +{ + if (window == NULL) { + SDL_SetError("Window does not exist"); + return nil; + } + + SDL_WindowData *data = (SDL_WindowData *)window->driverdata; + SDL_uikitview *view = data != NULL ? data->view : nil; + + if (view == nil) { + SDL_SetError("Window has no view"); + } + + return view; } -int SDL_iPhoneKeyboardHide(SDL_Window * window) { - - SDL_WindowData *data; - SDL_uikitview *view; - - if (NULL == window) { - SDL_SetError("Window does not exist"); - return -1; - } - - data = (SDL_WindowData *)window->driverdata; - view = data->view; - - if (NULL == view) { - SDL_SetError("Window has no view"); - return -1; - } - else { - [view hideKeyboard]; - return 0; - } +int SDL_iPhoneKeyboardShow(SDL_Window * window) +{ + SDL_uikitview *view = getWindowView(window); + if (view == nil) { + return -1; + } + + [view showKeyboard]; + return 0; } -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { - - SDL_WindowData *data; - SDL_uikitview *view; - - if (NULL == window) { - SDL_SetError("Window does not exist"); - return -1; - } - - data = (SDL_WindowData *)window->driverdata; - view = data->view; - - if (NULL == view) { - SDL_SetError("Window has no view"); - return 0; - } - else { - return view.keyboardVisible; - } +int SDL_iPhoneKeyboardHide(SDL_Window * window) +{ + SDL_uikitview *view = getWindowView(window); + if (view == nil) { + return -1; + } + + [view hideKeyboard]; + return 0; } -int SDL_iPhoneKeyboardToggle(SDL_Window * window) { - - SDL_WindowData *data; - SDL_uikitview *view; - - if (NULL == window) { - SDL_SetError("Window does not exist"); - return -1; - } - - data = (SDL_WindowData *)window->driverdata; - view = data->view; - - if (NULL == view) { - SDL_SetError("Window has no view"); - return -1; - } - else { - if (SDL_iPhoneKeyboardIsShown(window)) { - SDL_iPhoneKeyboardHide(window); - } - else { - SDL_iPhoneKeyboardShow(window); - } - return 0; - } +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) +{ + SDL_uikitview *view = getWindowView(window); + if (view == nil) { + return 0; + } + + return view.keyboardVisible; +} + +int SDL_iPhoneKeyboardToggle(SDL_Window * window) +{ + SDL_uikitview *view = getWindowView(window); + if (view == nil) { + return -1; + } + + if (SDL_iPhoneKeyboardIsShown(window)) { + SDL_iPhoneKeyboardHide(window); + } + else { + SDL_iPhoneKeyboardShow(window); + } + return 0; } #else /* stubs, used if compiled without keyboard support */ -int SDL_iPhoneKeyboardShow(SDL_Window * window) { - SDL_SetError("Not compiled with keyboard support"); - return -1; +int SDL_iPhoneKeyboardShow(SDL_Window * window) +{ + SDL_SetError("Not compiled with keyboard support"); + return -1; } -int SDL_iPhoneKeyboardHide(SDL_Window * window) { - SDL_SetError("Not compiled with keyboard support"); - return -1; +int SDL_iPhoneKeyboardHide(SDL_Window * window) +{ + SDL_SetError("Not compiled with keyboard support"); + return -1; } -SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) { - return 0; +SDL_bool SDL_iPhoneKeyboardIsShown(SDL_Window * window) +{ + return 0; } -int SDL_iPhoneKeyboardToggle(SDL_Window * window) { - SDL_SetError("Not compiled with keyboard support"); - return -1; +int SDL_iPhoneKeyboardToggle(SDL_Window * window) +{ + SDL_SetError("Not compiled with keyboard support"); + return -1; } - #endif /* SDL_IPHONE_KEYBOARD */ + +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitviewcontroller.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitviewcontroller.h new file mode 100644 index 000000000..904fc17eb --- /dev/null +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitviewcontroller.h @@ -0,0 +1,38 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + */ + +#import + +#include "../SDL_sysvideo.h" + +@interface SDL_uikitviewcontroller : UIViewController { +@private + SDL_Window *window; +} + +@property (readwrite) SDL_Window *window; + +- (id)initWithSDLWindow:(SDL_Window *)_window; +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient; +- (void)loadView; +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation; + +@end diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitviewcontroller.m b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitviewcontroller.m new file mode 100644 index 000000000..4ac5cb075 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitviewcontroller.m @@ -0,0 +1,152 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_UIKIT + +#include "SDL_video.h" +#include "SDL_assert.h" +#include "SDL_hints.h" +#include "../SDL_sysvideo.h" +#include "../../events/SDL_events_c.h" + +#include "SDL_uikitwindow.h" +#include "SDL_uikitviewcontroller.h" +#include "SDL_uikitvideo.h" + +@implementation SDL_uikitviewcontroller + +@synthesize window; + +- (id)initWithSDLWindow:(SDL_Window *)_window +{ + self = [self init]; + if (self == nil) { + return nil; + } + self.window = _window; + return self; +} + +- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)orient +{ + const char *orientationsCString; + if ((orientationsCString = SDL_GetHint(SDL_HINT_ORIENTATIONS)) != NULL) { + BOOL rotate = NO; + NSString *orientationsNSString = [NSString stringWithCString:orientationsCString + encoding:NSUTF8StringEncoding]; + NSArray *orientations = [orientationsNSString componentsSeparatedByCharactersInSet: + [NSCharacterSet characterSetWithCharactersInString:@" "]]; + + switch (orient) { + case UIInterfaceOrientationLandscapeLeft: + rotate = [orientations containsObject:@"LandscapeLeft"]; + break; + + case UIInterfaceOrientationLandscapeRight: + rotate = [orientations containsObject:@"LandscapeRight"]; + break; + + case UIInterfaceOrientationPortrait: + rotate = [orientations containsObject:@"Portrait"]; + break; + + case UIInterfaceOrientationPortraitUpsideDown: + rotate = [orientations containsObject:@"PortraitUpsideDown"]; + break; + + default: break; + } + + return rotate; + } + + if (self->window->flags & SDL_WINDOW_RESIZABLE) { + return YES; // any orientation is okay. + } + + // If not resizable, allow device to orient to other matching sizes + // (that is, let the user turn the device upside down...same screen + // dimensions, but it lets the user place the device where it's most + // comfortable in relation to its physical buttons, headphone jack, etc). + switch (orient) { + case UIInterfaceOrientationLandscapeLeft: + case UIInterfaceOrientationLandscapeRight: + return (self->window->w >= self->window->h); + + case UIInterfaceOrientationPortrait: + case UIInterfaceOrientationPortraitUpsideDown: + return (self->window->h >= self->window->w); + + default: break; + } + + return NO; // Nothing else is acceptable. +} + +- (void)loadView +{ + // do nothing. +} + +// Send a resized event when the orientation changes. +- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation +{ + const UIInterfaceOrientation toInterfaceOrientation = [self interfaceOrientation]; + SDL_WindowData *data = self->window->driverdata; + UIWindow *uiwindow = data->uiwindow; + UIScreen *uiscreen; + if (SDL_UIKit_supports_multiple_displays) + uiscreen = [uiwindow screen]; + else + uiscreen = [UIScreen mainScreen]; + const int noborder = (self->window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)); + CGRect frame = noborder ? [uiscreen bounds] : [uiscreen applicationFrame]; + const CGSize size = frame.size; + int w, h; + + switch (toInterfaceOrientation) { + case UIInterfaceOrientationPortrait: + case UIInterfaceOrientationPortraitUpsideDown: + w = (size.width < size.height) ? size.width : size.height; + h = (size.width > size.height) ? size.width : size.height; + break; + + case UIInterfaceOrientationLandscapeLeft: + case UIInterfaceOrientationLandscapeRight: + w = (size.width > size.height) ? size.width : size.height; + h = (size.width < size.height) ? size.width : size.height; + break; + + default: + SDL_assert(0 && "Unexpected interface orientation!"); + return; + } + + [uiwindow setFrame:frame]; + [data->view setFrame:frame]; + [data->view updateFrame]; + SDL_SendWindowEvent(self->window, SDL_WINDOWEVENT_RESIZED, w, h); +} + +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + +@end diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitwindow.h b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitwindow.h index f0f64f3b0..3090110d5 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitwindow.h +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitwindow.h @@ -1,36 +1,37 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ -#include "SDL_config.h" - #ifndef _SDL_uikitwindow_h #define _SDL_uikitwindow_h #include "../SDL_sysvideo.h" #import "SDL_uikitopenglview.h" +#import "SDL_uikitviewcontroller.h" typedef struct SDL_WindowData SDL_WindowData; extern int UIKit_CreateWindow(_THIS, SDL_Window * window); +extern void UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); extern void UIKit_DestroyWindow(_THIS, SDL_Window * window); +extern SDL_bool UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, + struct SDL_SysWMinfo * info); @class UIWindow; @@ -38,9 +39,9 @@ struct SDL_WindowData { UIWindow *uiwindow; SDL_uikitopenglview *view; + SDL_uikitviewcontroller *viewcontroller; }; - #endif /* _SDL_uikitwindow_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitwindow.m b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitwindow.m index f2337809e..ad54da2ef 100644 --- a/project/jni/sdl-1.3/src/video/uikit/SDL_uikitwindow.m +++ b/project/jni/sdl-1.3/src/video/uikit/SDL_uikitwindow.m @@ -1,29 +1,32 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2009 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_UIKIT + +#include "SDL_syswm.h" #include "SDL_video.h" #include "SDL_mouse.h" #include "SDL_assert.h" +#include "SDL_hints.h" #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" #include "../../events/SDL_events_c.h" @@ -34,17 +37,18 @@ #import "SDL_uikitappdelegate.h" #import "SDL_uikitopenglview.h" -#import "SDL_renderer_sw.h" -#include #include + + + static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bool created) { - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); UIScreen *uiscreen = (UIScreen *) display->driverdata; SDL_WindowData *data; - + /* Allocate the window data */ data = (SDL_WindowData *)SDL_malloc(sizeof(*data)); if (!data) { @@ -52,48 +56,86 @@ static int SetupWindowData(_THIS, SDL_Window *window, UIWindow *uiwindow, SDL_bo return -1; } data->uiwindow = uiwindow; + data->viewcontroller = nil; data->view = nil; /* Fill in the SDL window with the window data */ { window->x = 0; window->y = 0; - window->w = (int)uiwindow.frame.size.width; - window->h = (int)uiwindow.frame.size.height; + + /* We can pick either width or height here and we'll rotate the + screen to match, so we pick the closest to what we wanted. + */ + if (window->w >= window->h) { + if (uiwindow.frame.size.width > uiwindow.frame.size.height) { + window->w = (int)uiwindow.frame.size.width; + window->h = (int)uiwindow.frame.size.height; + } else { + window->w = (int)uiwindow.frame.size.height; + window->h = (int)uiwindow.frame.size.width; + } + } else { + if (uiwindow.frame.size.width > uiwindow.frame.size.height) { + window->w = (int)uiwindow.frame.size.height; + window->h = (int)uiwindow.frame.size.width; + } else { + window->w = (int)uiwindow.frame.size.width; + window->h = (int)uiwindow.frame.size.height; + } + } } - + window->driverdata = data; - - window->flags &= ~SDL_WINDOW_RESIZABLE; /* window is NEVER resizeable */ - window->flags |= SDL_WINDOW_OPENGL; /* window is always OpenGL */ - window->flags |= SDL_WINDOW_FULLSCREEN; /* window is always fullscreen */ - window->flags |= SDL_WINDOW_SHOWN; /* only one window on iPod touch, always shown */ - window->flags |= SDL_WINDOW_INPUT_FOCUS; /* always has input focus */ + + window->flags |= SDL_WINDOW_SHOWN; /* only one window on iOS, always shown */ // SDL_WINDOW_BORDERLESS controls whether status bar is hidden. // This is only set if the window is on the main screen. Other screens // just force the window to have the borderless flag. - if ([UIScreen mainScreen] == uiscreen) { - if (window->flags & SDL_WINDOW_BORDERLESS) { + if ([UIScreen mainScreen] != uiscreen) { + window->flags &= ~SDL_WINDOW_RESIZABLE; // window is NEVER resizeable + window->flags &= ~SDL_WINDOW_INPUT_FOCUS; // never has input focus + window->flags |= SDL_WINDOW_BORDERLESS; // never has a status bar. + } else { + window->flags |= SDL_WINDOW_INPUT_FOCUS; // always has input focus + + if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) { [UIApplication sharedApplication].statusBarHidden = YES; } else { [UIApplication sharedApplication].statusBarHidden = NO; } + + //const UIDeviceOrientation o = [[UIDevice currentDevice] orientation]; + //const BOOL landscape = (o == UIDeviceOrientationLandscapeLeft) || + // (o == UIDeviceOrientationLandscapeRight); + //const BOOL rotate = ( ((window->w > window->h) && (!landscape)) || + // ((window->w < window->h) && (landscape)) ); + + // The View Controller will handle rotating the view when the + // device orientation changes. This will trigger resize events, if + // appropriate. + SDL_uikitviewcontroller *controller; + controller = [SDL_uikitviewcontroller alloc]; + data->viewcontroller = [controller initWithSDLWindow:window]; + [data->viewcontroller setTitle:@"SDL App"]; // !!! FIXME: hook up SDL_SetWindowTitle() + // !!! FIXME: if (rotate), force a "resize" right at the start } - + return 0; - } -int UIKit_CreateWindow(_THIS, SDL_Window *window) { - - SDL_VideoDisplay *display = window->display; +int +UIKit_CreateWindow(_THIS, SDL_Window *window) +{ + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); UIScreen *uiscreen = (UIScreen *) display->driverdata; + const BOOL external = ([UIScreen mainScreen] != uiscreen); // SDL currently puts this window at the start of display's linked list. We rely on this. - SDL_assert(display->windows == window); + SDL_assert(_this->windows == window); - /* We currently only handle a single window per display on iPhone */ + /* We currently only handle a single window per display on iOS */ if (window->next != NULL) { SDL_SetError("Only one window allowed per display."); return -1; @@ -102,7 +144,7 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window) { // Non-mainscreen windows must be force to borderless, as there's no // status bar there, and we want to get the right dimensions later in // this function. - if ([UIScreen mainScreen] != uiscreen) { + if (external) { window->flags |= SDL_WINDOW_BORDERLESS; } @@ -127,8 +169,13 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window) { if (bestmode) { UIScreenMode *uimode = (UIScreenMode *) bestmode->driverdata; [uiscreen setCurrentMode:uimode]; - display->desktop_mode = *bestmode; + + // desktop_mode doesn't change here (the higher level will + // use it to set all the screens back to their defaults + // upon window destruction, SDL_Quit(), etc. + [((UIScreenMode *) display->current_mode.driverdata) release]; display->current_mode = *bestmode; + [((UIScreenMode *) display->current_mode.driverdata) retain]; } } } @@ -136,31 +183,92 @@ int UIKit_CreateWindow(_THIS, SDL_Window *window) { /* ignore the size user requested, and make a fullscreen window */ // !!! FIXME: can we have a smaller view? UIWindow *uiwindow = [UIWindow alloc]; - if (window->flags & SDL_WINDOW_BORDERLESS) + if (window->flags & (SDL_WINDOW_FULLSCREEN|SDL_WINDOW_BORDERLESS)) uiwindow = [uiwindow initWithFrame:[uiscreen bounds]]; else uiwindow = [uiwindow initWithFrame:[uiscreen applicationFrame]]; - if (SDL_UIKit_supports_multiple_displays) { + // put the window on an external display if appropriate. This implicitly + // does [uiwindow setframe:[uiscreen bounds]], so don't do it on the + // main display, where we land by default, as that would eat the + // status bar real estate. + if (external) { [uiwindow setScreen:uiscreen]; } if (SetupWindowData(_this, window, uiwindow, SDL_TRUE) < 0) { [uiwindow release]; return -1; - } - + } + return 1; - + } -void UIKit_DestroyWindow(_THIS, SDL_Window * window) { +void +UIKit_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) +{ + UIScreen *uiscreen = (UIScreen *) display->driverdata; + UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow; + + if (fullscreen) { + [UIApplication sharedApplication].statusBarHidden = YES; + uiwindow.frame = [uiscreen bounds]; + } else { + [UIApplication sharedApplication].statusBarHidden = NO; + uiwindow.frame = [uiscreen applicationFrame]; + } + + /* We can pick either width or height here and we'll rotate the + screen to match, so we pick the closest to what we wanted. + */ + if (window->w >= window->h) { + if (uiwindow.frame.size.width > uiwindow.frame.size.height) { + window->w = (int)uiwindow.frame.size.width; + window->h = (int)uiwindow.frame.size.height; + } else { + window->w = (int)uiwindow.frame.size.height; + window->h = (int)uiwindow.frame.size.width; + } + } else { + if (uiwindow.frame.size.width > uiwindow.frame.size.height) { + window->w = (int)uiwindow.frame.size.height; + window->h = (int)uiwindow.frame.size.width; + } else { + window->w = (int)uiwindow.frame.size.width; + window->h = (int)uiwindow.frame.size.height; + } + } +} + +void +UIKit_DestroyWindow(_THIS, SDL_Window * window) +{ SDL_WindowData *data = (SDL_WindowData *)window->driverdata; if (data) { + [data->viewcontroller release]; [data->uiwindow release]; SDL_free(data); window->driverdata = NULL; } } +SDL_bool +UIKit_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) +{ + UIWindow *uiwindow = ((SDL_WindowData *) window->driverdata)->uiwindow; + + if (info->version.major <= SDL_MAJOR_VERSION) { + info->subsystem = SDL_SYSWM_UIKIT; + info->info.uikit.window = uiwindow; + return SDL_TRUE; + } else { + SDL_SetError("Application not compiled with SDL %d.%d\n", + SDL_MAJOR_VERSION, SDL_MINOR_VERSION); + return SDL_FALSE; + } +} + +#endif /* SDL_VIDEO_DRIVER_UIKIT */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/jumphack.h b/project/jni/sdl-1.3/src/video/uikit/jumphack.h index b517e6355..169498303 100644 --- a/project/jni/sdl-1.3/src/video/uikit/jumphack.h +++ b/project/jni/sdl-1.3/src/video/uikit/jumphack.h @@ -14,3 +14,5 @@ extern jmp_buf *jump_env(void); #endif + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/uikit/keyinfotable.h b/project/jni/sdl-1.3/src/video/uikit/keyinfotable.h index 3bece3e5e..3c011521b 100644 --- a/project/jni/sdl-1.3/src/video/uikit/keyinfotable.h +++ b/project/jni/sdl-1.3/src/video/uikit/keyinfotable.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef _UIKIT_KeyInfo @@ -26,21 +25,20 @@ #include "SDL_scancode.h" /* - This file is used by the keyboard code in SDL_uikitview.m to convert between characters - passed in from the iPhone's virtual keyboard, and tuples of SDL_scancodes and SDL_keymods. - For example unicharToUIKeyInfoTable['a'] would give you the scan code and keymod for lower - case a. + This file is used by the keyboard code in SDL_uikitview.m to convert between characters + passed in from the iPhone's virtual keyboard, and tuples of SDL_Scancode and SDL_keymods. + For example unicharToUIKeyInfoTable['a'] would give you the scan code and keymod for lower + case a. */ typedef struct { - SDL_scancode code; + SDL_Scancode code; Uint16 mod; } UIKitKeyInfo; /* So far only ASCII characters here */ static UIKitKeyInfo unicharToUIKeyInfoTable[] = { -/* *INDENT-OFF* */ /* 0 */ { SDL_SCANCODE_UNKNOWN, 0 }, /* 1 */ { SDL_SCANCODE_UNKNOWN, 0 }, /* 2 */ { SDL_SCANCODE_UNKNOWN, 0 }, @@ -54,7 +52,7 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = { /* 10 */ { SDL_SCANCODE_UNKNOWN, 0 }, /* 11 */ { SDL_SCANCODE_UNKNOWN, 0 }, /* 12 */ { SDL_SCANCODE_UNKNOWN, 0 }, -/* 13 */ { SDL_SCANCODE_UNKNOWN, 0 }, +/* 13 */ { SDL_SCANCODE_RETURN, 0 }, /* 14 */ { SDL_SCANCODE_UNKNOWN, 0 }, /* 15 */ { SDL_SCANCODE_UNKNOWN, 0 }, /* 16 */ { SDL_SCANCODE_UNKNOWN, 0 }, @@ -74,22 +72,22 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = { /* 30 */ { SDL_SCANCODE_UNKNOWN, 0 }, /* 31 */ { SDL_SCANCODE_UNKNOWN, 0 }, /* 32 */ { SDL_SCANCODE_SPACE, 0 }, -/* 33 */ { SDL_SCANCODE_1, KMOD_SHIFT }, /* plus shift modifier '!' */ -/* 34 */ { SDL_SCANCODE_APOSTROPHE, KMOD_SHIFT }, /* plus shift modifier '"' */ -/* 35 */ { SDL_SCANCODE_3, KMOD_SHIFT }, /* plus shift modifier '#' */ -/* 36 */ { SDL_SCANCODE_4, KMOD_SHIFT }, /* plus shift modifier '$' */ -/* 37 */ { SDL_SCANCODE_5, KMOD_SHIFT }, /* plus shift modifier '%' */ -/* 38 */ { SDL_SCANCODE_7, KMOD_SHIFT }, /* plus shift modifier '&' */ -/* 39 */ { SDL_SCANCODE_APOSTROPHE, 0 }, /* ''' */ -/* 40 */ { SDL_SCANCODE_9, KMOD_SHIFT }, /* plus shift modifier '(' */ -/* 41 */ { SDL_SCANCODE_0, KMOD_SHIFT }, /* plus shift modifier ')' */ -/* 42 */ { SDL_SCANCODE_8, KMOD_SHIFT }, /* '*' */ -/* 43 */ { SDL_SCANCODE_EQUALS, KMOD_SHIFT }, /* plus shift modifier '+' */ -/* 44 */ { SDL_SCANCODE_COMMA, 0 }, /* ',' */ -/* 45 */ { SDL_SCANCODE_MINUS, 0 }, /* '-' */ -/* 46 */ { SDL_SCANCODE_PERIOD, 0 }, /* '.' */ -/* 47 */ { SDL_SCANCODE_SLASH, 0 }, /* '/' */ -/* 48 */ { SDL_SCANCODE_0, 0 }, +/* 33 */ { SDL_SCANCODE_1, KMOD_SHIFT }, /* plus shift modifier '!' */ +/* 34 */ { SDL_SCANCODE_APOSTROPHE, KMOD_SHIFT }, /* plus shift modifier '"' */ +/* 35 */ { SDL_SCANCODE_3, KMOD_SHIFT }, /* plus shift modifier '#' */ +/* 36 */ { SDL_SCANCODE_4, KMOD_SHIFT }, /* plus shift modifier '$' */ +/* 37 */ { SDL_SCANCODE_5, KMOD_SHIFT }, /* plus shift modifier '%' */ +/* 38 */ { SDL_SCANCODE_7, KMOD_SHIFT }, /* plus shift modifier '&' */ +/* 39 */ { SDL_SCANCODE_APOSTROPHE, 0 }, /* ''' */ +/* 40 */ { SDL_SCANCODE_9, KMOD_SHIFT }, /* plus shift modifier '(' */ +/* 41 */ { SDL_SCANCODE_0, KMOD_SHIFT }, /* plus shift modifier ')' */ +/* 42 */ { SDL_SCANCODE_8, KMOD_SHIFT }, /* '*' */ +/* 43 */ { SDL_SCANCODE_EQUALS, KMOD_SHIFT }, /* plus shift modifier '+' */ +/* 44 */ { SDL_SCANCODE_COMMA, 0 }, /* ',' */ +/* 45 */ { SDL_SCANCODE_MINUS, 0 }, /* '-' */ +/* 46 */ { SDL_SCANCODE_PERIOD, 0 }, /* '.' */ +/* 47 */ { SDL_SCANCODE_SLASH, 0 }, /* '/' */ +/* 48 */ { SDL_SCANCODE_0, 0 }, /* 49 */ { SDL_SCANCODE_1, 0 }, /* 50 */ { SDL_SCANCODE_2, 0 }, /* 51 */ { SDL_SCANCODE_3, 0 }, @@ -99,14 +97,14 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = { /* 55 */ { SDL_SCANCODE_7, 0 }, /* 56 */ { SDL_SCANCODE_8, 0 }, /* 57 */ { SDL_SCANCODE_9, 0 }, -/* 58 */ { SDL_SCANCODE_SEMICOLON, KMOD_SHIFT }, /* plus shift modifier ';' */ +/* 58 */ { SDL_SCANCODE_SEMICOLON, KMOD_SHIFT }, /* plus shift modifier ';' */ /* 59 */ { SDL_SCANCODE_SEMICOLON, 0 }, -/* 60 */ { SDL_SCANCODE_COMMA, KMOD_SHIFT }, /* plus shift modifier '<' */ +/* 60 */ { SDL_SCANCODE_COMMA, KMOD_SHIFT }, /* plus shift modifier '<' */ /* 61 */ { SDL_SCANCODE_EQUALS, 0 }, -/* 62 */ { SDL_SCANCODE_PERIOD, KMOD_SHIFT }, /* plus shift modifier '>' */ -/* 63 */ { SDL_SCANCODE_SLASH, KMOD_SHIFT }, /* plus shift modifier '?' */ -/* 64 */ { SDL_SCANCODE_2, KMOD_SHIFT }, /* plus shift modifier '@' */ -/* 65 */ { SDL_SCANCODE_A, KMOD_SHIFT }, /* all the following need shift modifiers */ +/* 62 */ { SDL_SCANCODE_PERIOD, KMOD_SHIFT }, /* plus shift modifier '>' */ +/* 63 */ { SDL_SCANCODE_SLASH, KMOD_SHIFT }, /* plus shift modifier '?' */ +/* 64 */ { SDL_SCANCODE_2, KMOD_SHIFT }, /* plus shift modifier '@' */ +/* 65 */ { SDL_SCANCODE_A, KMOD_SHIFT }, /* all the following need shift modifiers */ /* 66 */ { SDL_SCANCODE_B, KMOD_SHIFT }, /* 67 */ { SDL_SCANCODE_C, KMOD_SHIFT }, /* 68 */ { SDL_SCANCODE_D, KMOD_SHIFT }, @@ -135,10 +133,10 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = { /* 91 */ { SDL_SCANCODE_LEFTBRACKET, 0 }, /* 92 */ { SDL_SCANCODE_BACKSLASH, 0 }, /* 93 */ { SDL_SCANCODE_RIGHTBRACKET, 0 }, -/* 94 */ { SDL_SCANCODE_6, KMOD_SHIFT }, /* plus shift modifier '^' */ -/* 95 */ { SDL_SCANCODE_MINUS, KMOD_SHIFT }, /* plus shift modifier '_' */ -/* 96 */ { SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* '`' -/* 97 */ { SDL_SCANCODE_A, 0 }, +/* 94 */ { SDL_SCANCODE_6, KMOD_SHIFT }, /* plus shift modifier '^' */ +/* 95 */ { SDL_SCANCODE_MINUS, KMOD_SHIFT }, /* plus shift modifier '_' */ +/* 96 */ { SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* '`' */ +/* 97 */ { SDL_SCANCODE_A, 0 }, /* 98 */ { SDL_SCANCODE_B, 0 }, /* 99 */ { SDL_SCANCODE_C, 0 }, /* 100 */{ SDL_SCANCODE_D, 0 }, @@ -164,12 +162,13 @@ static UIKitKeyInfo unicharToUIKeyInfoTable[] = { /* 120 */{ SDL_SCANCODE_X, 0 }, /* 121 */{ SDL_SCANCODE_Y, 0 }, /* 122 */{ SDL_SCANCODE_Z, 0 }, -/* 123 */{ SDL_SCANCODE_LEFTBRACKET, KMOD_SHIFT }, /* plus shift modifier '{' */ -/* 124 */{ SDL_SCANCODE_BACKSLASH, KMOD_SHIFT }, /* plus shift modifier '|' */ -/* 125 */{ SDL_SCANCODE_RIGHTBRACKET, KMOD_SHIFT }, /* plus shift modifier '}' */ -/* 126 */{ SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* plus shift modifier '~' */ +/* 123 */{ SDL_SCANCODE_LEFTBRACKET, KMOD_SHIFT }, /* plus shift modifier '{' */ +/* 124 */{ SDL_SCANCODE_BACKSLASH, KMOD_SHIFT }, /* plus shift modifier '|' */ +/* 125 */{ SDL_SCANCODE_RIGHTBRACKET, KMOD_SHIFT }, /* plus shift modifier '}' */ +/* 126 */{ SDL_SCANCODE_GRAVE, KMOD_SHIFT }, /* plus shift modifier '~' */ /* 127 */{ SDL_SCANCODE_DELETE, KMOD_SHIFT } -/* *INDENT-ON* */ }; #endif /* UIKitKeyInfo */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_ceddrawrender.c b/project/jni/sdl-1.3/src/video/win32/SDL_ceddrawrender.c deleted file mode 100644 index 1b2fd1270..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_ceddrawrender.c +++ /dev/null @@ -1,835 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Stefan Klug - klug.stefan@gmx.de -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_DDRAW - -#include "SDL_win32video.h" -#include "../SDL_yuv_sw_c.h" - -#if 0 -#define DDRAW_LOG(...) printf(__VA_ARGS__) -#else -#define DDRAW_LOG(...) -#endif - - -/* DirectDraw renderer implementation */ - -static SDL_Renderer *DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags); -static int DDRAW_DisplayModeChanged(SDL_Renderer * renderer); -static int DDRAW_CreateTexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static int DDRAW_QueryTexturePixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int DDRAW_SetTextureColorMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int DDRAW_SetTextureAlphaMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int DDRAW_SetTextureBlendMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int DDRAW_SetTextureScaleMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int DDRAW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); -static int DDRAW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch); -static void DDRAW_UnlockTexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void DDRAW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects); -static int DDRAW_RenderPoint(SDL_Renderer * renderer, int x, int y); -static int DDRAW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, - int y2); -static int DDRAW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect); -static int DDRAW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, - const SDL_Rect * dstrect); -static void DDRAW_RenderPresent(SDL_Renderer * renderer); -static void DDRAW_DestroyTexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void DDRAW_DestroyRenderer(SDL_Renderer * renderer); - - -SDL_RenderDriver DDRAW_RenderDriver = { - DDRAW_CreateRenderer, - { - "ddraw", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE), - (SDL_BLENDMODE_NONE), - (SDL_SCALEMODE_NONE), - 0, - {0}, - 0, - 0} -}; - -typedef struct -{ - IDirectDraw *ddraw; - IDirectDrawSurface *primary; -} DDRAW_RenderData; - -typedef struct -{ - RECT lock; - IDirectDrawSurface *surface; -} DDRAW_TextureData; - - -static void -DDRAW_SetError(const char *prefix, HRESULT result) -{ - const char *error; - - switch (result) { - case DDERR_CANTCREATEDC: - error = "CANTCREATEDC"; - break; - case DDERR_CANTLOCKSURFACE: - error = "CANTLOCKSURFACE"; - break; - case DDERR_CLIPPERISUSINGHWND: - error = "CLIPPERISUSINGHWND"; - break; - case DDERR_COLORKEYNOTSET: - error = "COLORKEYNOTSET"; - break; - case DDERR_CURRENTLYNOTAVAIL: - error = "CURRENTLYNOTAVAIL"; - break; - case DDERR_DCALREADYCREATED: - error = "DCALREADYCREATED"; - break; - case DDERR_DEVICEDOESNTOWNSURFACE: - error = "DEVICEDOESNTOWNSURFACE"; - break; - case DDERR_DIRECTDRAWALREADYCREATED: - error = "DIRECTDRAWALREADYCREATED"; - break; - case DDERR_EXCLUSIVEMODEALREADYSET: - error = "EXCLUSIVEMODEALREADYSET"; - break; - case DDERR_GENERIC: - error = "GENERIC"; - break; - case DDERR_HEIGHTALIGN: - error = "HEIGHTALIGN"; - break; - case DDERR_IMPLICITLYCREATED: - error = "IMPLICITLYCREATED"; - break; - case DDERR_INCOMPATIBLEPRIMARY: - error = "INCOMPATIBLEPRIMARY"; - break; - case DDERR_INVALIDCAPS: - error = "INVALIDCAPS"; - break; - case DDERR_INVALIDCLIPLIST: - error = "INVALIDCLIPLIST"; - break; - case DDERR_INVALIDMODE: - error = "INVALIDMODE"; - break; - case DDERR_INVALIDOBJECT: - error = "INVALIDOBJECT"; - break; - case DDERR_INVALIDPARAMS: - error = "INVALIDPARAMS"; - break; - case DDERR_INVALIDPIXELFORMAT: - error = "INVALIDPIXELFORMAT"; - break; - case DDERR_INVALIDPOSITION: - error = "INVALIDPOSITION"; - break; - case DDERR_INVALIDRECT: - error = "INVALIDRECT"; - break; - case DDERR_LOCKEDSURFACES: - error = "LOCKEDSURFACES"; - break; - case DDERR_MOREDATA: - error = "MOREDATA"; - break; - case DDERR_NOALPHAHW: - error = "NOALPHAHW"; - break; - case DDERR_NOBLTHW: - error = "NOBLTHW"; - break; - case DDERR_NOCLIPLIST: - error = "NOCLIPLIST"; - break; - case DDERR_NOCLIPPERATTACHED: - error = "NOCLIPPERATTACHED"; - break; - case DDERR_NOCOLORCONVHW: - error = "NOCOLORCONVHW"; - break; - case DDERR_NOCOLORKEYHW: - error = "NOCOLORKEYHW"; - break; - case DDERR_NOCOOPERATIVELEVELSET: - error = "NOCOOPERATIVELEVELSET"; - break; - case DDERR_NODC: - error = "NODC"; - break; - case DDERR_NOFLIPHW: - error = "NOFLIPHW"; - break; - case DDERR_NOOVERLAYDEST: - error = "NOOVERLAYDEST"; - break; - case DDERR_NOOVERLAYHW: - error = "NOOVERLAYHW"; - break; - case DDERR_NOPALETTEATTACHED: - error = "NOPALETTEATTACHED"; - break; - case DDERR_NOPALETTEHW: - error = "NOPALETTEHW"; - break; - case DDERR_NORASTEROPHW: - error = "NORASTEROPHW"; - break; - case DDERR_NOSTRETCHHW: - error = "NOSTRETCHHW"; - break; - case DDERR_NOTAOVERLAYSURFACE: - error = "NOTAOVERLAYSURFACE"; - break; - case DDERR_NOTFLIPPABLE: - error = "NOTFLIPPABLE"; - break; - case DDERR_NOTFOUND: - error = "NOTFOUND"; - break; - case DDERR_NOTLOCKED: - error = "NOTLOCKED"; - break; - case DDERR_NOTPALETTIZED: - error = "NOTPALETTIZED"; - break; - case DDERR_NOVSYNCHW: - error = "NOVSYNCHW"; - break; - case DDERR_NOZOVERLAYHW: - error = "NOZOVERLAYHW"; - break; - case DDERR_OUTOFCAPS: - error = "OUTOFCAPS"; - break; - case DDERR_OUTOFMEMORY: - error = "OUTOFMEMORY"; - break; - case DDERR_OUTOFVIDEOMEMORY: - error = "OUTOFVIDEOMEMORY"; - break; - case DDERR_OVERLAPPINGRECTS: - error = "OVERLAPPINGRECTS"; - break; - case DDERR_OVERLAYNOTVISIBLE: - error = "OVERLAYNOTVISIBLE"; - break; - case DDERR_PALETTEBUSY: - error = "PALETTEBUSY"; - break; - case DDERR_PRIMARYSURFACEALREADYEXISTS: - error = "PRIMARYSURFACEALREADYEXISTS"; - break; - case DDERR_REGIONTOOSMALL: - error = "REGIONTOOSMALL"; - break; - case DDERR_SURFACEBUSY: - error = "SURFACEBUSY"; - break; - case DDERR_SURFACELOST: - error = "SURFACELOST"; - break; - case DDERR_TOOBIGHEIGHT: - error = "TOOBIGHEIGHT"; - break; - case DDERR_TOOBIGSIZE: - error = "TOOBIGSIZE"; - break; - case DDERR_TOOBIGWIDTH: - error = "TOOBIGWIDTH"; - break; - case DDERR_UNSUPPORTED: - error = "UNSUPPORTED"; - break; - case DDERR_UNSUPPORTEDFORMAT: - error = "UNSUPPORTEDFORMAT"; - break; - case DDERR_VERTICALBLANKINPROGRESS: - error = "VERTICALBLANKINPROGRESS"; - break; - case DDERR_VIDEONOTACTIVE: - error = "VIDEONOTACTIVE"; - break; - case DDERR_WASSTILLDRAWING: - error = "WASSTILLDRAWING"; - break; - case DDERR_WRONGMODE: - error = "WRONGMODE"; - break; - default: - error = "UNKNOWN"; - break; - } - SDL_SetError("%s: %s", prefix, error); -} - -static SDL_bool -PixelFormatToDDPIXELFORMAT(Uint32 format, LPDDPIXELFORMAT dst) -{ - SDL_zerop(dst); - dst->dwSize = sizeof(*dst); - - if (SDL_ISPIXELFORMAT_FOURCC(format)) { - dst->dwFlags = DDPF_FOURCC; - dst->dwFourCC = format; - } else if (SDL_ISPIXELFORMAT_INDEXED(format)) { - SDL_SetError("Indexed pixelformats are not supported."); - return SDL_FALSE; - } else { - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - if (!SDL_PixelFormatEnumToMasks - (format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("pixelformat not supported"); - return SDL_FALSE; - } - - if (!Rmask && !Gmask && !Bmask) { - dst->dwFlags = DDPF_ALPHA; - dst->dwAlphaBitDepth = bpp; - } else { - dst->dwFlags = DDPF_RGB; - dst->dwRGBBitCount = bpp; - dst->dwRBitMask = Rmask; - dst->dwGBitMask = Gmask; - dst->dwBBitMask = Bmask; - - if (Amask) { - dst->dwFlags |= DDPF_ALPHAPIXELS; - dst->dwRGBAlphaBitMask = Amask; - } - } - } - - return SDL_TRUE; -} - -static SDL_bool -DDRAW_IsTextureFormatAvailable(IDirectDraw * ddraw, Uint32 display_format, - Uint32 texture_format) -{ - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if (SDL_ISPIXELFORMAT_FOURCC(texture_format)) { - //TODO I don't expect DDRAW to support all 4CC formats, but I don't know which ones - return SDL_TRUE; - } - //These are only basic checks - if (SDL_ISPIXELFORMAT_INDEXED(texture_format)) { - return SDL_FALSE; - } - - if (!SDL_PixelFormatEnumToMasks - (texture_format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - return SDL_FALSE; - } - - switch (bpp) { - case 4: - case 8: - case 16: - case 24: - case 32: - break; - default: - return SDL_FALSE; - } - - return SDL_TRUE; -} - -void -DDRAW_AddRenderDriver(_THIS) -{ - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_RendererInfo *info = &DDRAW_RenderDriver.info; - SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; - - if (data->ddraw) { - int i; - int formats[] = { - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB332, - SDL_PIXELFORMAT_RGB444, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_ARGB4444, - SDL_PIXELFORMAT_ARGB1555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_ARGB2101010, - }; - - for (i = 0; i < SDL_arraysize(formats); ++i) { - if (DDRAW_IsTextureFormatAvailable - (data->ddraw, mode->format, formats[i])) { - info->texture_formats[info->num_texture_formats++] = - formats[i]; - } - } - - //TODO the fourcc formats should get fetched from IDirectDraw::GetFourCCCodes - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_YV12; - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_IYUV; - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_YUY2; - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_UYVY; - info->texture_formats[info->num_texture_formats++] = - SDL_PIXELFORMAT_YVYU; - - for (i = 0; i < _this->num_displays; ++i) - SDL_AddRenderDriver(&_this->displays[i], &DDRAW_RenderDriver); - } - } -} - -SDL_Renderer * -DDRAW_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - SDL_VideoDisplay *display = window->display; - SDL_VideoData *videodata = (SDL_VideoData *) display->device->driverdata; - SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; - SDL_Renderer *renderer; - DDRAW_RenderData *data; - HRESULT result; - DDSURFACEDESC ddsd; - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (DDRAW_RenderData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - DDRAW_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - data->ddraw = videodata->ddraw; - - videodata->render = RENDER_DDRAW; - - renderer->DisplayModeChanged = DDRAW_DisplayModeChanged; - renderer->CreateTexture = DDRAW_CreateTexture; - renderer->QueryTexturePixels = DDRAW_QueryTexturePixels; - - renderer->SetTextureColorMod = DDRAW_SetTextureColorMod; - renderer->SetTextureAlphaMod = DDRAW_SetTextureAlphaMod; - renderer->SetTextureBlendMode = DDRAW_SetTextureBlendMode; - renderer->SetTextureScaleMode = DDRAW_SetTextureScaleMode; - renderer->UpdateTexture = DDRAW_UpdateTexture; - renderer->LockTexture = DDRAW_LockTexture; - renderer->UnlockTexture = DDRAW_UnlockTexture; - renderer->DirtyTexture = DDRAW_DirtyTexture; - renderer->RenderPoint = DDRAW_RenderPoint; - renderer->RenderLine = DDRAW_RenderLine; - renderer->RenderFill = DDRAW_RenderFill; - renderer->RenderCopy = DDRAW_RenderCopy; - renderer->RenderPresent = DDRAW_RenderPresent; - renderer->DestroyTexture = DDRAW_DestroyTexture; - renderer->DestroyRenderer = DDRAW_DestroyRenderer; - renderer->info = DDRAW_RenderDriver.info; - renderer->window = window; - renderer->driverdata = data; - - renderer->info.flags = SDL_RENDERER_ACCELERATED; - - SDL_zero(ddsd); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_CAPS; - - if (window->flags & SDL_WINDOW_FULLSCREEN) { - ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; - } else { - //TODO handle non fullscreen - SDL_SetError("DirectDraw renderer has only fullscreen implemented"); - DDRAW_DestroyRenderer(renderer); - return NULL; - } - - if (flags & SDL_RENDERER_PRESENTFLIP2) { - ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT; - ddsd.dwBackBufferCount = 2; - } else if (flags & SDL_RENDERER_PRESENTFLIP3) { - ddsd.dwFlags |= DDSD_BACKBUFFERCOUNT; - ddsd.dwBackBufferCount = 3; - } else if (flags & SDL_RENDERER_PRESENTCOPY) { - //TODO what is the best approximation to this mode - } else { - - } - - if (flags & SDL_RENDERER_PRESENTVSYNC) { - SDL_SetError("DirectDraw renderer with v-sync is not implemented"); - DDRAW_DestroyRenderer(renderer); - return NULL; - } - - result = - data->ddraw->lpVtbl->SetCooperativeLevel(data->ddraw, - windowdata->hwnd, - DDSCL_NORMAL); - if (result != DD_OK) { - DDRAW_SetError("CreateDevice()", result); - DDRAW_DestroyRenderer(renderer); - return NULL; - } - - result = - data->ddraw->lpVtbl->CreateSurface(data->ddraw, &ddsd, &data->primary, - NULL); - if (result != DD_OK) { - DDRAW_SetError("CreateDevice()", result); - DDRAW_DestroyRenderer(renderer); - return NULL; - } - - return renderer; -} - -static int -DDRAW_Reset(SDL_Renderer * renderer) -{ - //TODO implement - /*D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - HRESULT result; - - result = IDirect3DDevice9_Reset(data->device, &data->pparams); - if (FAILED(result)) { - if (result == D3DERR_DEVICELOST) { - /* Don't worry about it, we'll reset later... * - return 0; - } else { - D3D_SetError("Reset()", result); - return -1; - } - } - IDirect3DDevice9_SetVertexShader(data->device, NULL); - IDirect3DDevice9_SetFVF(data->device, - D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_CULLMODE, - D3DCULL_NONE); - IDirect3DDevice9_SetRenderState(data->device, D3DRS_LIGHTING, FALSE); */ - return 0; -} - -static int -DDRAW_DisplayModeChanged(SDL_Renderer * renderer) -{ - //TODO implement - /*D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - - data->pparams.BackBufferWidth = window->w; - data->pparams.BackBufferHeight = window->h; - if (window->flags & SDL_WINDOW_FULLSCREEN) { - data->pparams.BackBufferFormat = - PixelFormatToD3DFMT(display->fullscreen_mode.format); - } else { - data->pparams.BackBufferFormat = D3DFMT_UNKNOWN; - } - return D3D_Reset(renderer); */ - return 0; -} - -static int -DDRAW_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - DDRAW_RenderData *renderdata = (DDRAW_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - Uint32 display_format = display->current_mode.format; - DDRAW_TextureData *data; - DDSURFACEDESC ddsd; - HRESULT result; - - data = (DDRAW_TextureData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - SDL_OutOfMemory(); - return -1; - } - - SDL_zero(ddsd); - ddsd.dwSize = sizeof(ddsd); - ddsd.dwFlags = DDSD_PIXELFORMAT | DDSD_HEIGHT | DDSD_WIDTH; - ddsd.dwWidth = texture->w; - ddsd.dwHeight = texture->h; - - - if (!PixelFormatToDDPIXELFORMAT(texture->format, &ddsd.ddpfPixelFormat)) { - SDL_free(data); - return -1; - } - - texture->driverdata = data; - - result = - renderdata->ddraw->lpVtbl->CreateSurface(renderdata->ddraw, &ddsd, - &data->surface, NULL); - if (result != DD_OK) { - SDL_free(data); - DDRAW_SetError("CreateTexture", result); - return -1; - } - - return 0; -} - -static int -DDRAW_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - //TODO implement - SDL_SetError("QueryTexturePixels is not implemented"); - return -1; -} - -static int -DDRAW_SetTextureColorMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -DDRAW_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -DDRAW_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->blendMode) { - case SDL_BLENDMODE_NONE: - return 0; - default: - SDL_Unsupported(); - texture->blendMode = SDL_BLENDMODE_NONE; - return -1; - } -} - -static int -DDRAW_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: - default: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_NONE; - return -1; - } - return 0; -} - -static int -DDRAW_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - DDRAW_TextureData *data = (DDRAW_TextureData *) texture->driverdata; - - //TODO implement - SDL_SetError("UpdateTexture is not implemented"); - return 0; -} - -static int -DDRAW_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - DDRAW_TextureData *data = (DDRAW_TextureData *) texture->driverdata; - HRESULT result; - DDSURFACEDESC ddsd; - - SDL_zero(ddsd); - ddsd.dwSize = sizeof(ddsd); - - /** - * On a Axim x51v locking a subrect returns the startaddress of the whole surface, - * wheras on my ASUS MyPal 696 the startaddress of the locked area is returned, - * thats why I always lock the whole surface and calculate the pixels pointer by hand. - * This shouldn't be a speed problem, as multiple locks aren't available on DDraw Mobile - * see http://msdn.microsoft.com/en-us/library/ms858221.aspx - */ - - result = data->surface->lpVtbl->Lock(data->surface, NULL, &ddsd, 0, NULL); - if (result != DD_OK) { - DDRAW_SetError("LockRect()", result); - return -1; - } - - *pixels = ddsd.lpSurface + rect->y * ddsd.lPitch + rect->x * ddsd.lXPitch; - *pitch = ddsd.lPitch; - return 0; -} - -static void -DDRAW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - DDRAW_TextureData *data = (DDRAW_TextureData *) texture->driverdata; - - data->surface->lpVtbl->Unlock(data->surface, NULL); -} - -static void -DDRAW_DirtyTexture(SDL_Renderer * renderer, SDL_Texture * texture, - int numrects, const SDL_Rect * rects) -{ -} - -static void -DDRAW_SetBlendMode(DDRAW_RenderData * data, int blendMode) -{ - switch (blendMode) { - - } -} - -static int -DDRAW_RenderPoint(SDL_Renderer * renderer, int x, int y) -{ - return -1; -} - -static int -DDRAW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2) -{ - return -1; -} - -static int -DDRAW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect) -{ - return -1; -} - -static int -DDRAW_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - DDRAW_RenderData *data = (DDRAW_RenderData *) renderer->driverdata; - DDRAW_TextureData *texturedata = - (DDRAW_TextureData *) texture->driverdata; - HRESULT result; - RECT srcr; - RECT dstr; - DDBLTFX bltfx; - - srcr.left = srcrect->x; - srcr.top = srcrect->y; - srcr.right = srcrect->x + srcrect->w; - srcr.bottom = srcrect->y + srcrect->h; - - dstr.left = dstrect->x; - dstr.top = dstrect->y; - dstr.right = dstrect->x + dstrect->w; - dstr.bottom = dstrect->y + dstrect->h; - - SDL_zero(bltfx); - bltfx.dwSize = sizeof(bltfx); - bltfx.dwROP = SRCCOPY; - - data->primary->lpVtbl->Blt(data->primary, &dstr, texturedata->surface, - &srcr, DDBLT_ROP, &bltfx); - - return 0; -} - -static void -DDRAW_RenderPresent(SDL_Renderer * renderer) -{ - DDRAW_RenderData *data = (DDRAW_RenderData *) renderer->driverdata; - HRESULT result; - - return; - - result = - data->primary->lpVtbl->Flip(data->primary, NULL, DDFLIP_INTERVAL1); - if (result != DD_OK) { - DDRAW_SetError("Present()", result); - } -} - -static void -DDRAW_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - DDRAW_TextureData *data = (DDRAW_TextureData *) texture->driverdata; - - if (!data) { - return; - } - - data->surface->lpVtbl->Release(data->surface); - SDL_free(data); - texture->driverdata = NULL; -} - -static void -DDRAW_DestroyRenderer(SDL_Renderer * renderer) -{ - DDRAW_RenderData *data = (DDRAW_RenderData *) renderer->driverdata; - - if (data) { - data->primary->lpVtbl->Release(data->primary); - SDL_free(data); - } - SDL_free(renderer); -} - -#endif /* SDL_VIDEO_RENDER_DDRAW */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_ceddrawrender.h b/project/jni/sdl-1.3/src/video/win32/SDL_ceddrawrender.h deleted file mode 100644 index 3f8d88221..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_ceddrawrender.h +++ /dev/null @@ -1,31 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Stefan Klug - klug.stefan@gmx.de -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_DDRAW -extern void DDRAW_AddRenderDriver(_THIS); -#endif - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_d3drender.h b/project/jni/sdl-1.3/src/video/win32/SDL_d3drender.h deleted file mode 100644 index 16d81aa38..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_d3drender.h +++ /dev/null @@ -1,28 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_D3D -extern void D3D_AddRenderDriver(_THIS); -#endif - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_gapirender.c b/project/jni/sdl-1.3/src/video/win32/SDL_gapirender.c deleted file mode 100644 index 8a1f4924d..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_gapirender.c +++ /dev/null @@ -1,1281 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2010 by Andrey Afletdinov * - * * - * WinCE RAW/GAPI video driver * - * * - * Part of the SDL - (Simple DirectMedia Layer) * - * http://www.libsdl.org * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ - -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_GAPI - -#include "SDL_win32video.h" -#include "SDL_win32window.h" -#include "../SDL_yuv_sw_c.h" - -// RawFrameBufferInfo -typedef struct -{ - WORD wFormat; - WORD wBPP; - VOID *pFramePointer; - int cxStride; - int cyStride; - int cxPixels; - int cyPixels; -} RawFrameBufferInfo; - -// GXDeviceInfo -typedef struct -{ - long Version; - void* pvFrameBuffer; - unsigned long cbStride; - unsigned long cxWidth; - unsigned long cyHeight; - unsigned long cBPP; - unsigned long ffFormat; - char unknown[0x84 - 7 * 4]; -} GXDeviceInfo; - -// wince: GXDisplayProperties -struct GXDisplayProperties -{ - DWORD cxWidth; - DWORD cyHeight; - long cbxPitch; - long cbyPitch; - long cBPP; - DWORD ffFormat; -}; - -// gx.dll -typedef int (*PFNGXOpenDisplay)(HWND hWnd, DWORD dwFlags); -typedef int (*PFNGXCloseDisplay)(); -typedef void* (*PFNGXBeginDraw)(); -typedef int (*PFNGXEndDraw)(); -typedef struct GXDisplayProperties (*PFNGXGetDisplayProperties)(); -typedef int (*PFNGXSuspend)(); -typedef int (*PFNGXResume)(); - -typedef struct -{ - // gx.dll - HMODULE hGapiLib; - PFNGXOpenDisplay GXOpenDisplay; - PFNGXCloseDisplay GXCloseDisplay; - PFNGXBeginDraw GXBeginDraw; - PFNGXEndDraw GXEndDraw; - PFNGXGetDisplayProperties GXGetDisplayProperties; - PFNGXSuspend GXSuspend; - PFNGXResume GXResume; -} GapiInfo; - -//#ifndef DM_DISPLAYORIENTATION -//#define DM_DISPLAYORIENTATION 0x00800000L -//#endif - -#define FORMAT_565 1 -#define FORMAT_555 2 -#define FORMAT_OTHER 3 - -#define GETRAWFRAMEBUFFER 0x00020001 -#define GETGXINFO 0x00020000 - -#define kfPalette 0x10 -#define kfDirect 0x20 -#define kfDirect555 0x40 -#define kfDirect565 0x80 - -#define GX_FULLSCREEN 0x01 - -enum ScreenOrientation { ORIENTATION_UNKNOWN = -1, ORIENTATION_UP = DMDO_0, ORIENTATION_DOWN = DMDO_180, ORIENTATION_LEFT = DMDO_270, ORIENTATION_RIGHT = DMDO_90 }; -enum ScreenGeometry { GEOMETRY_UNKNOWN, GEOMETRY_PORTRAIT, GEOMETRY_LANDSCAPE, GEOMETRY_SQUARE }; -enum FrameBufferFlags { FB_SKIP_OFFSET = 0x0001, FB_RAW_MODE = 0x0002, FB_SUSPENDED = 0x0004 }; - -// private framebuffer info -typedef struct -{ - int width; - int height; - int xpitch; - int ypitch; - int offset; -} FrameBufferInfo; - -// private display data -typedef struct -{ - unsigned char* pixels; // video memory - int format; // video format - FrameBufferInfo fb; // framebuffer geometry - GapiInfo* gapi; // GAPI module - int userOrientation; - int systemOrientation; - int hardwareGeometry; - int flags; // fb flags - float scale; // scale pointer position - int debug; - -} WINCE_RenderData; - -typedef struct -{ - SDL_SW_YUVTexture *yuv; - Uint32 format; - void *pixels; - int pitch; - -} WINCE_TextureData; - - -// system func -SDL_Renderer* WINCE_CreateRenderer(SDL_Window* window, Uint32 flags); -void WINCE_DestroyRenderer(SDL_Renderer* renderer); - -int WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture); -void WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture); -int WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch); -int WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch); -int WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch); -void WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture); - -int WINCE_Available(void); -void WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height); - -int WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect); -void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible); - -void WINCE_RenderPresent(SDL_Renderer* renderer); -int WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count); -int WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count); -int WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count); -int WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count); - -void WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt); -void WINCE_DumpVideoInfo(WINCE_RenderData* data); -void WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height); -void WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height); -void WINCE_SquareTransform(WINCE_RenderData* data, int width, int height); -int WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug); -int WINCE_GetDMOrientation(void); -int WINCE_SetDMOrientation(int orientation); -void WINCE_UpdateYUVTextureData(SDL_Texture* texture); - -// gapi engine specific -int GAPI_Init(WINCE_RenderData* data, HWND hwnd); -void GAPI_Quit(WINCE_RenderData* data); - -// raw engine specific -int RAW_Init(WINCE_RenderData* data); -void RAW_Quit(WINCE_RenderData* data); - -// tools -void FrameBufferRotate(FrameBufferInfo* src, int orientation); -int GetFrameBufferOrientation(const FrameBufferInfo* src); -void PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation); -void FrameBufferInitialize(FrameBufferInfo* fb); -void FrameBufferDumpInfo(const FrameBufferInfo* fb, const char*); -const char* GetOrientationName(int orientation); -void UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width); - -// stdlib -inline int __abs(int x){ return x < 0 ? -x : x; }; -inline void __swap(int* a, int* b){ int t = *a; *a = *b; *b = t; }; - -#define GAPI_RENDER_NAME "gapi" -#define RAW_RENDER_NAME "raw" -// -SDL_RenderDriver GAPI_RenderDriver = { - WINCE_CreateRenderer, - { - GAPI_RENDER_NAME, - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD), - (SDL_TEXTUREMODULATE_NONE), - (SDL_BLENDMODE_NONE), - (SDL_SCALEMODE_NONE), - 7, - { - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_YUY2, - SDL_PIXELFORMAT_UYVY, - SDL_PIXELFORMAT_YVYU - }, - 0, - 0 - } -}; - -SDL_RenderDriver RAW_RenderDriver = { - WINCE_CreateRenderer, - { - RAW_RENDER_NAME, - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD), - (SDL_TEXTUREMODULATE_NONE), - (SDL_BLENDMODE_NONE), - (SDL_SCALEMODE_NONE), - 7, - { - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_YUY2, - SDL_PIXELFORMAT_UYVY, - SDL_PIXELFORMAT_YVYU - }, - 0, - 0 - } -}; - -int WINCE_Available(void) -{ - const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER"); - - // raw check - RawFrameBufferInfo rfbi = { 0 }; - HDC hdc = GetDC(NULL); - int render_raw = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi); - ReleaseDC(NULL, hdc); - - if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 && - rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0) - render_raw = 1; - - if(preferably && 0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0 != render_raw; - - // gapi check - HMODULE render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll")); - if(0 == render_gapi) - render_gapi = LoadLibrary(TEXT("gx.dll")); - FreeLibrary(render_gapi); - - if(preferably && 0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0 != render_gapi; - - return 0 != render_raw || 0 != render_gapi; -} - -void WINCE_AddRenderDriver(_THIS) -{ - HDC hdc; - HMODULE render_gapi; - int render_raw, ii; - const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER"); - - // raw check - RawFrameBufferInfo rfbi = { 0 }; - hdc = GetDC(NULL); - render_raw = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi); - ReleaseDC(NULL, hdc); - - if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 && - rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0) - render_raw = 1; - - // gapi check - render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll")); - if(0 == render_gapi) - render_gapi = LoadLibrary(TEXT("gx.dll")); - - if(render_gapi) - FreeLibrary(render_gapi); - - for(ii = 0; ii < _this->num_displays; ++ii) - { - if(preferably) - { - if(0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME) && render_raw) - SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver); - else - if(0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME) && render_gapi) - SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver); - } - else - { - if(render_raw) - SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver); - if(render_gapi) - SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver); - } - } -} - -SDL_Renderer* WINCE_CreateRenderer(SDL_Window* window, Uint32 flags) -{ - SDL_VideoDisplay* display = window->display; - SDL_DisplayMode* displayMode = &display->current_mode; - SDL_WindowData* windowdata = (SDL_WindowData *) window->driverdata; - SDL_Renderer* renderer; - WINCE_RenderData* data; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - if(!(window->flags & SDL_WINDOW_FULLSCREEN)) - window->flags |= SDL_WINDOW_FULLSCREEN; - - if(!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) - { - SDL_SetError("Unknown display format"); - return NULL; - } - - switch(window->fullscreen_mode.format) - { - case SDL_PIXELFORMAT_RGB555: - case SDL_PIXELFORMAT_RGB565: - break; - - default: - SDL_SetError("Support only 16 or 15 bpp"); - return NULL; - } - - renderer = (SDL_Renderer*) SDL_calloc(1, sizeof(SDL_Renderer)); - if(!renderer) - { - SDL_OutOfMemory(); - return NULL; - } - - data = (WINCE_RenderData*) SDL_calloc(1, sizeof(WINCE_RenderData)); - if(!data) - { - WINCE_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - - // initialize internal engine - if(!RAW_Init(data) && !GAPI_Init(data, windowdata->hwnd)) - { - WINCE_DestroyRenderer(renderer); - return NULL; - } - - - // set debug - data->debug = SDL_getenv("DEBUG_VIDEO_GAPI") || SDL_getenv("GAPI_RENDERER_DEBUG") ? 1 : 0; -#if defined(DEBUG_VIDEO_GAPI) || defined(GAPI_RENDERER_DEBUG) - data->debug = 1; -#endif - - windowdata->videodata->render = data->gapi ? RENDER_GAPI : RENDER_RAW; - windowdata->videodata->CoordTransform = WINCE_PointerCoordinateTransform; - - window->display->device->MaximizeWindow = NULL; - window->display->device->MinimizeWindow = NULL; - - WINCE_SetupOrientation(data, window->w, window->h); - - renderer->CreateTexture = WINCE_CreateTexture; - renderer->DestroyTexture = WINCE_DestroyTexture; - renderer->QueryTexturePixels = WINCE_QueryTexturePixels; - renderer->UpdateTexture = WINCE_UpdateTexture; - renderer->LockTexture = WINCE_LockTexture; - renderer->UnlockTexture = WINCE_UnlockTexture; - - renderer->RenderCopy = WINCE_RenderCopy; - renderer->DestroyRenderer = WINCE_DestroyRenderer; - - renderer->RenderPresent = WINCE_RenderPresent; - renderer->RenderDrawPoints = WINCE_RenderDrawPoints; - renderer->RenderDrawLines = WINCE_RenderDrawLines; - renderer->RenderDrawRects = WINCE_RenderDrawRects; - renderer->RenderFillRects = WINCE_RenderFillRects; - - renderer->info = data->gapi ? GAPI_RenderDriver.info : RAW_RenderDriver.info; - - renderer->window = window; - renderer->driverdata = data; - - return renderer; -} - -void WINCE_DestroyRenderer(SDL_Renderer* renderer) -{ - WINCE_RenderData *renderdata = (WINCE_RenderData*) renderer->driverdata; - - if(renderdata) - { - if(renderdata->gapi) - GAPI_Quit(renderdata); - else - RAW_Quit(renderdata); - - SDL_free(renderdata); - } - - SDL_free(renderer); -} - -int WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture) -{ - WINCE_TextureData* texturedata = (WINCE_TextureData*) SDL_calloc(1, sizeof(WINCE_TextureData)); - if(NULL == texturedata) - { - SDL_OutOfMemory(); - return -1; - } - - texturedata->pitch = texture->w * SDL_BYTESPERPIXEL(texture->format); - texturedata->pixels = SDL_malloc(texture->h * texturedata->pitch); - if(NULL == texturedata->pixels) - { - SDL_OutOfMemory(); - return -1; - } - - if(SDL_ISPIXELFORMAT_FOURCC(texture->format)) - { - texturedata->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); - if(NULL == texturedata->yuv) - { - SDL_OutOfMemory(); - return -1; - } - SDL_Window* window = renderer->window; - SDL_VideoDisplay* display = window->display; - texturedata->format = display->current_mode.format; - } - else - { - texturedata->yuv = NULL; - texturedata->format = texture->format; - } - - texture->driverdata = texturedata; - - return 0; -} - -void WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture) -{ - WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata; - - if(texturedata) - { - if(texturedata->yuv) SDL_SW_DestroyYUVTexture(texturedata->yuv); - if(texturedata->pixels) SDL_free(texturedata->pixels); - SDL_free(texturedata); - texture->driverdata = NULL; - } -} - -int WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch) -{ - WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata; - - if(texturedata->yuv) - return SDL_SW_QueryYUVTexturePixels(texturedata->yuv, pixels, pitch); - - *pixels = texturedata->pixels; - *pitch = texturedata->pitch; - - return 0; -} - -int WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch) -{ - WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata; - - if(texturedata->yuv) - { - if(SDL_SW_UpdateYUVTexture(texturedata->yuv, rect, pixels, pitch) < 0) - return -1; - WINCE_UpdateYUVTextureData(texture); - return 0; - } - - if(0 < rect->w && 0 < rect->h) - { - const unsigned char *src = ((const unsigned char*) pixels); - unsigned char *dst = ((unsigned char*) texturedata->pixels) + - rect->y * texturedata->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format); - int length = rect->w * SDL_BYTESPERPIXEL(texture->format); - int height = rect->h; - - while(height--) - { - SDL_memcpy(dst, src, length); - dst += texturedata->pitch; - src += pitch; - } - } - - return 0; -} - -int WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch) -{ - WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata; - - if(texturedata->yuv) - return SDL_SW_LockYUVTexture(texturedata->yuv, rect, dirty, pixels, pitch); - - *pixels = (void *) ((unsigned char*) texturedata->pixels + - rect->y * texturedata->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch = texturedata->pitch; -} - -void WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture) -{ - WINCE_TextureData *texturedata = (WINCE_TextureData*) texture->driverdata; - - if(texturedata->yuv) - { - SDL_SW_UnlockYUVTexture(texturedata->yuv); - WINCE_UpdateYUVTextureData(texture); - } -} - -int WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect) -{ - WINCE_RenderData* dstdata = (WINCE_RenderData*) renderer->driverdata; - WINCE_TextureData* srcdata = (WINCE_TextureData*) texture->driverdata; - - if((dstdata->flags & FB_SUSPENDED) || - 0 >= srect->w || 0 >= srect->h) return; - - // lock gapi - if(dstdata->gapi) dstdata->gapi->GXBeginDraw(); - - const unsigned char *src = ((const unsigned char*) srcdata->pixels); - unsigned char *dst = dstdata->pixels + (dstdata->flags & FB_SKIP_OFFSET ? 0 : dstdata->fb.offset) + - drect->y * dstdata->fb.ypitch + - drect->x * dstdata->fb.xpitch; - if(srcdata->yuv) - { - return SDL_SW_CopyYUVToRGB(srcdata->yuv, - srect, srcdata->format, - drect->w, drect->h, dst, - dstdata->fb.ypitch); - } - else - { - int height = drect->h; - int length = drect->w * SDL_BYTESPERPIXEL(texture->format); // in bytes - - while(height--) - { - switch(SDL_BYTESPERPIXEL(texture->format)) - { - case 2: UpdateLine16to16(&dstdata->fb, (Uint16*) src, (Uint16*) dst, length >> 1); break; - - default: break; - } - - dst += dstdata->fb.ypitch; - src += srcdata->pitch; - } - } - - // unlock gapi - if(dstdata->gapi) dstdata->gapi->GXEndDraw(); - - return 0; -} - -void WINCE_RenderPresent(SDL_Renderer* renderer) -{ -} - -int WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count) -{ - SDL_Unsupported(); - return -1; -} - -int WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count) -{ - SDL_Unsupported(); - return -1; -} - -int WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count) -{ - SDL_Unsupported(); - return -1; -} - -int WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count) -{ - SDL_Unsupported(); - return -1; -} - - - -void WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height) -{ - const float maxW1 = GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) ? GetSystemMetrics(SM_CXSCREEN) : GetSystemMetrics(SM_CYSCREEN); - const float maxW2 = data->fb.width > data->fb.height ? data->fb.width : data->fb.height; - - // scale define - data->scale = maxW2 / maxW1; - - // init fb values - FrameBufferInitialize(&data->fb); - - // orientation values - data->userOrientation = ORIENTATION_UP; - data->systemOrientation = WINCE_GetDMOrientation(); - data->hardwareGeometry = data->fb.width == data->fb.height ? GEOMETRY_SQUARE : - (data->fb.width < data->fb.height ? GEOMETRY_PORTRAIT : GEOMETRY_LANDSCAPE); - - if(data->debug) - WINCE_DumpVideoInfo(data); - - if(data->systemOrientation == ORIENTATION_UNKNOWN) - data->systemOrientation == ORIENTATION_UP; - - data->userOrientation = ORIENTATION_UP; - - switch(data->hardwareGeometry) - { - case GEOMETRY_PORTRAIT: WINCE_PortraitTransform(data, width, height); break; - case GEOMETRY_LANDSCAPE: WINCE_LandscapeTransform(data, width, height); break; - case GEOMETRY_SQUARE: WINCE_SquareTransform(data, width, height); break; - default: break; - } - - // debug - if(data->debug) - { - printf("\n"); - printf("user video width: %d\n", width); - printf("user video height: %d\n", height); - FrameBufferDumpInfo(&data->fb, "user"); - } -} - -void WINCE_DumpVideoInfo(WINCE_RenderData* data) -{ - // get oem info - WCHAR oemInfo[48]; - SDL_memset(oemInfo, 0, sizeof(oemInfo)); - SystemParametersInfo(SPI_GETOEMINFO, sizeof(oemInfo) - sizeof(WCHAR), oemInfo, 0); - - printf("hardware oem: "); - wprintf(oemInfo); - printf("\n"); - - printf("video driver mode: %s\n", (data->flags & FB_RAW_MODE ? RAW_RENDER_NAME : GAPI_RENDER_NAME)); - printf("GetSystemMetrics(SM_CXSCREEN): %d\n", GetSystemMetrics(SM_CXSCREEN)); - printf("GetSystemMetrics(SM_CYSCREEN): %d\n", GetSystemMetrics(SM_CYSCREEN)); - printf("scale coord: %f\n", data->scale); - - FrameBufferDumpInfo(&data->fb, "hardware"); - - printf("display format: %p\n", data->format); - printf("display bits per pixel: %d\n", SDL_BITSPERPIXEL(data->format)); - printf("display bytes per pixel: %d\n", SDL_BYTESPERPIXEL(data->format)); - printf("display memory: %p\n", data->pixels); - printf("system orientation: %d, %s\n", data->systemOrientation, GetOrientationName(data->systemOrientation)); - printf("hardware geometry: %d\n", data->hardwareGeometry); -} - -void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible) -{ - SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata; - SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; - SDL_Renderer* renderer = (SDL_Renderer*) window->renderer; - - if(visible) - { - if(window->flags & SDL_WINDOW_FULLSCREEN) - { - if(videodata->SHFullScreen) - videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON); - ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE); - } - - ShowWindow(windowdata->hwnd, SW_SHOW); - SetForegroundWindow(windowdata->hwnd); - - if(renderer && - (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW)) - { - WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata; - renderdata->flags &= ~FB_SUSPENDED; - if(renderdata->gapi) renderdata->gapi->GXResume(); - } - } - else - { - if(renderer && - (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW)) - { - WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata; - if(renderdata->gapi) renderdata->gapi->GXSuspend(); - renderdata->flags |= FB_SUSPENDED; - } - - ShowWindow(windowdata->hwnd, SW_HIDE); - - if(window->flags & SDL_WINDOW_FULLSCREEN) - { - if(videodata->SHFullScreen) - videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON); - ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW); - } - } -} - - -void WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt) -{ - WINCE_RenderData* data = (WINCE_RenderData*) window->renderer->driverdata; - - pt->x *= data->scale; - pt->y *= data->scale; - - PointerRotate(pt, &data->fb, data->userOrientation); -} - -void WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height) -{ - if(data->systemOrientation != ORIENTATION_UP) - FrameBufferRotate(&data->fb, data->systemOrientation); - - if(data->fb.width != width || data->fb.height != height) - switch(data->systemOrientation) - { - case ORIENTATION_UP: - case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break; - case ORIENTATION_RIGHT: - case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break; - default: break; - } - - if(data->userOrientation != ORIENTATION_UP) - FrameBufferRotate(&data->fb, data->userOrientation); -} - -void WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height) -{ - switch(data->systemOrientation) - { - case ORIENTATION_UP: FrameBufferRotate(&data->fb, ORIENTATION_LEFT); break; - case ORIENTATION_LEFT:FrameBufferRotate(&data->fb, ORIENTATION_DOWN); break; - case ORIENTATION_DOWN:FrameBufferRotate(&data->fb, ORIENTATION_RIGHT); break; - default: break; - } - - if(data->fb.width != width || data->fb.height != height) - switch(data->systemOrientation) - { - case ORIENTATION_UP: - case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break; - case ORIENTATION_RIGHT: - case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break; - default: break; - } - - if(data->userOrientation != ORIENTATION_UP) - FrameBufferRotate(&data->fb, data->userOrientation); -} - -void WINCE_SquareTransform(WINCE_RenderData* data, int width, int height) -{ - WINCE_PortraitTransform(data, width, height); -} - -int WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug) -{ - // check square - if(GetSystemMetrics(SM_CXSCREEN) == GetSystemMetrics(SM_CYSCREEN) && - fb->width != fb->height) - { - if(fb->width < fb->height) - fb->height = fb->width; - else - if(fb->height < fb->width) - fb->width = fb->height; - } - - // check width - if(__abs(fb->xpitch) == bpp && - fb->width != __abs(fb->ypitch) / bpp) - { - if(fb->height == __abs(fb->ypitch) / bpp) - { - __swap(&fb->width, &fb->height); - - if(debug) - printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height); - } - else - return -1; - } - else - // check height - if(__abs(fb->ypitch) == bpp && - fb->height != __abs(fb->xpitch) / bpp) - { - if(fb->width == __abs(fb->xpitch) / bpp) - { - __swap(&fb->width, &fb->height); - - if(debug) - printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height); - } - else - return -1; - } - - return 0; -} - -void WINCE_UpdateYUVTextureData(SDL_Texture* texture) -{ - WINCE_TextureData* texturedata = (WINCE_TextureData*) texture->driverdata; - SDL_Rect rect; - - rect.x = 0; - rect.y = 0; - rect.w = texture->w; - rect.h = texture->h; - SDL_SW_CopyYUVToRGB(texturedata->yuv, &rect, texturedata->format, texture->w, texture->h, texturedata->pixels, texturedata->pitch); -} - -int GAPI_Init(WINCE_RenderData* data, HWND hwnd) -{ - if(NULL == data->gapi) - { - const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER"); - if(preferably && 0 != SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0; - - data->gapi = (GapiInfo *) SDL_calloc(1, sizeof(GapiInfo)); - if(NULL == data->gapi) - { - SDL_OutOfMemory(); - return 0; - } - - data->gapi->hGapiLib = LoadLibrary(TEXT("\\Windows\\gx.dll")); - if(0 == data->gapi->hGapiLib) - { - data->gapi->hGapiLib = LoadLibrary(TEXT("gx.dll")); - if(0 == data->gapi->hGapiLib) return 0; - } - - // load gapi library -#define LINK(type,name,import) name=(PFN##type)GetProcAddress(data->gapi->hGapiLib,TEXT(import)) - LINK(GXOpenDisplay, data->gapi->GXOpenDisplay, "?GXOpenDisplay@@YAHPAUHWND__@@K@Z"); - LINK(GXCloseDisplay, data->gapi->GXCloseDisplay, "?GXCloseDisplay@@YAHXZ"); - LINK(GXBeginDraw, data->gapi->GXBeginDraw, "?GXBeginDraw@@YAPAXXZ"); - LINK(GXEndDraw, data->gapi->GXEndDraw, "?GXEndDraw@@YAHXZ"); - LINK(GXGetDisplayProperties,data->gapi->GXGetDisplayProperties,"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ"); - LINK(GXSuspend, data->gapi->GXSuspend, "?GXSuspend@@YAHXZ"); - LINK(GXResume, data->gapi->GXResume, "?GXResume@@YAHXZ"); -#undef LINK - - int enable = data->gapi->GXGetDisplayProperties && data->gapi->GXCloseDisplay && data->gapi->GXOpenDisplay && - data->gapi->GXBeginDraw && data->gapi->GXEndDraw && data->gapi->GXSuspend && data->gapi->GXResume; - - if(!enable) - { - SDL_SetError("GAPI_Init: error gx.dll: internal error"); - GAPI_Quit(data); - return 0; - } - - if(0 == data->gapi->GXOpenDisplay(hwnd, GX_FULLSCREEN)) - { - SDL_SetError("GAPI_Init: couldn't initialize GAPI"); - GAPI_Quit(data); - return 0; - } - - struct GXDisplayProperties gxProperties = data->gapi->GXGetDisplayProperties(); - - // fill FrameBufferInfo - data->fb.xpitch = gxProperties.cbxPitch; - data->fb.ypitch = gxProperties.cbyPitch; - data->fb.width = gxProperties.cxWidth; - data->fb.height = gxProperties.cyHeight; - data->fb.offset = 0; - - if((gxProperties.ffFormat & kfDirect565) || 16 == gxProperties.cBPP) - data->format = SDL_PIXELFORMAT_RGB565; - else - if((gxProperties.ffFormat & kfDirect555) || 15 == gxProperties.cBPP) - data->format = SDL_PIXELFORMAT_RGB555; - else - data->format = 0; - - // get pixels - GXDeviceInfo gxInfo = { 0 }; - HDC hdc = GetDC(NULL); - - gxInfo.Version = 100; - int result = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), (char *) &gxInfo); - ReleaseDC(NULL, hdc); - - if(result > 0) - { - // more debug - if(data->debug) - { - printf("GXDeviceInfo.pvFrameBuffer: %p\n", gxInfo.pvFrameBuffer); - printf("GXDeviceInfo.cxWidth: %d\n", gxInfo.cxWidth); - printf("GXDeviceInfo.cyHeight: %d\n", gxInfo.cyHeight); - printf("GXDeviceInfo.cbStride: %d\n", gxInfo.cbStride); - printf("GXDeviceInfo.cBPP: %d\n", gxInfo.cBPP); - printf("GXDeviceInfo.ffFormat: 0x%x\n", gxInfo.ffFormat); - - printf("GXDeviceInfo.unk:\n"); - int ii; for(ii = 0; ii < sizeof(gxInfo.unknown); ++ii) - printf("0x%02hhX,", gxInfo.unknown[ii]); - printf("\n"); - } - - if(gxInfo.ffFormat && gxInfo.ffFormat != gxProperties.ffFormat) - { - if((gxInfo.ffFormat & kfDirect565) || 16 == gxInfo.cBPP) - data->format = SDL_PIXELFORMAT_RGB565; - else - if((gxInfo.ffFormat & kfDirect555) || 15 == gxInfo.cBPP) - data->format = SDL_PIXELFORMAT_RGB555; - } - - data->pixels = gxInfo.pvFrameBuffer; - } - else - { - data->flags |= FB_SKIP_OFFSET; - data->pixels = data->gapi->GXBeginDraw(); - data->gapi->GXEndDraw(); - - if(data->debug) - { - printf("GAPI_Init\n"); - printf("use GXBeginDraw: %p\n", data->pixels); - printf("use skip offset\n"); - } - } - - if(0 == data->format || - 0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug)) - { - SDL_SetError("GAPI_Init: unknown hardware"); - GAPI_Quit(data); - return 0; - } - } - - return data->gapi && data->pixels ? 1 : 0; -} - -void GAPI_Quit(WINCE_RenderData* data) -{ - if(data->gapi) - { - if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay(); - if(data->gapi->hGapiLib) FreeLibrary(data->gapi->hGapiLib); - - SDL_free(data->gapi); - data->gapi = NULL; - } -} - -int RAW_Init(WINCE_RenderData* data) -{ - const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER"); - if(preferably && 0 != SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0; - - RawFrameBufferInfo rfbi = { 0 }; - HDC hdc = GetDC(NULL); - int result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi); - ReleaseDC(NULL, hdc); - - //disable - if(result == 0 || rfbi.pFramePointer == 0 || - rfbi.cxPixels == 0 || rfbi.cyPixels == 0 || - rfbi.cxStride == 0 || rfbi.cyStride == 0) return 0; - - data->flags = FB_RAW_MODE; - - // fill FrameBufferInfo - SDL_memset(&data->fb, 0, sizeof(FrameBufferInfo)); - - data->fb.xpitch = rfbi.cxStride; - data->fb.ypitch = rfbi.cyStride; - data->fb.width = rfbi.cxPixels; - data->fb.height = rfbi.cyPixels; - data->fb.offset = 0; - - if((FORMAT_565 & rfbi.wFormat) || 16 == rfbi.wBPP) - data->format = SDL_PIXELFORMAT_RGB565; - else - if((FORMAT_555 & rfbi.wFormat) || 15 == rfbi.wBPP) - data->format = SDL_PIXELFORMAT_RGB555; - else - data->format = 0; - - if(0 == data->format || - 0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug)) - { - SDL_SetError("RAW_Init: unknown hardware"); - RAW_Quit(data); - return 0; - } - - data->pixels = rfbi.pFramePointer; - - return data->pixels ? 1 : 0; -} - -void RAW_Quit(WINCE_RenderData* data) -{ -} - -void FrameBufferInitialize(FrameBufferInfo* fb) -{ - int orientation = GetFrameBufferOrientation(fb); - - // set correct start offset - switch(orientation) - { - case ORIENTATION_UP: - fb->offset = 0; - break; - - case ORIENTATION_LEFT: - fb->offset = __abs(fb->ypitch * (fb->height - 1)); - break; - - case ORIENTATION_RIGHT: - fb->offset = __abs(fb->xpitch * (fb->width - 1)); - break; - - case ORIENTATION_DOWN: - fb->offset = __abs(fb->xpitch * (fb->width - 1) + - fb->ypitch * (fb->height - 1)); - break; - - default: break; - } - - //if(orientation != ORIENTATION_UP) - switch(orientation) - { - case ORIENTATION_LEFT: FrameBufferRotate(fb, ORIENTATION_RIGHT); break; - case ORIENTATION_RIGHT:FrameBufferRotate(fb, ORIENTATION_LEFT); break; - case ORIENTATION_DOWN: FrameBufferRotate(fb, ORIENTATION_DOWN); break; - - default: break; - } -} - -int GetFrameBufferOrientation(const FrameBufferInfo* src) -{ - if(src->xpitch > 0 && src->ypitch > 0) - return ORIENTATION_UP; - else - if(src->xpitch > 0 && src->ypitch < 0) - return ORIENTATION_LEFT; - else - if(src->xpitch < 0 && src->ypitch > 0) - return ORIENTATION_RIGHT; - else - if(src->xpitch < 0 && src->ypitch < 0) - return ORIENTATION_DOWN; - - return ORIENTATION_UNKNOWN; -} - -void FrameBufferRotate(FrameBufferInfo* dst, int orientation) -{ - FrameBufferInfo src; - // copy dst -> src - SDL_memcpy(&src, dst, sizeof(FrameBufferInfo)); - - switch(orientation) - { - case ORIENTATION_LEFT: - dst->width = src.height; - dst->height = src.width; - dst->xpitch = src.ypitch; - dst->ypitch = -src.xpitch; - dst->offset = src.offset + src.xpitch * (src.width - 1); - break; - - case ORIENTATION_RIGHT: - dst->width = src.height; - dst->height = src.width; - dst->xpitch = -src.ypitch; - dst->ypitch = src.xpitch; - dst->offset = src.offset + src.ypitch * (src.height - 1); - break; - - case ORIENTATION_DOWN: - FrameBufferRotate(dst, ORIENTATION_LEFT); - FrameBufferRotate(dst, ORIENTATION_LEFT); - break; - - default: - break; - } -} - -void PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation) -{ - switch(orientation) - { - case ORIENTATION_UP: - break; - - case ORIENTATION_LEFT: - { - int temp = pt->y; - pt->y = fb->height - pt->x; - pt->x = temp; - } - break; - - case ORIENTATION_RIGHT: - { - int temp = pt->x; - pt->x = fb->width - pt->y; - pt->y = temp; - } - break; - - case ORIENTATION_DOWN: - pt->x = fb->width - pt->x; - pt->y = fb->height - pt->y; - break; - - default: break; - } -} - -const char* GetOrientationName(int orientation) -{ - switch(orientation) - { - case ORIENTATION_UP: return "UP"; - case ORIENTATION_DOWN: return "DOWN"; - case ORIENTATION_LEFT: return "LEFT"; - case ORIENTATION_RIGHT: return "RIGHT"; - default: break; - } - - return "UNKNOWN"; -} - -int WINCE_GetDMOrientation(void) -{ - DEVMODE sDevMode = {0}; - sDevMode.dmSize = sizeof(DEVMODE); - sDevMode.dmFields = DM_DISPLAYORIENTATION; - - // DMDO_0, DMDO_90, DMDO_180, DMDO_270 - if(DISP_CHANGE_BADMODE != ChangeDisplaySettingsEx(NULL, &sDevMode, 0, CDS_TEST, NULL)) - switch(sDevMode.dmDisplayOrientation) - { - case DMDO_0: return DMDO_0; - case DMDO_90: return DMDO_90; - case DMDO_180: return DMDO_180; - case DMDO_270: return DMDO_270; - default: break; - } - - SDL_SetError("WINCE_GetDMOrientation: ChangeDisplaySettingsEx return BADMODE"); - return -1; -} - -int WINCE_SetDMOrientation(int orientation) -{ - DEVMODE sDevMode = {0}; - sDevMode.dmSize = sizeof(DEVMODE); - sDevMode.dmFields = DM_DISPLAYORIENTATION; - - switch(orientation) - { - case DMDO_0: sDevMode.dmDisplayOrientation = DMDO_0; break; - case DMDO_90: sDevMode.dmDisplayOrientation = DMDO_90; break; - case DMDO_180: sDevMode.dmDisplayOrientation = DMDO_180; break; - case DMDO_270: sDevMode.dmDisplayOrientation = DMDO_270; break; - default: return 0; - } - - if(DISP_CHANGE_BADMODE != ChangeDisplaySettingsEx(NULL, &sDevMode, 0, CDS_RESET, NULL)) - return 1; - - SDL_SetError("WINCE_SetDMOrientation: ChangeDisplaySettingsEx return BADMODE"); - return -1; -} - -void FrameBufferDumpInfo(const FrameBufferInfo* fb, const char* name) -{ - printf("%s fb.width: %d\n", name, fb->width); - printf("%s fb.height: %d\n", name, fb->height); - printf("%s fb.xpitch: %d\n", name, fb->xpitch); - printf("%s fb.ypitch: %d\n", name, fb->ypitch); - printf("%s fb.offset: %d\n", name, fb->offset); - - int orientation = GetFrameBufferOrientation(fb); - printf("%s fb.orientation: %d, %s\n", name, orientation, GetOrientationName(orientation)); -} - -void UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width) -{ - if(2 == fb->xpitch) - { - switch(width) - { - case 1: - *dst = *src; - break; - - case 2: - *((Uint32*) dst) = *((Uint32*) src); - break; - - default: - SDL_memcpy(dst, src, width * 2); - break; - } - } - else - if(-2 == fb->xpitch) - { - while(width--) - *dst-- = *src++; - } - else - { - while(width--) - { - *dst = *src++; - dst += fb->xpitch / 2; - } - } -} - -#endif // SDL_VIDEO_RENDER_GAPI diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_gapirender.h b/project/jni/sdl-1.3/src/video/win32/SDL_gapirender.h deleted file mode 100644 index 8eff78f3d..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_gapirender.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Stefan Klug - klug.stefan@gmx.de -*/ -#include "SDL_config.h" - -/* SDL surface based renderer implementation */ - -#if SDL_VIDEO_RENDER_GAPI -extern void WINCE_AddRenderDriver(_THIS); -extern int WINCE_Available(void); -extern void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible); -extern int WINCE_GetDMOrientation(void); -extern int WINCE_SetDMOrientation(int orientation); -#endif - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_gapirender_c.h b/project/jni/sdl-1.3/src/video/win32/SDL_gapirender_c.h deleted file mode 100644 index 9779473e0..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_gapirender_c.h +++ /dev/null @@ -1,24 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Stefan Klug - klug.stefan@gmx.de -*/ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_gdirender.c b/project/jni/sdl-1.3/src/video/win32/SDL_gdirender.c deleted file mode 100644 index 729069d9f..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_gdirender.c +++ /dev/null @@ -1,1127 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_GDI - -#include "SDL_win32video.h" -#include "../SDL_rect_c.h" -#include "../SDL_yuv_sw_c.h" -#include "../SDL_alphamult.h" - -#ifdef _WIN32_WCE -#define NO_GETDIBBITS 1 -#endif - -/* GDI renderer implementation */ - -static SDL_Renderer *GDI_CreateRenderer(SDL_Window * window, Uint32 flags); -static int GDI_DisplayModeChanged(SDL_Renderer * renderer); -static int GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int GDI_QueryTexturePixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int GDI_SetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, - int ncolors); -static int GDI_GetTexturePalette(SDL_Renderer * renderer, - SDL_Texture * texture, SDL_Color * colors, - int firstcolor, int ncolors); -static int GDI_SetTextureAlphaMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GDI_SetTextureBlendMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GDI_SetTextureScaleMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); -static int GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch); -static void GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int GDI_SetDrawBlendMode(SDL_Renderer * renderer); -static int GDI_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int GDI_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int GDI_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int GDI_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect); -static int GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch); -static int GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch); -static void GDI_RenderPresent(SDL_Renderer * renderer); -static void GDI_DestroyTexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void GDI_DestroyRenderer(SDL_Renderer * renderer); - - -SDL_RenderDriver GDI_RenderDriver = { - GDI_CreateRenderer, - { - "gdi", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED), - (SDL_TEXTUREMODULATE_NONE | SDL_TEXTUREMODULATE_ALPHA), - (SDL_BLENDMODE_NONE | SDL_BLENDMODE_MASK), - (SDL_SCALEMODE_NONE | SDL_SCALEMODE_FAST), - 14, - { - SDL_PIXELFORMAT_INDEX8, - SDL_PIXELFORMAT_RGB555, - SDL_PIXELFORMAT_RGB565, - SDL_PIXELFORMAT_RGB888, - SDL_PIXELFORMAT_BGR888, - SDL_PIXELFORMAT_ARGB8888, - SDL_PIXELFORMAT_RGBA8888, - SDL_PIXELFORMAT_ABGR8888, - SDL_PIXELFORMAT_BGRA8888, - SDL_PIXELFORMAT_YV12, - SDL_PIXELFORMAT_IYUV, - SDL_PIXELFORMAT_YUY2, - SDL_PIXELFORMAT_UYVY, - SDL_PIXELFORMAT_YVYU}, - 0, - 0} -}; - -typedef struct -{ - HWND hwnd; - HDC window_hdc; - HDC render_hdc; - HDC memory_hdc; - HDC current_hdc; -#ifndef NO_GETDIBBITS - LPBITMAPINFO bmi; -#endif - HBITMAP hbm[3]; - int current_hbm; - SDL_DirtyRectList dirty; - SDL_bool makedirty; -} GDI_RenderData; - -typedef struct -{ - SDL_SW_YUVTexture *yuv; - Uint32 format; - HPALETTE hpal; - HBITMAP hbm; - void *pixels; - int pitch; - SDL_bool premultiplied; -} GDI_TextureData; - -static void -UpdateYUVTextureData(SDL_Texture * texture) -{ - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - SDL_Rect rect; - - rect.x = 0; - rect.y = 0; - rect.w = texture->w; - rect.h = texture->h; - SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, - texture->h, data->pixels, data->pitch); -} - -void -GDI_AddRenderDriver(_THIS) -{ - int i; - for (i = 0; i < _this->num_displays; ++i) { - SDL_AddRenderDriver(&_this->displays[i], &GDI_RenderDriver); - } -} - -SDL_Renderer * -GDI_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; - SDL_Renderer *renderer; - GDI_RenderData *data; - int bmi_size; - HBITMAP hbm; - int i, n; - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (GDI_RenderData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - GDI_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - - windowdata->videodata->render = RENDER_GDI; - - renderer->DisplayModeChanged = GDI_DisplayModeChanged; - renderer->CreateTexture = GDI_CreateTexture; - renderer->QueryTexturePixels = GDI_QueryTexturePixels; - renderer->SetTexturePalette = GDI_SetTexturePalette; - renderer->GetTexturePalette = GDI_GetTexturePalette; - renderer->SetTextureAlphaMod = GDI_SetTextureAlphaMod; - renderer->SetTextureBlendMode = GDI_SetTextureBlendMode; - renderer->SetTextureScaleMode = GDI_SetTextureScaleMode; - renderer->UpdateTexture = GDI_UpdateTexture; - renderer->LockTexture = GDI_LockTexture; - renderer->UnlockTexture = GDI_UnlockTexture; - renderer->SetDrawBlendMode = GDI_SetDrawBlendMode; - renderer->RenderDrawPoints = GDI_RenderDrawPoints; - renderer->RenderDrawLines = GDI_RenderDrawLines; - renderer->RenderDrawRects = GDI_RenderDrawRects; - renderer->RenderFillRects = GDI_RenderFillRects; - renderer->RenderCopy = GDI_RenderCopy; - renderer->RenderReadPixels = GDI_RenderReadPixels; - renderer->RenderWritePixels = GDI_RenderWritePixels; - renderer->RenderPresent = GDI_RenderPresent; - renderer->DestroyTexture = GDI_DestroyTexture; - renderer->DestroyRenderer = GDI_DestroyRenderer; - renderer->info = GDI_RenderDriver.info; - renderer->window = window; - renderer->driverdata = data; - - renderer->info.flags = SDL_RENDERER_ACCELERATED; - - data->hwnd = windowdata->hwnd; - data->window_hdc = windowdata->hdc; - data->render_hdc = CreateCompatibleDC(data->window_hdc); - data->memory_hdc = CreateCompatibleDC(data->window_hdc); - -#ifndef NO_GETDIBBITS - /* Fill in the compatible bitmap info */ - bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); - data->bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size); - if (!data->bmi) { - GDI_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - data->bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - - hbm = CreateCompatibleBitmap(data->window_hdc, 1, 1); - GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS); - GetDIBits(data->window_hdc, hbm, 0, 1, NULL, data->bmi, DIB_RGB_COLORS); - DeleteObject(hbm); -#endif - - if (flags & SDL_RENDERER_SINGLEBUFFER) { - renderer->info.flags |= - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY); - n = 0; - } else if (flags & SDL_RENDERER_PRESENTFLIP2) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; - n = 2; - } else if (flags & SDL_RENDERER_PRESENTFLIP3) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; - n = 3; - } else { - renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; - n = 1; - } - for (i = 0; i < n; ++i) { - data->hbm[i] = - CreateCompatibleBitmap(data->window_hdc, window->w, window->h); - if (!data->hbm[i]) { - GDI_DestroyRenderer(renderer); - WIN_SetError("CreateCompatibleBitmap()"); - return NULL; - } - } - if (n > 0) { - SelectObject(data->render_hdc, data->hbm[0]); - data->current_hdc = data->render_hdc; - data->makedirty = SDL_TRUE; - } else { - data->current_hdc = data->window_hdc; - data->makedirty = SDL_FALSE; - } - data->current_hbm = 0; - -#ifdef _WIN32_WCE - // check size for GDI fullscreen and rotate - if((window->flags & SDL_WINDOW_FULLSCREEN) && - GetSystemMetrics(SM_CXSCREEN) != GetSystemMetrics(SM_CYSCREEN) && - ((GetSystemMetrics(SM_CXSCREEN) < GetSystemMetrics(SM_CYSCREEN) && window->w > window->h) || - (GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) && window->w < window->h))) - { - int orientation = WINCE_GetDMOrientation(); - switch(orientation) - { - case DMDO_0: orientation = DMDO_90; break; - case DMDO_270: orientation = DMDO_180; break; - case DMDO_90: orientation = DMDO_0; break; - case DMDO_180: orientation = DMDO_270; break; - - default: - GDI_DestroyRenderer(renderer); - return NULL; - } - - if(0 > WINCE_SetDMOrientation(orientation)) - { - GDI_DestroyRenderer(renderer); - return NULL; - } - } -#endif - - return renderer; -} - -static int -GDI_DisplayModeChanged(SDL_Renderer * renderer) -{ - GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - int i, n; - - if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) { - n = 0; - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { - n = 2; - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { - n = 3; - } else { - n = 1; - } - for (i = 0; i < n; ++i) { - if (data->hbm[i]) { - DeleteObject(data->hbm[i]); - data->hbm[i] = NULL; - } - } - for (i = 0; i < n; ++i) { - data->hbm[i] = - CreateCompatibleBitmap(data->window_hdc, window->w, window->h); - if (!data->hbm[i]) { - WIN_SetError("CreateCompatibleBitmap()"); - return -1; - } - } - if (n > 0) { - SelectObject(data->render_hdc, data->hbm[0]); - } - data->current_hbm = 0; - - return 0; -} - -static HBITMAP -GDI_CreateDIBSection(HDC hdc, int w, int h, int pitch, Uint32 format, - HPALETTE * hpal, void ** pixels) -{ - int bmi_size; - LPBITMAPINFO bmi; - - bmi_size = sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD); - bmi = (LPBITMAPINFO) SDL_calloc(1, bmi_size); - if (!bmi) { - SDL_OutOfMemory(); - return NULL; - } - bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - bmi->bmiHeader.biWidth = w; - bmi->bmiHeader.biHeight = -h; /* topdown bitmap */ - bmi->bmiHeader.biPlanes = 1; - bmi->bmiHeader.biSizeImage = h * pitch; - bmi->bmiHeader.biXPelsPerMeter = 0; - bmi->bmiHeader.biYPelsPerMeter = 0; - bmi->bmiHeader.biClrUsed = 0; - bmi->bmiHeader.biClrImportant = 0; - bmi->bmiHeader.biBitCount = SDL_BYTESPERPIXEL(format) * 8; - if (SDL_ISPIXELFORMAT_INDEXED(format)) { - bmi->bmiHeader.biCompression = BI_RGB; - if (hpal) { - int i, ncolors; - LOGPALETTE *palette; - - ncolors = (1 << SDL_BITSPERPIXEL(format)); - palette = - (LOGPALETTE *) SDL_malloc(sizeof(*palette) + - ncolors * sizeof(PALETTEENTRY)); - if (!palette) { - SDL_free(bmi); - SDL_OutOfMemory(); - return NULL; - } - palette->palVersion = 0x300; - palette->palNumEntries = ncolors; - for (i = 0; i < ncolors; ++i) { - palette->palPalEntry[i].peRed = 0xFF; - palette->palPalEntry[i].peGreen = 0xFF; - palette->palPalEntry[i].peBlue = 0xFF; - palette->palPalEntry[i].peFlags = 0; - } - *hpal = CreatePalette(palette); - SDL_free(palette); - } - } else { - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - bmi->bmiHeader.biCompression = BI_BITFIELDS; - SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, - &Amask); - ((Uint32 *) bmi->bmiColors)[0] = Rmask; - ((Uint32 *) bmi->bmiColors)[1] = Gmask; - ((Uint32 *) bmi->bmiColors)[2] = Bmask; - if (hpal) { - *hpal = NULL; - } - } - return CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, pixels, NULL, 0); -} - -static int -GDI_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - GDI_TextureData *data; - - data = (GDI_TextureData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - SDL_OutOfMemory(); - return -1; - } - - texture->driverdata = data; - - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - data->yuv = - SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); - if (!data->yuv) { - return -1; - } - data->format = display->current_mode.format; - } else { - data->format = texture->format; - } - data->pitch = (texture->w * SDL_BYTESPERPIXEL(data->format)); - - if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING - || texture->format != display->current_mode.format) { - data->hbm = GDI_CreateDIBSection(renderdata->memory_hdc, - texture->w, texture->h, - data->pitch, data->format, - &data->hpal, &data->pixels); - } else { - data->hbm = CreateCompatibleBitmap(renderdata->window_hdc, - texture->w, texture->h); - } - if (!data->hbm) { - WIN_SetError("Couldn't create bitmap"); - return -1; - } - - return 0; -} - -static int -GDI_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - - if (data->yuv) { - return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); - } else { - *pixels = data->pixels; - *pitch = data->pitch; - return 0; - } -} - -static int -GDI_SetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Color * colors, int firstcolor, int ncolors) -{ - GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - - if (data->yuv) { - SDL_SetError("YUV textures don't have a palette"); - return -1; - } else { - PALETTEENTRY entries[256]; - int i; - - for (i = 0; i < ncolors; ++i) { - entries[i].peRed = colors[i].r; - entries[i].peGreen = colors[i].g; - entries[i].peBlue = colors[i].b; - entries[i].peFlags = 0; - } - if (!SetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) { - WIN_SetError("SetPaletteEntries()"); - return -1; - } - return 0; - } -} - -static int -GDI_GetTexturePalette(SDL_Renderer * renderer, SDL_Texture * texture, - SDL_Color * colors, int firstcolor, int ncolors) -{ - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - - if (data->yuv) { - SDL_SetError("YUV textures don't have a palette"); - return -1; - } else { - PALETTEENTRY entries[256]; - int i; - - if (!GetPaletteEntries(data->hpal, firstcolor, ncolors, entries)) { - WIN_SetError("GetPaletteEntries()"); - return -1; - } - for (i = 0; i < ncolors; ++i) { - colors[i].r = entries[i].peRed; - colors[i].g = entries[i].peGreen; - colors[i].b = entries[i].peBlue; - } - return 0; - } -} - -static int -GDI_SetTextureAlphaMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ - return 0; -} - -static int -GDI_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - - switch (texture->blendMode) { - case SDL_BLENDMODE_NONE: - if (data->premultiplied) { - /* Crap, we've lost the original pixel data... *sigh* */ - } - return 0; -#ifndef _WIN32_WCE /* WinCE has no alphablend */ - case SDL_BLENDMODE_MASK: - case SDL_BLENDMODE_BLEND: - if (!data->premultiplied && data->pixels) { - switch (texture->format) { - case SDL_PIXELFORMAT_ARGB8888: - SDL_PreMultiplyAlphaARGB8888(texture->w, texture->h, - (Uint32 *) data->pixels, - data->pitch); - data->premultiplied = SDL_TRUE; - break; - case SDL_PIXELFORMAT_RGBA8888: - SDL_PreMultiplyAlphaRGBA8888(texture->w, texture->h, - (Uint32 *) data->pixels, - data->pitch); - data->premultiplied = SDL_TRUE; - break; - case SDL_PIXELFORMAT_ABGR8888: - SDL_PreMultiplyAlphaABGR8888(texture->w, texture->h, - (Uint32 *) data->pixels, - data->pitch); - data->premultiplied = SDL_TRUE; - break; - case SDL_PIXELFORMAT_BGRA8888: - SDL_PreMultiplyAlphaBGRA8888(texture->w, texture->h, - (Uint32 *) data->pixels, - data->pitch); - data->premultiplied = SDL_TRUE; - break; - } - } - return 0; -#endif - default: - SDL_Unsupported(); - texture->blendMode = SDL_BLENDMODE_NONE; - return -1; - } -} - -static int -GDI_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: - case SDL_SCALEMODE_FAST: - return 0; - case SDL_SCALEMODE_SLOW: - case SDL_SCALEMODE_BEST: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_FAST; - return -1; - default: - SDL_Unsupported(); - texture->scaleMode = SDL_SCALEMODE_NONE; - return -1; - } - return 0; -} - -static int -GDI_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - - if (data->yuv) { - if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) { - return -1; - } - UpdateYUVTextureData(texture); - return 0; - } else { - GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; - - if (data->pixels) { - Uint8 *src, *dst; - int row; - size_t length; - - src = (Uint8 *) pixels; - dst = - (Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format); - length = rect->w * SDL_BYTESPERPIXEL(texture->format); - for (row = 0; row < rect->h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += data->pitch; - } - if (data->premultiplied) { - Uint32 *pixels = - (Uint32 *) data->pixels + rect->y * (data->pitch / 4) + - rect->x; - switch (texture->format) { - case SDL_PIXELFORMAT_ARGB8888: - SDL_PreMultiplyAlphaARGB8888(rect->w, rect->h, pixels, - data->pitch); - break; - case SDL_PIXELFORMAT_RGBA8888: - SDL_PreMultiplyAlphaRGBA8888(rect->w, rect->h, pixels, - data->pitch); - break; - case SDL_PIXELFORMAT_ABGR8888: - SDL_PreMultiplyAlphaABGR8888(rect->w, rect->h, pixels, - data->pitch); - break; - case SDL_PIXELFORMAT_BGRA8888: - SDL_PreMultiplyAlphaBGRA8888(rect->w, rect->h, pixels, - data->pitch); - break; - } - } - } else if (rect->w == texture->w && pitch == data->pitch) { -#ifndef NO_GETDIBBITS - if (!SetDIBits - (renderdata->window_hdc, data->hbm, rect->y, rect->h, pixels, - renderdata->bmi, DIB_RGB_COLORS)) { - WIN_SetError("SetDIBits()"); - return -1; - } -#else - SDL_SetError("FIXME: Update Texture"); - return -1; -#endif - } else { - SDL_SetError - ("FIXME: Need to allocate temporary memory and do GetDIBits() followed by SetDIBits(), since we can only set blocks of scanlines at a time"); - return -1; - } - return 0; - } -} - -static int -GDI_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - - if (data->yuv) { - return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, - pitch); - } else if (data->pixels) { -#ifndef _WIN32_WCE - /* WinCE has no GdiFlush */ - GdiFlush(); -#endif - *pixels = - (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch = data->pitch; - return 0; - } else { - SDL_SetError("No pixels available"); - return -1; - } -} - -static void -GDI_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - - if (data->yuv) { - SDL_SW_UnlockYUVTexture(data->yuv); - UpdateYUVTextureData(texture); - } -} - -static int -GDI_SetDrawBlendMode(SDL_Renderer * renderer) -{ - switch (renderer->blendMode) { - case SDL_BLENDMODE_NONE: - return 0; - default: - SDL_Unsupported(); - renderer->blendMode = SDL_BLENDMODE_NONE; - return -1; - } -} - -static int -GDI_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - int i; - COLORREF color; - - if (data->makedirty) { - /* Get the smallest rectangle that contains everything */ - SDL_Window *window = renderer->window; - SDL_Rect rect; - - rect.x = 0; - rect.y = 0; - rect.w = window->w; - rect.h = window->h; - if (!SDL_EnclosePoints(points, count, &rect, &rect)) { - /* Nothing to draw */ - return 0; - } - - SDL_AddDirtyRect(&data->dirty, &rect); - } - - color = RGB(renderer->r, renderer->g, renderer->b); - for (i = 0; i < count; ++i) { - SetPixel(data->current_hdc, points[i].x, points[i].y, color); - } - - return 0; -} - -static int -GDI_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - HPEN pen; - BOOL status; - - if (data->makedirty) { - /* Get the smallest rectangle that contains everything */ - SDL_Window *window = renderer->window; - SDL_Rect clip, rect; - - clip.x = 0; - clip.y = 0; - clip.w = window->w; - clip.h = window->h; - SDL_EnclosePoints(points, count, NULL, &rect); - if (!SDL_IntersectRect(&rect, &clip, &rect)) { - /* Nothing to draw */ - return 0; - } - - SDL_AddDirtyRect(&data->dirty, &rect); - } - - /* Should we cache the pen? .. it looks like GDI does for us. :) */ - pen = CreatePen(PS_SOLID, 1, RGB(renderer->r, renderer->g, renderer->b)); - SelectObject(data->current_hdc, pen); - { - LPPOINT p = SDL_stack_alloc(POINT, count); - int i; - - for (i = 0; i < count; ++i) { - p[i].x = points[i].x; - p[i].y = points[i].y; - } - status = Polyline(data->current_hdc, p, count); - SDL_stack_free(p); - } - DeleteObject(pen); - - /* Need to close the endpoint of the line */ - if (points[0].x != points[count-1].x || points[0].y != points[count-1].y) { - SetPixel(data->current_hdc, points[count-1].x, points[count-1].y, - RGB(renderer->r, renderer->g, renderer->b)); - } - - if (!status) { - WIN_SetError("Polyline()"); - return -1; - } - return 0; -} - -static int -GDI_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - HPEN pen; - POINT vertices[5]; - int i, status = 1; - - if (data->makedirty) { - SDL_Window *window = renderer->window; - SDL_Rect clip, rect; - - clip.x = 0; - clip.y = 0; - clip.w = window->w; - clip.h = window->h; - - for (i = 0; i < count; ++i) { - if (SDL_IntersectRect(rects[i], &clip, &rect)) { - SDL_AddDirtyRect(&data->dirty, &rect); - } - } - } - - /* Should we cache the pen? .. it looks like GDI does for us. :) */ - pen = CreatePen(PS_SOLID, 1, RGB(renderer->r, renderer->g, renderer->b)); - SelectObject(data->current_hdc, pen); - for (i = 0; i < count; ++i) { - const SDL_Rect *rect = rects[i]; - - vertices[0].x = rect->x; - vertices[0].y = rect->y; - - vertices[1].x = rect->x+rect->w-1; - vertices[1].y = rect->y; - - vertices[2].x = rect->x+rect->w-1; - vertices[2].y = rect->y+rect->h-1; - - vertices[3].x = rect->x; - vertices[3].y = rect->y+rect->h-1; - - vertices[4].x = rect->x; - vertices[4].y = rect->y; - - status &= Polyline(data->current_hdc, vertices, 5); - } - DeleteObject(pen); - - if (!status) { - WIN_SetError("Polyline()"); - return -1; - } - return 0; -} - -static int -GDI_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, - int count) -{ - GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - RECT rc; - HBRUSH brush; - int i, status = 1; - - if (data->makedirty) { - SDL_Window *window = renderer->window; - SDL_Rect clip, rect; - - clip.x = 0; - clip.y = 0; - clip.w = window->w; - clip.h = window->h; - - for (i = 0; i < count; ++i) { - if (SDL_IntersectRect(rects[i], &clip, &rect)) { - SDL_AddDirtyRect(&data->dirty, &rect); - } - } - } - - /* Should we cache the brushes? .. it looks like GDI does for us. :) */ - brush = CreateSolidBrush(RGB(renderer->r, renderer->g, renderer->b)); - SelectObject(data->current_hdc, brush); - for (i = 0; i < count; ++i) { - const SDL_Rect *rect = rects[i]; - - rc.left = rect->x; - rc.top = rect->y; - rc.right = rect->x + rect->w; - rc.bottom = rect->y + rect->h; - - status &= FillRect(data->current_hdc, &rc, brush); - } - DeleteObject(brush); - - if (!status) { - WIN_SetError("FillRect()"); - return -1; - } - return 0; -} - -static int -GDI_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - GDI_TextureData *texturedata = (GDI_TextureData *) texture->driverdata; - - if (data->makedirty) { - SDL_AddDirtyRect(&data->dirty, dstrect); - } - - SelectObject(data->memory_hdc, texturedata->hbm); - if (texturedata->hpal) { - SelectPalette(data->memory_hdc, texturedata->hpal, TRUE); - RealizePalette(data->memory_hdc); - } - if (texture->blendMode & (SDL_BLENDMODE_MASK | SDL_BLENDMODE_BLEND)) { -#ifdef _WIN32_WCE - SDL_SetError("Texture has blendmode not supported under WinCE"); - return -1; -#else - BLENDFUNCTION blendFunc = { - AC_SRC_OVER, - 0, - texture->a, - AC_SRC_ALPHA - }; - if (!AlphaBlend - (data->current_hdc, dstrect->x, dstrect->y, dstrect->w, - dstrect->h, data->memory_hdc, srcrect->x, srcrect->y, srcrect->w, - srcrect->h, blendFunc)) { - WIN_SetError("AlphaBlend()"); - return -1; - } -#endif - } else { - if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { - if (!BitBlt - (data->current_hdc, dstrect->x, dstrect->y, dstrect->w, - srcrect->h, data->memory_hdc, srcrect->x, srcrect->y, - SRCCOPY)) { - WIN_SetError("BitBlt()"); - return -1; - } - } else { - if (!StretchBlt - (data->current_hdc, dstrect->x, dstrect->y, dstrect->w, - dstrect->h, data->memory_hdc, srcrect->x, srcrect->y, - srcrect->w, srcrect->h, SRCCOPY)) { - WIN_SetError("StretchBlt()"); - return -1; - } - } - } - return 0; -} - -static int -GDI_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) -{ - GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - struct { - HBITMAP hbm; - void *pixels; - int pitch; - Uint32 format; - } data; - - data.format = display->current_mode.format; - data.pitch = (rect->w * SDL_BYTESPERPIXEL(data.format)); - - data.hbm = GDI_CreateDIBSection(renderdata->memory_hdc, rect->w, rect->h, - data.pitch, data.format, NULL, - &data.pixels); - if (!data.hbm) { - WIN_SetError("Couldn't create bitmap"); - return -1; - } - - SelectObject(renderdata->memory_hdc, data.hbm); - if (!BitBlt(renderdata->memory_hdc, 0, 0, rect->w, rect->h, - renderdata->current_hdc, rect->x, rect->y, SRCCOPY)) { - WIN_SetError("BitBlt()"); - DeleteObject(data.hbm); - return -1; - } - - SDL_ConvertPixels(rect->w, rect->h, - data.format, data.pixels, data.pitch, - format, pixels, pitch); - - DeleteObject(data.hbm); - return 0; -} - -static int -GDI_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch) -{ - GDI_RenderData *renderdata = (GDI_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - struct { - HBITMAP hbm; - void *pixels; - int pitch; - Uint32 format; - } data; - - data.format = display->current_mode.format; - data.pitch = (rect->w * SDL_BYTESPERPIXEL(data.format)); - - data.hbm = GDI_CreateDIBSection(renderdata->memory_hdc, rect->w, rect->h, - data.pitch, data.format, - NULL, &data.pixels); - if (!data.hbm) { - WIN_SetError("Couldn't create bitmap"); - return -1; - } - - SDL_ConvertPixels(rect->w, rect->h, format, pixels, pitch, - data.format, data.pixels, data.pitch); - - SelectObject(renderdata->memory_hdc, data.hbm); - if (!BitBlt(renderdata->current_hdc, rect->x, rect->y, rect->w, rect->h, - renderdata->memory_hdc, 0, 0, SRCCOPY)) { - WIN_SetError("BitBlt()"); - DeleteObject(data.hbm); - return -1; - } - - DeleteObject(data.hbm); - return 0; -} - -static void -GDI_RenderPresent(SDL_Renderer * renderer) -{ - GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - SDL_DirtyRect *dirty; - - /* Send the data to the display */ - if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) { - for (dirty = data->dirty.list; dirty; dirty = dirty->next) { - const SDL_Rect *rect = &dirty->rect; - BitBlt(data->window_hdc, rect->x, rect->y, rect->w, rect->h, - data->render_hdc, rect->x, rect->y, SRCCOPY); - } - SDL_ClearDirtyRects(&data->dirty); - } - - /* Update the flipping chain, if any */ - if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { - data->current_hbm = (data->current_hbm + 1) % 2; - SelectObject(data->render_hdc, data->hbm[data->current_hbm]); - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { - data->current_hbm = (data->current_hbm + 1) % 3; - SelectObject(data->render_hdc, data->hbm[data->current_hbm]); - } -} - -static void -GDI_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - GDI_TextureData *data = (GDI_TextureData *) texture->driverdata; - - if (!data) { - return; - } - if (data->yuv) { - SDL_SW_DestroyYUVTexture(data->yuv); - } - if (data->hpal) { - DeleteObject(data->hpal); - } - if (data->hbm) { - DeleteObject(data->hbm); - } - SDL_free(data); - texture->driverdata = NULL; -} - -static void -GDI_DestroyRenderer(SDL_Renderer * renderer) -{ - GDI_RenderData *data = (GDI_RenderData *) renderer->driverdata; - int i; - - if (data) { - DeleteDC(data->render_hdc); - DeleteDC(data->memory_hdc); -#ifndef NO_GETDIBBITS - if (data->bmi) { - SDL_free(data->bmi); - } -#endif - for (i = 0; i < SDL_arraysize(data->hbm); ++i) { - if (data->hbm[i]) { - DeleteObject(data->hbm[i]); - } - } - SDL_FreeDirtyRects(&data->dirty); - SDL_free(data); - } - SDL_free(renderer); -} - -#endif /* SDL_VIDEO_RENDER_GDI */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_gdirender.h b/project/jni/sdl-1.3/src/video/win32/SDL_gdirender.h deleted file mode 100644 index 268f4b77f..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_gdirender.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* SDL surface based renderer implementation */ - -#if SDL_VIDEO_RENDER_GDI -extern void GDI_AddRenderDriver(_THIS); -#endif - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32clipboard.h b/project/jni/sdl-1.3/src/video/win32/SDL_win32clipboard.h deleted file mode 100644 index ab2fb17a7..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32clipboard.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_win32clipboard_h -#define _SDL_win32clipboard_h - -/* Forward declaration */ -struct SDL_VideoData; - -extern int WIN_SetClipboardText(_THIS, const char *text); -extern char *WIN_GetClipboardText(_THIS); -extern SDL_bool WIN_HasClipboardText(_THIS); -extern void WIN_CheckClipboardUpdate(struct SDL_VideoData * data); - -#endif /* _SDL_win32clipboard_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32events.h b/project/jni/sdl-1.3/src/video/win32/SDL_win32events.h deleted file mode 100644 index 18e880bf4..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32events.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_win32events_h -#define _SDL_win32events_h - -extern LPTSTR SDL_Appname; -extern Uint32 SDL_Appstyle; -extern HINSTANCE SDL_Instance; - -extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, - LPARAM lParam); -extern void WIN_PumpEvents(_THIS); - -#endif /* _SDL_win32events_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32gamma.c b/project/jni/sdl-1.3/src/video/win32/SDL_win32gamma.c deleted file mode 100644 index b94a7f596..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32gamma.c +++ /dev/null @@ -1,71 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_win32video.h" - - -int -WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp) -{ -#ifdef _WIN32_WCE - return -1; -#else - SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; - HDC hdc; - BOOL succeeded = FALSE; - - hdc = CreateDC(data->DeviceName, NULL, NULL, NULL); - if (hdc) { - succeeded = SetDeviceGammaRamp(hdc, ramp); - if (!succeeded) { - WIN_SetError("SetDeviceGammaRamp()"); - } - DeleteDC(hdc); - } - return succeeded ? 0 : -1; -#endif -} - -int -WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp) -{ -#ifdef _WIN32_WCE - return -1; -#else - SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; - HDC hdc; - BOOL succeeded = FALSE; - - hdc = CreateDC(data->DeviceName, NULL, NULL, NULL); - if (hdc) { - succeeded = GetDeviceGammaRamp(hdc, ramp); - if (!succeeded) { - WIN_SetError("GetDeviceGammaRamp()"); - } - DeleteDC(hdc); - } - return succeeded ? 0 : -1; -#endif -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32gamma.h b/project/jni/sdl-1.3/src/video/win32/SDL_win32gamma.h deleted file mode 100644 index 25db4755d..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32gamma.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_win32gamma_h -#define _SDL_win32gamma_h - -extern int WIN_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp); -extern int WIN_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp); - -#endif /* _SDL_win32gamma_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32keyboard.h b/project/jni/sdl-1.3/src/video/win32/SDL_win32keyboard.h deleted file mode 100644 index 670730bba..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32keyboard.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_win32keyboard_h -#define _SDL_win32keyboard_h - -extern BYTE alpha_scancodes[26]; -extern BYTE keypad_scancodes[10]; - -extern void WIN_InitKeyboard(_THIS); -extern void WIN_UpdateKeymap(void); -extern void WIN_QuitKeyboard(_THIS); - -extern void WIN_StartTextInput(_THIS); -extern void WIN_StopTextInput(_THIS); -extern void WIN_SetTextInputRect(_THIS, SDL_Rect *rect); - -extern SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata); - -#endif /* _SDL_win32keyboard_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32modes.h b/project/jni/sdl-1.3/src/video/win32/SDL_win32modes.h deleted file mode 100644 index c8ee4534e..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32modes.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_win32modes_h -#define _SDL_win32modes_h - -typedef struct -{ - TCHAR DeviceName[32]; -} SDL_DisplayData; - -typedef struct -{ - DEVMODE DeviceMode; -} SDL_DisplayModeData; - -extern int WIN_InitModes(_THIS); -extern int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); -extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display); -extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); -extern void WIN_QuitModes(_THIS); - -#endif /* _SDL_win32modes_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32mouse.c b/project/jni/sdl-1.3/src/video/win32/SDL_win32mouse.c deleted file mode 100644 index 093720bcb..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32mouse.c +++ /dev/null @@ -1,44 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ - -/* we need to define it, so that raw input is included*/ - -#if (_WIN32_WINNT < 0x0501) -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif - -#include "SDL_config.h" - -#include "SDL_win32video.h" - -void -WIN_InitMouse(_THIS) -{ -} - -void -WIN_QuitMouse(_THIS) -{ -} - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32mouse.h b/project/jni/sdl-1.3/src/video/win32/SDL_win32mouse.h deleted file mode 100644 index 278d4e832..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32mouse.h +++ /dev/null @@ -1,32 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_win32mouse_h -#define _SDL_win32mouse_h - -extern void WIN_InitMouse(_THIS); -extern void WIN_QuitMouse(_THIS); - -#endif /* _SDL_win32mouse_h */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32shape.h b/project/jni/sdl-1.3/src/video/win32/SDL_win32shape.h deleted file mode 100644 index e18a77ec0..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32shape.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com -*/ - -#include "SDL_config.h" - -#ifndef _SDL_win32shape_h -#define _SDL_win32shape_h - -#include "SDL_video.h" -#include "SDL_shape.h" -#include "../SDL_sysvideo.h" -#include "../SDL_shape_internals.h" - -typedef struct { - SDL_ShapeTree *mask_tree; -} SDL_ShapeData; - -extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window); -extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); -extern int Win32_ResizeWindowShape(SDL_Window *window); - -#endif /* _SDL_win32shape_h */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32video.c b/project/jni/sdl-1.3/src/video/win32/SDL_win32video.c deleted file mode 100644 index eaa820eed..000000000 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32video.c +++ /dev/null @@ -1,266 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_main.h" -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" - -#include "SDL_win32video.h" -#include "SDL_win32shape.h" -#include "SDL_d3drender.h" -#include "SDL_gdirender.h" -#include "SDL_gapirender.h" - -/* Initialization/Query functions */ -static int WIN_VideoInit(_THIS); -static void WIN_VideoQuit(_THIS); - -/* Sets an error message based on GetLastError() */ -void -WIN_SetError(const char *prefix) -{ - TCHAR buffer[1024]; - char *message; - FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0, - buffer, SDL_arraysize(buffer), NULL); - message = WIN_StringToUTF8(buffer); - SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message); - SDL_free(message); -} - - -/* WIN32 driver bootstrap functions */ - -static int -WIN_Available(void) -{ - return (1); -} - -static void -WIN_DeleteDevice(SDL_VideoDevice * device) -{ - SDL_VideoData *data = (SDL_VideoData *) device->driverdata; - - SDL_UnregisterApp(); -#if SDL_VIDEO_RENDER_D3D - if (data->d3d) { - IDirect3D9_Release(data->d3d); - FreeLibrary(data->d3dDLL); - } -#endif -#if SDL_VIDEO_RENDER_DDRAW - if (data->ddraw) { - data->ddraw->lpVtbl->Release(data->ddraw); - FreeLibrary(data->ddrawDLL); - } -#endif -#ifdef _WIN32_WCE - if(data->hAygShell) { - FreeLibrary(data->hAygShell); - } -#endif - if (data->userDLL) { - FreeLibrary(data->userDLL); - } - - SDL_free(device->driverdata); - SDL_free(device); -} - -static SDL_VideoDevice * -WIN_CreateDevice(int devindex) -{ - SDL_VideoDevice *device; - SDL_VideoData *data; - - SDL_RegisterApp(NULL, 0, NULL); - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); - if (device) { - data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); - } else { - data = NULL; - } - if (!data) { - SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } - return NULL; - } - device->driverdata = data; - -#if SDL_VIDEO_RENDER_D3D - data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL")); - if (data->d3dDLL) { - IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion); - - D3DCreate = - (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL, - "Direct3DCreate9"); - if (D3DCreate) { - data->d3d = D3DCreate(D3D_SDK_VERSION); - } - if (!data->d3d) { - FreeLibrary(data->d3dDLL); - data->d3dDLL = NULL; - } - } -#endif /* SDL_VIDEO_RENDER_D3D */ -#if SDL_VIDEO_RENDER_DDRAW - data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll")); - if (data->ddrawDLL) { - IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID, - LPDIRECTDRAW FAR * lplpDD, - IUnknown FAR * pUnkOuter); - - DDCreate = - (IDirectDraw * - (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *)) - GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate")); - if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) { - FreeLibrary(data->ddrawDLL); - data->ddrawDLL = NULL; - data->ddraw = NULL; - } - } -#endif /* SDL_VIDEO_RENDER_DDRAW */ - -#ifdef _WIN32_WCE - data->hAygShell = LoadLibrary(TEXT("\\windows\\aygshell.dll")); - if(0 == data->hAygShell) - data->hAygShell = LoadLibrary(TEXT("aygshell.dll")); - data->SHFullScreen = (0 != data->hAygShell ? - (PFNSHFullScreen) GetProcAddress(data->hAygShell, TEXT("SHFullScreen")) : 0); - data->CoordTransform = NULL; -#endif - - data->userDLL = LoadLibrary(TEXT("USER32.DLL")); - if (data->userDLL) { - data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) GetProcAddress(data->userDLL, "CloseTouchInputHandle"); - data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) GetProcAddress(data->userDLL, "GetTouchInputInfo"); - data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) GetProcAddress(data->userDLL, "RegisterTouchWindow"); - } - - /* Set the function pointers */ - device->VideoInit = WIN_VideoInit; - device->VideoQuit = WIN_VideoQuit; - device->GetDisplayBounds = WIN_GetDisplayBounds; - device->GetDisplayModes = WIN_GetDisplayModes; - device->SetDisplayMode = WIN_SetDisplayMode; - device->SetDisplayGammaRamp = WIN_SetDisplayGammaRamp; - device->GetDisplayGammaRamp = WIN_GetDisplayGammaRamp; - device->PumpEvents = WIN_PumpEvents; - -#undef CreateWindow - device->CreateWindow = WIN_CreateWindow; - device->CreateWindowFrom = WIN_CreateWindowFrom; - device->SetWindowTitle = WIN_SetWindowTitle; - device->SetWindowIcon = WIN_SetWindowIcon; - device->SetWindowPosition = WIN_SetWindowPosition; - device->SetWindowSize = WIN_SetWindowSize; - device->ShowWindow = WIN_ShowWindow; - device->HideWindow = WIN_HideWindow; - device->RaiseWindow = WIN_RaiseWindow; - device->MaximizeWindow = WIN_MaximizeWindow; - device->MinimizeWindow = WIN_MinimizeWindow; - device->RestoreWindow = WIN_RestoreWindow; - device->SetWindowGrab = WIN_SetWindowGrab; - device->DestroyWindow = WIN_DestroyWindow; - device->GetWindowWMInfo = WIN_GetWindowWMInfo; - - device->shape_driver.CreateShaper = Win32_CreateShaper; - device->shape_driver.SetWindowShape = Win32_SetWindowShape; - device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape; - -#ifdef SDL_VIDEO_OPENGL_WGL - device->GL_LoadLibrary = WIN_GL_LoadLibrary; - device->GL_GetProcAddress = WIN_GL_GetProcAddress; - device->GL_UnloadLibrary = WIN_GL_UnloadLibrary; - device->GL_CreateContext = WIN_GL_CreateContext; - device->GL_MakeCurrent = WIN_GL_MakeCurrent; - device->GL_SetSwapInterval = WIN_GL_SetSwapInterval; - device->GL_GetSwapInterval = WIN_GL_GetSwapInterval; - device->GL_SwapWindow = WIN_GL_SwapWindow; - device->GL_DeleteContext = WIN_GL_DeleteContext; -#endif - device->StartTextInput = WIN_StartTextInput; - device->StopTextInput = WIN_StopTextInput; - device->SetTextInputRect = WIN_SetTextInputRect; - - device->SetClipboardText = WIN_SetClipboardText; - device->GetClipboardText = WIN_GetClipboardText; - device->HasClipboardText = WIN_HasClipboardText; - - device->free = WIN_DeleteDevice; - - return device; -} - -VideoBootStrap WIN32_bootstrap = { -#ifdef _WIN32_WCE - "wince", "SDL WinCE video driver", WINCE_Available, WIN_CreateDevice -#else - "win32", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice -#endif -}; - -int -WIN_VideoInit(_THIS) -{ - if (WIN_InitModes(_this) < 0) { - return -1; - } - -#if SDL_VIDEO_RENDER_D3D - D3D_AddRenderDriver(_this); -#endif -#if SDL_VIDEO_RENDER_DDRAW - DDRAW_AddRenderDriver(_this); -#endif -#if SDL_VIDEO_RENDER_GDI - GDI_AddRenderDriver(_this); -#endif -#if SDL_VIDEO_RENDER_GAPI - WINCE_AddRenderDriver(_this); -#endif - - WIN_InitKeyboard(_this); - WIN_InitMouse(_this); - - return 0; -} - -void -WIN_VideoQuit(_THIS) -{ - WIN_QuitModes(_this); - WIN_QuitKeyboard(_this); - WIN_QuitMouse(_this); -} - -/* vim: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_msctf.h b/project/jni/sdl-1.3/src/video/windows/SDL_msctf.h similarity index 97% rename from project/jni/sdl-1.3/src/video/win32/SDL_msctf.h rename to project/jni/sdl-1.3/src/video/windows/SDL_msctf.h index a338ddfb1..9ff43c058 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_msctf.h +++ b/project/jni/sdl-1.3/src/video/windows/SDL_msctf.h @@ -1,221 +1,221 @@ -#ifndef _SDL_msctf_h -#define _SDL_msctf_h - -#include - -#define TF_INVALID_COOKIE (0xffffffff) -#define TF_IPSINK_FLAG_ACTIVE 0x0001 -#define TF_TMAE_UIELEMENTENABLEDONLY 0x00000004 - -typedef struct ITfThreadMgr ITfThreadMgr; -typedef struct ITfDocumentMgr ITfDocumentMgr; -typedef struct ITfClientId ITfClientId; - -typedef struct IEnumTfDocumentMgrs IEnumTfDocumentMgrs; -typedef struct IEnumTfFunctionProviders IEnumTfFunctionProviders; -typedef struct ITfFunctionProvider ITfFunctionProvider; -typedef struct ITfCompartmentMgr ITfCompartmentMgr; -typedef struct ITfContext ITfContext; -typedef struct IEnumTfContexts IEnumTfContexts; -typedef struct ITfUIElementSink ITfUIElementSink; -typedef struct ITfUIElement ITfUIElement; -typedef struct ITfUIElementMgr ITfUIElementMgr; -typedef struct IEnumTfUIElements IEnumTfUIElements; -typedef struct ITfThreadMgrEx ITfThreadMgrEx; -typedef struct ITfCandidateListUIElement ITfCandidateListUIElement; -typedef struct ITfReadingInformationUIElement ITfReadingInformationUIElement; -typedef struct ITfInputProcessorProfileActivationSink ITfInputProcessorProfileActivationSink; -typedef struct ITfSource ITfSource; - -typedef DWORD TfClientId; -typedef DWORD TfEditCookie; - -typedef struct ITfThreadMgrVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgr *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgr *); - ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgr *); - HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgr *, TfClientId *); - HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgr *); - HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgr *); - HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgr *, IEnumTfDocumentMgrs **); - HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgr *, ITfDocumentMgr **); - HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgr *, ITfDocumentMgr *); - HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgr *, HWND, ITfDocumentMgr *, ITfDocumentMgr **); - HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgr *, BOOL *); - HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgr *, REFCLSID, ITfFunctionProvider **); - HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgr *, IEnumTfFunctionProviders **); - HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgr *, ITfCompartmentMgr **); -} ITfThreadMgrVtbl; - -struct ITfThreadMgr -{ - const struct ITfThreadMgrVtbl *lpVtbl; -}; - -typedef struct ITfThreadMgrExVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgrEx *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgrEx *); - ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgrEx *); - HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgrEx *, TfClientId *); - HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgrEx *); - HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgrEx *, ITfDocumentMgr **); - HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgrEx *, IEnumTfDocumentMgrs **); - HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgrEx *, ITfDocumentMgr **); - HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgrEx *, ITfDocumentMgr *); - HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgrEx *, ITfDocumentMgr *, ITfDocumentMgr **); - HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgrEx *, BOOL *); - HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgrEx *, REFCLSID, ITfFunctionProvider **); - HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgrEx *, IEnumTfFunctionProviders **); - HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgrEx *, ITfCompartmentMgr **); - HRESULT (STDMETHODCALLTYPE *ActivateEx)(ITfThreadMgrEx *, TfClientId *, DWORD); - HRESULT (STDMETHODCALLTYPE *GetActiveFlags)(ITfThreadMgrEx *, DWORD *); -} ITfThreadMgrExVtbl; - -struct ITfThreadMgrEx -{ - const struct ITfThreadMgrExVtbl *lpVtbl; -}; - -typedef struct ITfDocumentMgrVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfDocumentMgr *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfDocumentMgr *); - ULONG (STDMETHODCALLTYPE *Release)(ITfDocumentMgr *); - HRESULT (STDMETHODCALLTYPE *CreateContext)(ITfDocumentMgr *, TfClientId, DWORD, IUnknown *, ITfContext **, TfEditCookie *); - HRESULT (STDMETHODCALLTYPE *Push)(ITfDocumentMgr *, ITfContext *); - HRESULT (STDMETHODCALLTYPE *Pop)(ITfDocumentMgr *); - HRESULT (STDMETHODCALLTYPE *GetTop)(ITfDocumentMgr *, ITfContext **); - HRESULT (STDMETHODCALLTYPE *GetBase)(ITfDocumentMgr *, ITfContext **); - HRESULT (STDMETHODCALLTYPE *EnumContexts)(ITfDocumentMgr *, IEnumTfContexts **); -} ITfDocumentMgrVtbl; - -struct ITfDocumentMgr -{ - const struct ITfDocumentMgrVtbl *lpVtbl; -}; - -typedef struct ITfUIElementSinkVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementSink *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementSink *); - ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementSink *); - HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementSink *, DWORD, BOOL *); - HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementSink *, DWORD); - HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementSink *, DWORD); -} ITfUIElementSinkVtbl; - -struct ITfUIElementSink -{ - const struct ITfUIElementSinkVtbl *lpVtbl; -}; - -typedef struct ITfUIElementMgrVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementMgr *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementMgr *); - ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementMgr *); - HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementMgr *, ITfUIElement *, BOOL *, DWORD *); - HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementMgr *, DWORD); - HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementMgr *, DWORD); - HRESULT (STDMETHODCALLTYPE *GetUIElement)(ITfUIElementMgr *, DWORD, ITfUIElement **); - HRESULT (STDMETHODCALLTYPE *EnumUIElements)(ITfUIElementMgr *, IEnumTfUIElements **); -} ITfUIElementMgrVtbl; - -struct ITfUIElementMgr -{ - const struct ITfUIElementMgrVtbl *lpVtbl; -}; - -typedef struct ITfCandidateListUIElementVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfCandidateListUIElement *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfCandidateListUIElement *); - ULONG (STDMETHODCALLTYPE *Release)(ITfCandidateListUIElement *); - HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfCandidateListUIElement *, BSTR *); - HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfCandidateListUIElement *, GUID *); - HRESULT (STDMETHODCALLTYPE *Show)(ITfCandidateListUIElement *, BOOL); - HRESULT (STDMETHODCALLTYPE *IsShown)(ITfCandidateListUIElement *, BOOL *); - HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfCandidateListUIElement *, DWORD *); - HRESULT (STDMETHODCALLTYPE *GetDocumentMgr)(ITfCandidateListUIElement *, ITfDocumentMgr **); - HRESULT (STDMETHODCALLTYPE *GetCount)(ITfCandidateListUIElement *, UINT *); - HRESULT (STDMETHODCALLTYPE *GetSelection)(ITfCandidateListUIElement *, UINT *); - HRESULT (STDMETHODCALLTYPE *GetString)(ITfCandidateListUIElement *, UINT, BSTR *); - HRESULT (STDMETHODCALLTYPE *GetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT, UINT *); - HRESULT (STDMETHODCALLTYPE *SetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT); - HRESULT (STDMETHODCALLTYPE *GetCurrentPage)(ITfCandidateListUIElement *, UINT *); -} ITfCandidateListUIElementVtbl; - -struct ITfCandidateListUIElement -{ - const struct ITfCandidateListUIElementVtbl *lpVtbl; -}; - -typedef struct ITfReadingInformationUIElementVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfReadingInformationUIElement *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfReadingInformationUIElement *); - ULONG (STDMETHODCALLTYPE *Release)(ITfReadingInformationUIElement *); - HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfReadingInformationUIElement *, BSTR *); - HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfReadingInformationUIElement *, GUID *); - HRESULT (STDMETHODCALLTYPE *Show)(ITfReadingInformationUIElement *, BOOL); - HRESULT (STDMETHODCALLTYPE *IsShown)(ITfReadingInformationUIElement *, BOOL *); - HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfReadingInformationUIElement *, DWORD *); - HRESULT (STDMETHODCALLTYPE *GetContext)(ITfReadingInformationUIElement *, ITfContext **); - HRESULT (STDMETHODCALLTYPE *GetString)(ITfReadingInformationUIElement *, BSTR *); - HRESULT (STDMETHODCALLTYPE *GetMaxReadingStringLength)(ITfReadingInformationUIElement *, UINT *); - HRESULT (STDMETHODCALLTYPE *GetErrorIndex)(ITfReadingInformationUIElement *, UINT *); - HRESULT (STDMETHODCALLTYPE *IsVerticalOrderPreferred)(ITfReadingInformationUIElement *, BOOL *); -} ITfReadingInformationUIElementVtbl; - -struct ITfReadingInformationUIElement -{ - const struct ITfReadingInformationUIElementVtbl *lpVtbl; -}; - -typedef struct ITfUIElementVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElement *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElement *); - ULONG (STDMETHODCALLTYPE *Release)(ITfUIElement *); - HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfUIElement *, BSTR *); - HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfUIElement *, GUID *); - HRESULT (STDMETHODCALLTYPE *Show)(ITfUIElement *, BOOL); - HRESULT (STDMETHODCALLTYPE *IsShown)(ITfUIElement *, BOOL *); -} ITfUIElementVtbl; - -struct ITfUIElement -{ - const struct ITfUIElementVtbl *lpVtbl; -}; - -typedef struct ITfInputProcessorProfileActivationSinkVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfInputProcessorProfileActivationSink *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfInputProcessorProfileActivationSink *); - ULONG (STDMETHODCALLTYPE *Release)(ITfInputProcessorProfileActivationSink *); - HRESULT (STDMETHODCALLTYPE *OnActivated)(ITfInputProcessorProfileActivationSink *, DWORD, LANGID, REFCLSID, REFGUID, REFGUID, HKL, DWORD); - -} ITfInputProcessorProfileActivationSinkVtbl; - -struct ITfInputProcessorProfileActivationSink -{ - const struct ITfInputProcessorProfileActivationSinkVtbl *lpVtbl; -}; - -typedef struct ITfSourceVtbl -{ - HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfSource *, REFIID, void **); - ULONG (STDMETHODCALLTYPE *AddRef)(ITfSource *); - ULONG (STDMETHODCALLTYPE *Release)(ITfSource *); - HRESULT (STDMETHODCALLTYPE *AdviseSink)(ITfSource *, REFIID, IUnknown *, DWORD *); - HRESULT (STDMETHODCALLTYPE *UnadviseSink)(ITfSource *, DWORD); -} ITfSourceVtbl; - -struct ITfSource -{ - const struct ITfSourceVtbl *lpVtbl; -}; - -#endif /* _SDL_msctf_h */ +#ifndef _SDL_msctf_h +#define _SDL_msctf_h + +#include + +#define TF_INVALID_COOKIE (0xffffffff) +#define TF_IPSINK_FLAG_ACTIVE 0x0001 +#define TF_TMAE_UIELEMENTENABLEDONLY 0x00000004 + +typedef struct ITfThreadMgr ITfThreadMgr; +typedef struct ITfDocumentMgr ITfDocumentMgr; +typedef struct ITfClientId ITfClientId; + +typedef struct IEnumTfDocumentMgrs IEnumTfDocumentMgrs; +typedef struct IEnumTfFunctionProviders IEnumTfFunctionProviders; +typedef struct ITfFunctionProvider ITfFunctionProvider; +typedef struct ITfCompartmentMgr ITfCompartmentMgr; +typedef struct ITfContext ITfContext; +typedef struct IEnumTfContexts IEnumTfContexts; +typedef struct ITfUIElementSink ITfUIElementSink; +typedef struct ITfUIElement ITfUIElement; +typedef struct ITfUIElementMgr ITfUIElementMgr; +typedef struct IEnumTfUIElements IEnumTfUIElements; +typedef struct ITfThreadMgrEx ITfThreadMgrEx; +typedef struct ITfCandidateListUIElement ITfCandidateListUIElement; +typedef struct ITfReadingInformationUIElement ITfReadingInformationUIElement; +typedef struct ITfInputProcessorProfileActivationSink ITfInputProcessorProfileActivationSink; +typedef struct ITfSource ITfSource; + +typedef DWORD TfClientId; +typedef DWORD TfEditCookie; + +typedef struct ITfThreadMgrVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgr *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgr *); + ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgr *); + HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgr *, TfClientId *); + HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgr *); + HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgr *); + HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgr *, IEnumTfDocumentMgrs **); + HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgr *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgr *, ITfDocumentMgr *); + HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgr *, HWND, ITfDocumentMgr *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgr *, BOOL *); + HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgr *, REFCLSID, ITfFunctionProvider **); + HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgr *, IEnumTfFunctionProviders **); + HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgr *, ITfCompartmentMgr **); +} ITfThreadMgrVtbl; + +struct ITfThreadMgr +{ + const struct ITfThreadMgrVtbl *lpVtbl; +}; + +typedef struct ITfThreadMgrExVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfThreadMgrEx *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfThreadMgrEx *); + ULONG (STDMETHODCALLTYPE *Release)(ITfThreadMgrEx *); + HRESULT (STDMETHODCALLTYPE *Activate)(ITfThreadMgrEx *, TfClientId *); + HRESULT (STDMETHODCALLTYPE *Deactivate)(ITfThreadMgrEx *); + HRESULT (STDMETHODCALLTYPE *CreateDocumentMgr)(ITfThreadMgrEx *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *EnumDocumentMgrs)(ITfThreadMgrEx *, IEnumTfDocumentMgrs **); + HRESULT (STDMETHODCALLTYPE *GetFocus)(ITfThreadMgrEx *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *SetFocus)(ITfThreadMgrEx *, ITfDocumentMgr *); + HRESULT (STDMETHODCALLTYPE *AssociateFocus)(ITfThreadMgrEx *, ITfDocumentMgr *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *IsThreadFocus)(ITfThreadMgrEx *, BOOL *); + HRESULT (STDMETHODCALLTYPE *GetFunctionProvider)(ITfThreadMgrEx *, REFCLSID, ITfFunctionProvider **); + HRESULT (STDMETHODCALLTYPE *EnumFunctionProviders)(ITfThreadMgrEx *, IEnumTfFunctionProviders **); + HRESULT (STDMETHODCALLTYPE *GetGlobalCompartment)(ITfThreadMgrEx *, ITfCompartmentMgr **); + HRESULT (STDMETHODCALLTYPE *ActivateEx)(ITfThreadMgrEx *, TfClientId *, DWORD); + HRESULT (STDMETHODCALLTYPE *GetActiveFlags)(ITfThreadMgrEx *, DWORD *); +} ITfThreadMgrExVtbl; + +struct ITfThreadMgrEx +{ + const struct ITfThreadMgrExVtbl *lpVtbl; +}; + +typedef struct ITfDocumentMgrVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfDocumentMgr *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfDocumentMgr *); + ULONG (STDMETHODCALLTYPE *Release)(ITfDocumentMgr *); + HRESULT (STDMETHODCALLTYPE *CreateContext)(ITfDocumentMgr *, TfClientId, DWORD, IUnknown *, ITfContext **, TfEditCookie *); + HRESULT (STDMETHODCALLTYPE *Push)(ITfDocumentMgr *, ITfContext *); + HRESULT (STDMETHODCALLTYPE *Pop)(ITfDocumentMgr *); + HRESULT (STDMETHODCALLTYPE *GetTop)(ITfDocumentMgr *, ITfContext **); + HRESULT (STDMETHODCALLTYPE *GetBase)(ITfDocumentMgr *, ITfContext **); + HRESULT (STDMETHODCALLTYPE *EnumContexts)(ITfDocumentMgr *, IEnumTfContexts **); +} ITfDocumentMgrVtbl; + +struct ITfDocumentMgr +{ + const struct ITfDocumentMgrVtbl *lpVtbl; +}; + +typedef struct ITfUIElementSinkVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementSink *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementSink *); + ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementSink *); + HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementSink *, DWORD, BOOL *); + HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementSink *, DWORD); + HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementSink *, DWORD); +} ITfUIElementSinkVtbl; + +struct ITfUIElementSink +{ + const struct ITfUIElementSinkVtbl *lpVtbl; +}; + +typedef struct ITfUIElementMgrVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElementMgr *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElementMgr *); + ULONG (STDMETHODCALLTYPE *Release)(ITfUIElementMgr *); + HRESULT (STDMETHODCALLTYPE *BeginUIElement)(ITfUIElementMgr *, ITfUIElement *, BOOL *, DWORD *); + HRESULT (STDMETHODCALLTYPE *UpdateUIElement)(ITfUIElementMgr *, DWORD); + HRESULT (STDMETHODCALLTYPE *EndUIElement)(ITfUIElementMgr *, DWORD); + HRESULT (STDMETHODCALLTYPE *GetUIElement)(ITfUIElementMgr *, DWORD, ITfUIElement **); + HRESULT (STDMETHODCALLTYPE *EnumUIElements)(ITfUIElementMgr *, IEnumTfUIElements **); +} ITfUIElementMgrVtbl; + +struct ITfUIElementMgr +{ + const struct ITfUIElementMgrVtbl *lpVtbl; +}; + +typedef struct ITfCandidateListUIElementVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfCandidateListUIElement *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfCandidateListUIElement *); + ULONG (STDMETHODCALLTYPE *Release)(ITfCandidateListUIElement *); + HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfCandidateListUIElement *, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfCandidateListUIElement *, GUID *); + HRESULT (STDMETHODCALLTYPE *Show)(ITfCandidateListUIElement *, BOOL); + HRESULT (STDMETHODCALLTYPE *IsShown)(ITfCandidateListUIElement *, BOOL *); + HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfCandidateListUIElement *, DWORD *); + HRESULT (STDMETHODCALLTYPE *GetDocumentMgr)(ITfCandidateListUIElement *, ITfDocumentMgr **); + HRESULT (STDMETHODCALLTYPE *GetCount)(ITfCandidateListUIElement *, UINT *); + HRESULT (STDMETHODCALLTYPE *GetSelection)(ITfCandidateListUIElement *, UINT *); + HRESULT (STDMETHODCALLTYPE *GetString)(ITfCandidateListUIElement *, UINT, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT, UINT *); + HRESULT (STDMETHODCALLTYPE *SetPageIndex)(ITfCandidateListUIElement *, UINT *, UINT); + HRESULT (STDMETHODCALLTYPE *GetCurrentPage)(ITfCandidateListUIElement *, UINT *); +} ITfCandidateListUIElementVtbl; + +struct ITfCandidateListUIElement +{ + const struct ITfCandidateListUIElementVtbl *lpVtbl; +}; + +typedef struct ITfReadingInformationUIElementVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfReadingInformationUIElement *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfReadingInformationUIElement *); + ULONG (STDMETHODCALLTYPE *Release)(ITfReadingInformationUIElement *); + HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfReadingInformationUIElement *, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfReadingInformationUIElement *, GUID *); + HRESULT (STDMETHODCALLTYPE *Show)(ITfReadingInformationUIElement *, BOOL); + HRESULT (STDMETHODCALLTYPE *IsShown)(ITfReadingInformationUIElement *, BOOL *); + HRESULT (STDMETHODCALLTYPE *GetUpdatedFlags)(ITfReadingInformationUIElement *, DWORD *); + HRESULT (STDMETHODCALLTYPE *GetContext)(ITfReadingInformationUIElement *, ITfContext **); + HRESULT (STDMETHODCALLTYPE *GetString)(ITfReadingInformationUIElement *, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetMaxReadingStringLength)(ITfReadingInformationUIElement *, UINT *); + HRESULT (STDMETHODCALLTYPE *GetErrorIndex)(ITfReadingInformationUIElement *, UINT *); + HRESULT (STDMETHODCALLTYPE *IsVerticalOrderPreferred)(ITfReadingInformationUIElement *, BOOL *); +} ITfReadingInformationUIElementVtbl; + +struct ITfReadingInformationUIElement +{ + const struct ITfReadingInformationUIElementVtbl *lpVtbl; +}; + +typedef struct ITfUIElementVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfUIElement *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfUIElement *); + ULONG (STDMETHODCALLTYPE *Release)(ITfUIElement *); + HRESULT (STDMETHODCALLTYPE *GetDescription)(ITfUIElement *, BSTR *); + HRESULT (STDMETHODCALLTYPE *GetGUID)(ITfUIElement *, GUID *); + HRESULT (STDMETHODCALLTYPE *Show)(ITfUIElement *, BOOL); + HRESULT (STDMETHODCALLTYPE *IsShown)(ITfUIElement *, BOOL *); +} ITfUIElementVtbl; + +struct ITfUIElement +{ + const struct ITfUIElementVtbl *lpVtbl; +}; + +typedef struct ITfInputProcessorProfileActivationSinkVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfInputProcessorProfileActivationSink *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfInputProcessorProfileActivationSink *); + ULONG (STDMETHODCALLTYPE *Release)(ITfInputProcessorProfileActivationSink *); + HRESULT (STDMETHODCALLTYPE *OnActivated)(ITfInputProcessorProfileActivationSink *, DWORD, LANGID, REFCLSID, REFGUID, REFGUID, HKL, DWORD); + +} ITfInputProcessorProfileActivationSinkVtbl; + +struct ITfInputProcessorProfileActivationSink +{ + const struct ITfInputProcessorProfileActivationSinkVtbl *lpVtbl; +}; + +typedef struct ITfSourceVtbl +{ + HRESULT (STDMETHODCALLTYPE *QueryInterface)(ITfSource *, REFIID, void **); + ULONG (STDMETHODCALLTYPE *AddRef)(ITfSource *); + ULONG (STDMETHODCALLTYPE *Release)(ITfSource *); + HRESULT (STDMETHODCALLTYPE *AdviseSink)(ITfSource *, REFIID, IUnknown *, DWORD *); + HRESULT (STDMETHODCALLTYPE *UnadviseSink)(ITfSource *, DWORD); +} ITfSourceVtbl; + +struct ITfSource +{ + const struct ITfSourceVtbl *lpVtbl; +}; + +#endif /* _SDL_msctf_h */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_vkeys.h b/project/jni/sdl-1.3/src/video/windows/SDL_vkeys.h similarity index 53% rename from project/jni/sdl-1.3/src/video/win32/SDL_vkeys.h rename to project/jni/sdl-1.3/src/video/windows/SDL_vkeys.h index f4b4a2c44..2e9ea74fb 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_vkeys.h +++ b/project/jni/sdl-1.3/src/video/windows/SDL_vkeys.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #ifndef VK_0 diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32clipboard.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowsclipboard.c similarity index 69% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32clipboard.c rename to project/jni/sdl-1.3/src/video/windows/SDL_windowsclipboard.c index e7e5fd687..1310a18e1 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32clipboard.c +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsclipboard.c @@ -1,28 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_win32video.h" -#include "SDL_win32window.h" +#if SDL_VIDEO_DRIVER_WINDOWS + +#include "SDL_windowsvideo.h" +#include "SDL_windowswindow.h" #include "../../events/SDL_clipboardevents_c.h" @@ -37,15 +38,11 @@ static HWND GetWindowHandle(_THIS) { - SDL_VideoDisplay *display; SDL_Window *window; - display = _this->displays; - if (display) { - window = display->windows; - if (window) { - return ((SDL_WindowData *) window->driverdata)->hwnd; - } + window = _this->windows; + if (window) { + return ((SDL_WindowData *) window->driverdata)->hwnd; } return NULL; } @@ -141,11 +138,13 @@ WIN_GetClipboardText(_THIS) SDL_bool WIN_HasClipboardText(_THIS) { - if (IsClipboardFormatAvailable(TEXT_FORMAT)) { - return SDL_TRUE; - } else { - return SDL_FALSE; - } + SDL_bool result = SDL_FALSE; + char *text = WIN_GetClipboardText(_this); + if (text) { + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); + } + return result; } void @@ -166,4 +165,6 @@ WIN_CheckClipboardUpdate(struct SDL_VideoData * data) } } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsclipboard.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowsclipboard.h new file mode 100644 index 000000000..240bcb3cc --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsclipboard.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_windowsclipboard_h +#define _SDL_windowsclipboard_h + +/* Forward declaration */ +struct SDL_VideoData; + +extern int WIN_SetClipboardText(_THIS, const char *text); +extern char *WIN_GetClipboardText(_THIS); +extern SDL_bool WIN_HasClipboardText(_THIS); +extern void WIN_CheckClipboardUpdate(struct SDL_VideoData * data); + +#endif /* _SDL_windowsclipboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32events.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowsevents.c similarity index 85% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32events.c rename to project/jni/sdl-1.3/src/video/windows/SDL_windowsevents.c index 86c6c16f1..62bb92e43 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32events.c +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsevents.c @@ -1,29 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ - #include "SDL_config.h" -#include "SDL_win32video.h" -#include "SDL_win32shape.h" +#if SDL_VIDEO_DRIVER_WINDOWS + +#include "SDL_windowsvideo.h" +#include "SDL_windowsshape.h" #include "SDL_syswm.h" #include "SDL_vkeys.h" #include "../../events/SDL_events_c.h" @@ -113,10 +113,10 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_VERSION(&wmmsg.version); wmmsg.subsystem = SDL_SYSWM_WINDOWS; - wmmsg.win.hwnd = hwnd; - wmmsg.win.msg = msg; - wmmsg.win.wParam = wParam; - wmmsg.win.lParam = lParam; + wmmsg.msg.win.hwnd = hwnd; + wmmsg.msg.win.msg = msg; + wmmsg.msg.win.wParam = wParam; + wmmsg.msg.win.lParam = lParam; SDL_SendSysWMEvent(&wmmsg); } @@ -192,20 +192,18 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) case WM_MOUSEMOVE: #ifdef _WIN32_WCE - /* transform coords for VGA, WVGA... */ - { - SDL_VideoData *videodata = data->videodata; - if(videodata->CoordTransform && - (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW)) - { - POINT pt; - pt.x = LOWORD(lParam); - pt.y = HIWORD(lParam); - videodata->CoordTransform(data->window, &pt); - SDL_SendMouseMotion(data->window, 0, pt.x, pt.y); - break; - } - } + /* transform coords for VGA, WVGA... */ + { + SDL_VideoData *videodata = data->videodata; + if(videodata->CoordTransform) { + POINT pt; + pt.x = LOWORD(lParam); + pt.y = HIWORD(lParam); + videodata->CoordTransform(data->window, &pt); + SDL_SendMouseMotion(data->window, 0, pt.x, pt.y); + break; + } + } #endif SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam)); break; @@ -218,12 +216,49 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_LEFT); break; + case WM_RBUTTONDOWN: + SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_RIGHT); + break; + + case WM_RBUTTONUP: + SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_RIGHT); + break; + + case WM_MBUTTONDOWN: + SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_MIDDLE); + break; + + case WM_MBUTTONUP: + SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_MIDDLE); + break; + + case WM_XBUTTONDOWN: + SDL_SendMouseButton(data->window, SDL_PRESSED, SDL_BUTTON_X1 + GET_XBUTTON_WPARAM(wParam) - 1); + returnCode = TRUE; + break; + + case WM_XBUTTONUP: + SDL_SendMouseButton(data->window, SDL_RELEASED, SDL_BUTTON_X1 + GET_XBUTTON_WPARAM(wParam) - 1); + returnCode = TRUE; + break; + + case WM_MOUSEWHEEL: + { + int motion = (short) HIWORD(wParam); + + SDL_SendMouseWheel(data->window, 0, motion); + break; + } + +#ifdef WM_MOUSELEAVE + /* FIXME: Do we need the SDL 1.2 hack to generate WM_MOUSELEAVE now? */ case WM_MOUSELEAVE: if (SDL_GetMouseFocus() == data->window) { SDL_SetMouseFocus(NULL); } returnCode = 0; break; +#endif /* WM_MOUSELEAVE */ case WM_SYSKEYDOWN: case WM_KEYDOWN: @@ -348,13 +383,16 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) returnCode = 0; break; +#ifdef WM_INPUTLANGCHANGE case WM_INPUTLANGCHANGE: { WIN_UpdateKeymap(); } returnCode = 1; break; +#endif /* WM_INPUTLANGCHANGE */ +#ifdef WM_GETMINMAXINFO case WM_GETMINMAXINFO: { MINMAXINFO *info; @@ -413,6 +451,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } returnCode = 0; break; +#endif /* WM_GETMINMAXINFO */ case WM_WINDOWPOSCHANGED: { @@ -451,36 +490,12 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) hittest = LOWORD(lParam); if (hittest == HTCLIENT) { - /* FIXME: Implement the cursor API */ - static HCURSOR cursor; - if (!cursor) { - cursor = LoadCursor(NULL, IDC_ARROW); - } - SetCursor(cursor); + SetCursor(SDL_cursor); returnCode = TRUE; } } break; - /* We are about to get palette focus! */ - case WM_QUERYNEWPALETTE: - { - /* - WIN_RealizePalette(current_video); - returnCode = TRUE; - */ - } - break; - - /* Another application changed the palette */ - case WM_PALETTECHANGED: - { - /* - WIN_PaletteChanged(current_video, (HWND) wParam); - */ - } - break; - /* We were occluded, refresh our display */ case WM_PAINT: { @@ -500,6 +515,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } return (1); +#if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER) case WM_SYSCOMMAND: { /* Don't start the screensaver or blank the monitor in fullscreen apps */ @@ -511,6 +527,7 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) } } break; +#endif /* System has screensaver support */ case WM_CLOSE: { @@ -541,7 +558,8 @@ WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) for (i = 0; i < num_inputs; ++i) { PTOUCHINPUT input = &inputs[i]; - SDL_TouchID touchId = (SDL_TouchID)input->hSource; + const SDL_TouchID touchId = (SDL_TouchID) + ((size_t)input->hSource); if (!SDL_GetTouch(touchId)) { SDL_Touch touch; @@ -622,7 +640,9 @@ SDL_RegisterApp(char *name, Uint32 style, void *hInst) } if (!name && !SDL_Appname) { name = "SDL_app"; +#if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC) SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC); +#endif SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); } @@ -675,4 +695,6 @@ SDL_UnregisterApp() } } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsevents.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowsevents.h new file mode 100644 index 000000000..0e69e2ea0 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsevents.h @@ -0,0 +1,36 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_windowsevents_h +#define _SDL_windowsevents_h + +extern LPTSTR SDL_Appname; +extern Uint32 SDL_Appstyle; +extern HINSTANCE SDL_Instance; + +extern LRESULT CALLBACK WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, + LPARAM lParam); +extern void WIN_PumpEvents(_THIS); + +#endif /* _SDL_windowsevents_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsframebuffer.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowsframebuffer.c new file mode 100644 index 000000000..13948006d --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsframebuffer.c @@ -0,0 +1,128 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_WINDOWS + +#include "SDL_windowsvideo.h" + +#ifndef _WIN32_WCE +#define HAVE_GETDIBITS +#endif + +int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + size_t size; + LPBITMAPINFO info; +#ifdef HAVE_GETDIBITS + HBITMAP hbm; +#endif + + /* Free the old framebuffer surface */ + if (data->mdc) { + DeleteDC(data->mdc); + } + if (data->hbm) { + DeleteObject(data->hbm); + } + + /* Find out the format of the screen */ + size = sizeof(BITMAPINFOHEADER) + 256 * sizeof (RGBQUAD); + info = (LPBITMAPINFO)SDL_stack_alloc(Uint8, size); + +#ifdef HAVE_GETDIBITS + SDL_memset(info, 0, size); + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + + /* The second call to GetDIBits() fills in the bitfields */ + hbm = CreateCompatibleBitmap(data->hdc, 1, 1); + GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS); + GetDIBits(data->hdc, hbm, 0, 0, NULL, info, DIB_RGB_COLORS); + DeleteObject(hbm); + + *format = SDL_PIXELFORMAT_UNKNOWN; + if (info->bmiHeader.biCompression == BI_BITFIELDS) { + int bpp; + Uint32 *masks; + + bpp = info->bmiHeader.biPlanes * info->bmiHeader.biBitCount; + masks = (Uint32*)((Uint8*)info + info->bmiHeader.biSize); + *format = SDL_MasksToPixelFormatEnum(bpp, masks[0], masks[1], masks[2], 0); + } + if (*format == SDL_PIXELFORMAT_UNKNOWN) +#endif + { + /* We'll use RGB format for now */ + *format = SDL_PIXELFORMAT_RGB888; + + /* Create a new one */ + SDL_memset(info, 0, size); + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = 32; + info->bmiHeader.biCompression = BI_RGB; + } + + /* Fill in the size information */ + *pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); + info->bmiHeader.biWidth = window->w; + info->bmiHeader.biHeight = -window->h; /* negative for topdown bitmap */ + info->bmiHeader.biSizeImage = window->h * (*pitch); + + data->mdc = CreateCompatibleDC(data->hdc); + data->hbm = CreateDIBSection(data->hdc, info, DIB_RGB_COLORS, pixels, NULL, 0); + SDL_stack_free(info); + + if (!data->hbm) { + WIN_SetError("Unable to create DIB"); + return -1; + } + SelectObject(data->mdc, data->hbm); + + return 0; +} + +int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + + BitBlt(data->hdc, 0, 0, window->w, window->h, data->mdc, 0, 0, SRCCOPY); + return 0; +} + +void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + + if (data->mdc) { + DeleteDC(data->mdc); + data->mdc = NULL; + } + if (data->hbm) { + DeleteObject(data->hbm); + data->hbm = NULL; + } +} + +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsframebuffer.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowsframebuffer.h new file mode 100644 index 000000000..895233f62 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsframebuffer.h @@ -0,0 +1,27 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +extern int WIN_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, void ** pixels, int *pitch); +extern int WIN_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, int numrects); +extern void WIN_DestroyWindowFramebuffer(_THIS, SDL_Window * window); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32keyboard.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowskeyboard.c similarity index 93% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32keyboard.c rename to project/jni/sdl-1.3/src/video/windows/SDL_windowskeyboard.c index c35e3564d..a824505f4 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32keyboard.c +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowskeyboard.c @@ -1,38 +1,45 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_win32video.h" +#if SDL_VIDEO_DRIVER_WINDOWS + +#ifdef _WIN32_WCE +#define SDL_DISABLE_WINDOWS_IME +#endif + +#include "SDL_windowsvideo.h" #include "../../events/SDL_keyboard_c.h" -#include "../../events/scancodes_win32.h" +#include "../../events/scancodes_windows.h" #include #include +#ifndef SDL_DISABLE_WINDOWS_IME static void IME_Init(SDL_VideoData *videodata, HWND hwnd); static void IME_Enable(SDL_VideoData *videodata, HWND hwnd); static void IME_Disable(SDL_VideoData *videodata, HWND hwnd); static void IME_Quit(SDL_VideoData *videodata); +#endif /* !SDL_DISABLE_WINDOWS_IME */ #ifndef MAPVK_VK_TO_VSC #define MAPVK_VK_TO_VSC 0 @@ -87,7 +94,7 @@ WIN_InitKeyboard(_THIS) } } - data->key_layout = win32_scancode_table; + data->key_layout = windows_scancode_table; data->ime_com_initialized = SDL_FALSE; data->ime_threadmgr = 0; @@ -110,7 +117,6 @@ WIN_InitKeyboard(_THIS) data->ime_candlistindexbase = 0; data->ime_candvertical = SDL_TRUE; - data->ime_candtex = NULL; data->ime_dirty = SDL_FALSE; SDL_memset(&data->ime_rect, 0, sizeof(data->ime_rect)); SDL_memset(&data->ime_candlistrect, 0, sizeof(data->ime_candlistrect)); @@ -145,15 +151,15 @@ void WIN_UpdateKeymap() { int i; - SDL_scancode scancode; - SDLKey keymap[SDL_NUM_SCANCODES]; + SDL_Scancode scancode; + SDL_Keycode keymap[SDL_NUM_SCANCODES]; SDL_GetDefaultKeymap(keymap); - for (i = 0; i < SDL_arraysize(win32_scancode_table); i++) { + for (i = 0; i < SDL_arraysize(windows_scancode_table); i++) { /* Make sure this scancode is a valid character scancode */ - scancode = win32_scancode_table[i]; + scancode = windows_scancode_table[i]; if (scancode == SDL_SCANCODE_UNKNOWN || keymap[scancode] >= 127) { continue; } @@ -172,12 +178,15 @@ WIN_UpdateKeymap() void WIN_QuitKeyboard(_THIS) { +#ifndef SDL_DISABLE_WINDOWS_IME IME_Quit((SDL_VideoData *)_this->driverdata); +#endif } void WIN_StartTextInput(_THIS) { +#ifndef SDL_DISABLE_WINDOWS_IME SDL_Window *window = SDL_GetKeyboardFocus(); if (window) { HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; @@ -186,11 +195,13 @@ WIN_StartTextInput(_THIS) IME_Init(videodata, hwnd); IME_Enable(videodata, hwnd); } +#endif /* !SDL_DISABLE_WINDOWS_IME */ } void WIN_StopTextInput(_THIS) { +#ifndef SDL_DISABLE_WINDOWS_IME SDL_Window *window = SDL_GetKeyboardFocus(); if (window) { HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; @@ -198,6 +209,7 @@ WIN_StopTextInput(_THIS) IME_Init(videodata, hwnd); IME_Disable(videodata, hwnd); } +#endif /* !SDL_DISABLE_WINDOWS_IME */ } void @@ -207,6 +219,21 @@ WIN_SetTextInputRect(_THIS, SDL_Rect *rect) videodata->ime_rect = *rect; } +#ifdef SDL_DISABLE_WINDOWS_IME + + +SDL_bool +IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata) +{ + return SDL_FALSE; +} + +void IME_Present(SDL_VideoData *videodata) +{ +} + +#else + #ifdef __GNUC__ #undef DEFINE_GUID #define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) static const GUID n = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}} @@ -280,20 +307,20 @@ IME_Init(SDL_VideoData *videodata, HWND hwnd) return; videodata->ime_hwnd_main = hwnd; - if (SUCCEEDED(CoInitializeEx(NULL, COINIT_APARTMENTTHREADED))) { + if (SUCCEEDED(WIN_CoInitialize())) { videodata->ime_com_initialized = SDL_TRUE; CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr); } videodata->ime_initialized = SDL_TRUE; - videodata->ime_himm32 = LoadLibraryA("imm32.dll"); + videodata->ime_himm32 = SDL_LoadObject("imm32.dll"); if (!videodata->ime_himm32) { videodata->ime_available = SDL_FALSE; return; } - videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))GetProcAddress(videodata->ime_himm32, "ImmLockIMC"); - videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))GetProcAddress(videodata->ime_himm32, "ImmUnlockIMC"); - videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))GetProcAddress(videodata->ime_himm32, "ImmLockIMCC"); - videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))GetProcAddress(videodata->ime_himm32, "ImmUnlockIMCC"); + videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC"); + videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMC"); + videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMCC"); + videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMCC"); IME_SetWindow(videodata, hwnd); videodata->ime_himc = ImmGetContext(hwnd); @@ -356,7 +383,7 @@ IME_Quit(SDL_VideoData *videodata) videodata->ime_hwnd_main = 0; videodata->ime_himc = 0; if (videodata->ime_himm32) { - FreeLibrary(videodata->ime_himm32); + SDL_UnloadObject(videodata->ime_himm32); videodata->ime_himm32 = 0; } if (videodata->ime_threadmgr) { @@ -364,7 +391,7 @@ IME_Quit(SDL_VideoData *videodata) videodata->ime_threadmgr = 0; } if (videodata->ime_com_initialized) { - CoUninitialize(); + WIN_CoUninitialize(); videodata->ime_com_initialized = SDL_FALSE; } IME_DestroyTextures(videodata); @@ -507,7 +534,7 @@ IME_GetId(SDL_VideoData *videodata, UINT uIndex) return dwRet[uIndex]; hklprev = hkl; - dwLang = ((DWORD)hkl & 0xffff); + dwLang = ((DWORD_PTR)hkl & 0xffff); if (videodata->ime_uiless && LANG() == LANG_CHT) { dwRet[0] = IMEID_CHT_VER_VISTA; dwRet[1] = 0; @@ -579,7 +606,7 @@ static void IME_SetupAPI(SDL_VideoData *videodata) { char ime_file[MAX_PATH + 1]; - HMODULE hime = 0; + void* hime = 0; HKL hkl = 0; videodata->GetReadingString = 0; videodata->ShowReadingWindow = 0; @@ -590,14 +617,14 @@ IME_SetupAPI(SDL_VideoData *videodata) if (ImmGetIMEFileNameA(hkl, ime_file, sizeof(ime_file) - 1) <= 0) return; - hime = LoadLibraryA(ime_file); + hime = SDL_LoadObject(ime_file); if (!hime) return; videodata->GetReadingString = (UINT (WINAPI *)(HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT)) - GetProcAddress(hime, "GetReadingString"); + SDL_LoadFunction(hime, "GetReadingString"); videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL)) - GetProcAddress(hime, "ShowReadingWindow"); + SDL_LoadFunction(hime, "ShowReadingWindow"); if (videodata->ShowReadingWindow) { HIMC himc = ImmGetContext(videodata->ime_hwnd_current); @@ -754,7 +781,7 @@ IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata) UINT cchars = 0; for (; i < videodata->ime_candcount; ++i) { - UINT len = SDL_wcslen((LPWSTR)((DWORD)cand_list + cand_list->dwOffset[i])) + 1; + UINT len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1; if (len + cchars > maxcandchar) { if (i > cand_list->dwSelection) break; @@ -774,7 +801,7 @@ IME_GetCandidateList(HIMC himc, SDL_VideoData *videodata) } SDL_memset(&videodata->ime_candidates, 0, sizeof(videodata->ime_candidates)); for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++) { - LPCWSTR candidate = (LPCWSTR)((DWORD)cand_list + cand_list->dwOffset[i]); + LPCWSTR candidate = (LPCWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i]); IME_AddCandidate(videodata, j, candidate); } if (PRIMLANG() == LANG_KOREAN || (PRIMLANG() == LANG_CHT && !IME_GetId(videodata, 0))) @@ -1221,10 +1248,11 @@ UILess_ReleaseSinks(SDL_VideoData *videodata) static void * StartDrawToBitmap(HDC hdc, HBITMAP *hhbm, int width, int height) { - BITMAPINFO info = {0}; + BITMAPINFO info; BITMAPINFOHEADER *infoHeader = &info.bmiHeader; BYTE *bits = NULL; if (hhbm) { + SDL_zero(info); infoHeader->biSize = sizeof(BITMAPINFOHEADER); infoHeader->biWidth = width; infoHeader->biHeight = -1 * SDL_abs(height); @@ -1247,36 +1275,6 @@ StopDrawToBitmap(HDC hdc, HBITMAP *hhbm) } } -static void -BitmapToTexture(HBITMAP hbm, BYTE *bits, int width, int height, SDL_Texture **texture) -{ - SDL_Surface *surface = NULL; - BITMAP bm = {0}; - - if (GetObject(hbm, sizeof(bm), &bm) == 0) - return; - - if (bits && texture) { - /* - For transparency: - - const Uint8 alpha = 130; - unsigned long *p = (unsigned long *)bits; - unsigned long *end = (unsigned long *)(bits + (bm.bmWidthBytes * bm.bmHeight)); - while (p < end) { - *p = RGB(GetRValue(*p), GetGValue(*p), GetBValue(*p)) | (alpha << 24); - ++p; - } - surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0xff000000); - */ - surface = SDL_CreateRGBSurfaceFrom(bits, width, height, bm.bmBitsPixel, bm.bmWidthBytes, 0x00ff0000, 0x0000ff00, 0x000000ff, 0); - if (surface) { - *texture = SDL_CreateTextureFromSurface(0, surface); - SDL_FreeSurface(surface); - } - } -} - /* This draws only within the specified area and fills the entire region. */ static void DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize) @@ -1290,19 +1288,9 @@ DrawRect(HDC hdc, int left, int top, int right, int bottom, int pensize) Rectangle(hdc, left, top, right, bottom); } -static void -DestroyTexture(SDL_Texture **texture) -{ - if (texture && *texture) { - SDL_DestroyTexture(*texture); - *texture = NULL; - } -} - static void IME_DestroyTextures(SDL_VideoData *videodata) { - DestroyTexture(&videodata->ime_candtex); } #define SDL_swap(a,b) { \ @@ -1517,7 +1505,6 @@ IME_RenderCandidateList(SDL_VideoData *videodata, HDC hdc) DrawRect(hdc, left, top, right, bottom, candborder); ExtTextOutW(hdc, left + candborder + candpadding, top + candborder + candpadding, 0, NULL, s, SDL_wcslen(s), NULL); } - BitmapToTexture(hbm, bits, size.cx, size.cy, &videodata->ime_candtex); StopDrawToBitmap(hdc, &hbm); DeleteObject(listpen); @@ -1549,7 +1536,11 @@ void IME_Present(SDL_VideoData *videodata) if (videodata->ime_dirty) IME_Render(videodata); - SDL_RenderCopy(videodata->ime_candtex, NULL, &videodata->ime_candlistrect); + // FIXME: Need to show the IME bitmap } +#endif /* SDL_DISABLE_WINDOWS_IME */ + +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowskeyboard.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowskeyboard.h new file mode 100644 index 000000000..4c99cbdd7 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowskeyboard.h @@ -0,0 +1,41 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_windowskeyboard_h +#define _SDL_windowskeyboard_h + +extern BYTE alpha_scancodes[26]; +extern BYTE keypad_scancodes[10]; + +extern void WIN_InitKeyboard(_THIS); +extern void WIN_UpdateKeymap(void); +extern void WIN_QuitKeyboard(_THIS); + +extern void WIN_StartTextInput(_THIS); +extern void WIN_StopTextInput(_THIS); +extern void WIN_SetTextInputRect(_THIS, SDL_Rect *rect); + +extern SDL_bool IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, struct SDL_VideoData *videodata); + +#endif /* _SDL_windowskeyboard_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32modes.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowsmodes.c similarity index 69% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32modes.c rename to project/jni/sdl-1.3/src/video/windows/SDL_windowsmodes.c index 992b61517..71092ac93 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32modes.c +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsmodes.c @@ -1,35 +1,42 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_win32video.h" +#if SDL_VIDEO_DRIVER_WINDOWS +#include "SDL_windowsvideo.h" + +/* Windows CE compatibility */ +#ifndef CDS_FULLSCREEN +#define CDS_FULLSCREEN 0 +#endif static SDL_bool WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode) { SDL_DisplayModeData *data; DEVMODE devmode; +#ifndef _WIN32_WCE HDC hdc; +#endif devmode.dmSize = sizeof(devmode); devmode.dmDriverExtra = 0; @@ -160,35 +167,58 @@ WIN_AddDisplay(LPTSTR DeviceName) int WIN_InitModes(_THIS) { + int pass; DWORD i, j, count; DISPLAY_DEVICE device; device.cb = sizeof(device); - for (i = 0;; ++i) { - TCHAR DeviceName[32]; - if (!EnumDisplayDevices(NULL, i, &device, 0)) { - break; - } - if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) { - continue; - } - SDL_memcpy(DeviceName, device.DeviceName, sizeof(DeviceName)); -#ifdef DEBUG_MODES - printf("Device: %s\n", WIN_StringToUTF8(DeviceName)); -#endif - count = 0; - for (j = 0;; ++j) { - if (!EnumDisplayDevices(DeviceName, j, &device, 0)) { + /* Get the primary display in the first pass */ + for (pass = 0; pass < 2; ++pass) { + for (i = 0; ; ++i) { + TCHAR DeviceName[32]; + + if (!EnumDisplayDevices(NULL, i, &device, 0)) { break; } if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) { continue; } - count += WIN_AddDisplay(device.DeviceName); - } - if (count == 0) { - WIN_AddDisplay(DeviceName); + if (pass == 0) { + if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) { + continue; + } + } else { + if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { + continue; + } + } + SDL_memcpy(DeviceName, device.DeviceName, sizeof(DeviceName)); +#ifdef DEBUG_MODES + printf("Device: %s\n", WIN_StringToUTF8(DeviceName)); +#endif + count = 0; + for (j = 0; ; ++j) { + if (!EnumDisplayDevices(DeviceName, j, &device, 0)) { + break; + } + if (!(device.StateFlags & DISPLAY_DEVICE_ATTACHED_TO_DESKTOP)) { + continue; + } + if (pass == 0) { + if (!(device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE)) { + continue; + } + } else { + if (device.StateFlags & DISPLAY_DEVICE_PRIMARY_DEVICE) { + continue; + } + } + count += WIN_AddDisplay(device.DeviceName); + } + if (count == 0) { + WIN_AddDisplay(DeviceName); + } } } if (_this->num_displays == 0) { @@ -201,14 +231,14 @@ WIN_InitModes(_THIS) int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect) { - SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->desktop_mode.driverdata; + SDL_DisplayModeData *data = (SDL_DisplayModeData *) display->current_mode.driverdata; #ifdef _WIN32_WCE // WINCE: DEVMODE.dmPosition not found, or may be mingw32ce bug rect->x = 0; rect->y = 0; - rect->w = display->windows->w; - rect->h = display->windows->h; + rect->w = _this->windows->w; + rect->h = _this->windows->h; #else rect->x = (int)data->DeviceMode.dmPosition.x; rect->y = (int)data->DeviceMode.dmPosition.y; @@ -229,6 +259,10 @@ WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display) if (!WIN_GetDisplayMode(data->DeviceName, i, &mode)) { break; } + if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) { + /* We don't support palettized modes now */ + continue; + } if (mode.format != SDL_PIXELFORMAT_UNKNOWN) { if (!SDL_AddDisplayMode(display, &mode)) { SDL_free(mode.driverdata); @@ -255,9 +289,7 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) status = ChangeDisplaySettingsEx(displaydata->DeviceName, &data->DeviceMode, NULL, CDS_FULLSCREEN, NULL); - if (status == DISP_CHANGE_SUCCESSFUL) { - return 0; - } else { + if (status != DISP_CHANGE_SUCCESSFUL) { const char *reason = "Unknown reason"; switch (status) { case DISP_CHANGE_BADFLAGS: @@ -276,12 +308,16 @@ WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode) SDL_SetError("ChangeDisplaySettingsEx() failed: %s", reason); return -1; } + EnumDisplaySettings(displaydata->DeviceName, ENUM_CURRENT_SETTINGS, &data->DeviceMode); + return 0; } void WIN_QuitModes(_THIS) { - ChangeDisplaySettingsEx(NULL, NULL, NULL, 0, NULL); + /* All fullscreen windows should have restored modes by now */ } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsmodes.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowsmodes.h new file mode 100644 index 000000000..a3a5aef6a --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsmodes.h @@ -0,0 +1,44 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_windowsmodes_h +#define _SDL_windowsmodes_h + +typedef struct +{ + TCHAR DeviceName[32]; +} SDL_DisplayData; + +typedef struct +{ + DEVMODE DeviceMode; +} SDL_DisplayModeData; + +extern int WIN_InitModes(_THIS); +extern int WIN_GetDisplayBounds(_THIS, SDL_VideoDisplay * display, SDL_Rect * rect); +extern void WIN_GetDisplayModes(_THIS, SDL_VideoDisplay * display); +extern int WIN_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); +extern void WIN_QuitModes(_THIS); + +#endif /* _SDL_windowsmodes_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsmouse.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowsmouse.c new file mode 100644 index 000000000..0a0011fa9 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsmouse.c @@ -0,0 +1,168 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_WINDOWS + +#include "SDL_assert.h" +#include "SDL_windowsvideo.h" + +#include "../../events/SDL_mouse_c.h" + + +HCURSOR SDL_cursor = NULL; + + +static SDL_Cursor * +WIN_CreateDefaultCursor() +{ + SDL_Cursor *cursor; + + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + cursor->driverdata = LoadCursor(NULL, IDC_ARROW); + } else { + SDL_OutOfMemory(); + } + + return cursor; +} + +static SDL_Cursor * +WIN_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + SDL_Cursor *cursor; + HICON hicon; + HDC hdc; + BITMAPV4HEADER bmh; + LPVOID pixels; + ICONINFO ii; + + SDL_zero(bmh); + bmh.bV4Size = sizeof(bmh); + bmh.bV4Width = surface->w; + bmh.bV4Height = -surface->h; /* Invert the image */ + bmh.bV4Planes = 1; + bmh.bV4BitCount = 32; + bmh.bV4V4Compression = BI_BITFIELDS; + bmh.bV4AlphaMask = 0xFF000000; + bmh.bV4RedMask = 0x00FF0000; + bmh.bV4GreenMask = 0x0000FF00; + bmh.bV4BlueMask = 0x000000FF; + + hdc = GetDC(NULL); + SDL_zero(ii); + ii.fIcon = FALSE; + ii.xHotspot = (DWORD)hot_x; + ii.yHotspot = (DWORD)hot_y; + ii.hbmColor = CreateDIBSection(hdc, (BITMAPINFO*)&bmh, DIB_RGB_COLORS, &pixels, NULL, 0); + ii.hbmMask = CreateBitmap(surface->w, surface->h, 1, 1, NULL); + ReleaseDC(NULL, hdc); + + SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); + SDL_assert(surface->pitch == surface->w * 4); + SDL_memcpy(pixels, surface->pixels, surface->h * surface->pitch); + + hicon = CreateIconIndirect(&ii); + + DeleteObject(ii.hbmColor); + DeleteObject(ii.hbmMask); + + if (!hicon) { + WIN_SetError("CreateIconIndirect()"); + return NULL; + } + + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + cursor->driverdata = hicon; + } else { + DestroyIcon(hicon); + SDL_OutOfMemory(); + } + + return cursor; +} + +static void +WIN_FreeCursor(SDL_Cursor * cursor) +{ + HICON hicon = (HICON)cursor->driverdata; + + DestroyIcon(hicon); + SDL_free(cursor); +} + +static int +WIN_ShowCursor(SDL_Cursor * cursor) +{ + if (cursor) { + SDL_cursor = (HCURSOR)cursor->driverdata; + } else { + SDL_cursor = NULL; + } + if (SDL_GetMouseFocus() != NULL) { + SetCursor(SDL_cursor); + } + return 0; +} + +static void +WIN_WarpMouse(SDL_Window * window, int x, int y) +{ + HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; + POINT pt; + + pt.x = x; + pt.y = y; + ClientToScreen(hwnd, &pt); + SetCursorPos(pt.x, pt.y); +} + +static int +WIN_SetRelativeMouseMode(SDL_bool enabled) +{ + SDL_Unsupported(); + return -1; +} + +void +WIN_InitMouse(_THIS) +{ + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = WIN_CreateCursor; + mouse->ShowCursor = WIN_ShowCursor; + mouse->FreeCursor = WIN_FreeCursor; + mouse->WarpMouse = WIN_WarpMouse; + mouse->SetRelativeMouseMode = WIN_SetRelativeMouseMode; + + SDL_SetDefaultCursor(WIN_CreateDefaultCursor()); +} + +void +WIN_QuitMouse(_THIS) +{ +} + +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsmouse.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowsmouse.h new file mode 100644 index 000000000..ed30e536e --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsmouse.h @@ -0,0 +1,33 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#ifndef _SDL_windowsmouse_h +#define _SDL_windowsmouse_h + +extern HCURSOR SDL_cursor; + +extern void WIN_InitMouse(_THIS); +extern void WIN_QuitMouse(_THIS); + +#endif /* _SDL_windowsmouse_h */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32opengl.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowsopengl.c similarity index 93% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32opengl.c rename to project/jni/sdl-1.3/src/video/windows/SDL_windowsopengl.c index 326ae53c0..a69f30864 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32opengl.c +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsopengl.c @@ -1,27 +1,28 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#include "SDL_win32video.h" +#if SDL_VIDEO_DRIVER_WINDOWS + +#include "SDL_windowsvideo.h" /* WGL implementation of SDL OpenGL support */ @@ -101,7 +102,7 @@ WIN_GL_LoadLibrary(_THIS, const char *path) !_this->gl_data->wglDeleteContext || !_this->gl_data->wglMakeCurrent) { SDL_SetError("Could not retrieve OpenGL functions"); - FreeLibrary(handle); + SDL_UnloadObject(handle); return -1; } @@ -409,8 +410,6 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window) *iAttr++ = WGL_DRAW_TO_WINDOW_ARB; *iAttr++ = GL_TRUE; - *iAttr++ = WGL_ACCELERATION_ARB; - *iAttr++ = WGL_FULL_ACCELERATION_ARB; *iAttr++ = WGL_RED_BITS_ARB; *iAttr++ = _this->gl_config.red_size; *iAttr++ = WGL_GREEN_BITS_ARB; @@ -471,9 +470,8 @@ WIN_GL_SetupWindow(_THIS, SDL_Window * window) if (_this->gl_config.accelerated >= 0) { *iAttr++ = WGL_ACCELERATION_ARB; - *iAttr++ = - (_this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB : - WGL_NO_ACCELERATION_ARB); + *iAttr++ = (_this->gl_config.accelerated ? WGL_FULL_ACCELERATION_ARB : + WGL_NO_ACCELERATION_ARB); } *iAttr = 0; @@ -609,4 +607,6 @@ WIN_GL_DeleteContext(_THIS, SDL_GLContext context) #endif /* SDL_VIDEO_OPENGL_WGL */ +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32opengl.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowsopengl.h similarity index 80% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32opengl.h rename to project/jni/sdl-1.3/src/video/windows/SDL_windowsopengl.h index d3a938a4c..5ef245937 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32opengl.h +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsopengl.h @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#ifndef _SDL_win32opengl_h -#define _SDL_win32opengl_h +#ifndef _SDL_windowsopengl_h +#define _SDL_windowsopengl_h #if SDL_VIDEO_OPENGL_WGL @@ -121,6 +120,6 @@ extern void WIN_GL_DeleteContext(_THIS, SDL_GLContext context); #endif /* SDL_VIDEO_OPENGL_WGL */ -#endif /* _SDL_win32opengl_h */ +#endif /* _SDL_windowsopengl_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32shape.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowsshape.c similarity index 71% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32shape.c rename to project/jni/sdl-1.3/src/video/windows/SDL_windowsshape.c index 68350a572..e915ae067 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32shape.c +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsshape.c @@ -1,29 +1,30 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_WINDOWS -#include #include "SDL_assert.h" -#include "SDL_win32shape.h" -#include "SDL_win32video.h" +#include "SDL_windowsshape.h" +#include "SDL_windowsvideo.h" SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window) { @@ -102,3 +103,5 @@ Win32_ResizeWindowShape(SDL_Window *window) { return 0; } + +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsshape.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowsshape.h new file mode 100644 index 000000000..0de69bf9d --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsshape.h @@ -0,0 +1,40 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ + +#include "SDL_config.h" + +#ifndef _SDL_windowsshape_h +#define _SDL_windowsshape_h + +#include "SDL_video.h" +#include "SDL_shape.h" +#include "../SDL_sysvideo.h" +#include "../SDL_shape_internals.h" + +typedef struct { + SDL_ShapeTree *mask_tree; +} SDL_ShapeData; + +extern SDL_WindowShaper* Win32_CreateShaper(SDL_Window * window); +extern int Win32_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMode *shape_mode); +extern int Win32_ResizeWindowShape(SDL_Window *window); + +#endif /* _SDL_windowsshape_h */ diff --git a/project/jni/sdl-1.3/src/video/windows/SDL_windowsvideo.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowsvideo.c new file mode 100644 index 000000000..c90e91955 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsvideo.c @@ -0,0 +1,193 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_WINDOWS + +#include "SDL_main.h" +#include "SDL_video.h" +#include "SDL_mouse.h" +#include "../SDL_sysvideo.h" +#include "../SDL_pixels_c.h" + +#include "SDL_windowsvideo.h" +#include "SDL_windowsframebuffer.h" +#include "SDL_windowsshape.h" + +/* Initialization/Query functions */ +static int WIN_VideoInit(_THIS); +static void WIN_VideoQuit(_THIS); + + +/* Windows driver bootstrap functions */ + +static int +WIN_Available(void) +{ + return (1); +} + +static void +WIN_DeleteDevice(SDL_VideoDevice * device) +{ + SDL_VideoData *data = (SDL_VideoData *) device->driverdata; + + SDL_UnregisterApp(); +#ifdef _WIN32_WCE + if(data->hAygShell) { + SDL_UnloadObject(data->hAygShell); + } +#endif + if (data->userDLL) { + SDL_UnloadObject(data->userDLL); + } + + SDL_free(device->driverdata); + SDL_free(device); +} + +static SDL_VideoDevice * +WIN_CreateDevice(int devindex) +{ + SDL_VideoDevice *device; + SDL_VideoData *data; + + SDL_RegisterApp(NULL, 0, NULL); + + /* Initialize all variables that we clean on shutdown */ + device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice)); + if (device) { + data = (struct SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData)); + } else { + data = NULL; + } + if (!data) { + SDL_OutOfMemory(); + if (device) { + SDL_free(device); + } + return NULL; + } + device->driverdata = data; + +#ifdef _WIN32_WCE + data->hAygShell = SDL_LoadObject("\\windows\\aygshell.dll"); + if(0 == data->hAygShell) + data->hAygShell = SDL_LoadObject("aygshell.dll"); + data->SHFullScreen = (0 != data->hAygShell ? + (PFNSHFullScreen) SDL_LoadFunction(data->hAygShell, "SHFullScreen") : 0); + data->CoordTransform = NULL; +#endif + + data->userDLL = SDL_LoadObject("USER32.DLL"); + if (data->userDLL) { + data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle"); + data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo"); + data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow"); + } + + /* Set the function pointers */ + device->VideoInit = WIN_VideoInit; + device->VideoQuit = WIN_VideoQuit; + device->GetDisplayBounds = WIN_GetDisplayBounds; + device->GetDisplayModes = WIN_GetDisplayModes; + device->SetDisplayMode = WIN_SetDisplayMode; + device->PumpEvents = WIN_PumpEvents; + +#undef CreateWindow + device->CreateWindow = WIN_CreateWindow; + device->CreateWindowFrom = WIN_CreateWindowFrom; + device->SetWindowTitle = WIN_SetWindowTitle; + device->SetWindowIcon = WIN_SetWindowIcon; + device->SetWindowPosition = WIN_SetWindowPosition; + device->SetWindowSize = WIN_SetWindowSize; + device->ShowWindow = WIN_ShowWindow; + device->HideWindow = WIN_HideWindow; + device->RaiseWindow = WIN_RaiseWindow; + device->MaximizeWindow = WIN_MaximizeWindow; + device->MinimizeWindow = WIN_MinimizeWindow; + device->RestoreWindow = WIN_RestoreWindow; + device->SetWindowFullscreen = WIN_SetWindowFullscreen; + device->SetWindowGammaRamp = WIN_SetWindowGammaRamp; + device->GetWindowGammaRamp = WIN_GetWindowGammaRamp; + device->SetWindowGrab = WIN_SetWindowGrab; + device->DestroyWindow = WIN_DestroyWindow; + device->GetWindowWMInfo = WIN_GetWindowWMInfo; + device->CreateWindowFramebuffer = WIN_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = WIN_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = WIN_DestroyWindowFramebuffer; + + device->shape_driver.CreateShaper = Win32_CreateShaper; + device->shape_driver.SetWindowShape = Win32_SetWindowShape; + device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape; + +#if SDL_VIDEO_OPENGL_WGL + device->GL_LoadLibrary = WIN_GL_LoadLibrary; + device->GL_GetProcAddress = WIN_GL_GetProcAddress; + device->GL_UnloadLibrary = WIN_GL_UnloadLibrary; + device->GL_CreateContext = WIN_GL_CreateContext; + device->GL_MakeCurrent = WIN_GL_MakeCurrent; + device->GL_SetSwapInterval = WIN_GL_SetSwapInterval; + device->GL_GetSwapInterval = WIN_GL_GetSwapInterval; + device->GL_SwapWindow = WIN_GL_SwapWindow; + device->GL_DeleteContext = WIN_GL_DeleteContext; +#endif + device->StartTextInput = WIN_StartTextInput; + device->StopTextInput = WIN_StopTextInput; + device->SetTextInputRect = WIN_SetTextInputRect; + + device->SetClipboardText = WIN_SetClipboardText; + device->GetClipboardText = WIN_GetClipboardText; + device->HasClipboardText = WIN_HasClipboardText; + + device->free = WIN_DeleteDevice; + + return device; +} + +VideoBootStrap WINDOWS_bootstrap = { + "windows", "SDL Windows video driver", WIN_Available, WIN_CreateDevice +}; + +int +WIN_VideoInit(_THIS) +{ + if (WIN_InitModes(_this) < 0) { + return -1; + } + + WIN_InitKeyboard(_this); + WIN_InitMouse(_this); + + return 0; +} + +void +WIN_VideoQuit(_THIS) +{ + WIN_QuitModes(_this); + WIN_QuitKeyboard(_this); + WIN_QuitMouse(_this); +} + +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + +/* vim: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32video.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowsvideo.h similarity index 57% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32video.h rename to project/jni/sdl-1.3/src/video/windows/SDL_windowsvideo.h index 61c6fb54b..e046c386f 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32video.h +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowsvideo.h @@ -1,42 +1,33 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#ifndef _SDL_win32video_h -#define _SDL_win32video_h +#ifndef _SDL_windowsvideo_h +#define _SDL_windowsvideo_h #include "../SDL_sysvideo.h" -#define WIN32_LEAN_AND_MEAN -#define STRICT -#ifndef UNICODE -#define UNICODE -#endif -#undef WINVER -#define WINVER 0x500 /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */ +#include "../../core/windows/SDL_windows.h" -#include - -#ifndef __GNUC__ +#if defined(_MSC_VER) && !defined(_WIN32_WCE) #include #else #include "SDL_msctf.h" @@ -47,38 +38,16 @@ #define MAX_CANDLIST 10 #define MAX_CANDLENGTH 256 -#if SDL_VIDEO_RENDER_D3D -//#include -#define D3D_DEBUG_INFO -#include "d3d9.h" -#endif - -#if SDL_VIDEO_RENDER_DDRAW -/* WIN32_LEAN_AND_MEAN was defined, so we have to include this by hand */ -#include -#include "ddraw.h" -#endif - -#include "SDL_win32clipboard.h" -#include "SDL_win32events.h" -#include "SDL_win32gamma.h" -#include "SDL_win32keyboard.h" -#include "SDL_win32modes.h" -#include "SDL_win32mouse.h" -#include "SDL_win32opengl.h" -#include "SDL_win32window.h" +#include "SDL_windowsclipboard.h" +#include "SDL_windowsevents.h" +#include "SDL_windowskeyboard.h" +#include "SDL_windowsmodes.h" +#include "SDL_windowsmouse.h" +#include "SDL_windowsopengl.h" +#include "SDL_windowswindow.h" #include "SDL_events.h" +#include "SDL_loadso.h" -#ifdef UNICODE -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR)) -#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1) -#else -#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1)) -#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1) -#endif -extern void WIN_SetError(const char *prefix); - -enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW }; #if WINVER < 0x0601 /* Touch input definitions */ @@ -91,17 +60,17 @@ enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RA DECLARE_HANDLE(HTOUCHINPUT); -typedef struct _TOUCHINPUT { - LONG x; - LONG y; - HANDLE hSource; - DWORD dwID; - DWORD dwFlags; - DWORD dwMask; - DWORD dwTime; - ULONG_PTR dwExtraInfo; - DWORD cxContact; - DWORD cyContact; +typedef struct _TOUCHINPUT { + LONG x; + LONG y; + HANDLE hSource; + DWORD dwID; + DWORD dwFlags; + DWORD dwMask; + DWORD dwTime; + ULONG_PTR dwExtraInfo; + DWORD cxContact; + DWORD cyContact; } TOUCHINPUT, *PTOUCHINPUT; #endif /* WINVER < 0x0601 */ @@ -146,28 +115,20 @@ typedef struct SDL_VideoData { int render; -#if SDL_VIDEO_RENDER_D3D - HANDLE d3dDLL; - IDirect3D9 *d3d; -#endif -#if SDL_VIDEO_RENDER_DDRAW - HANDLE ddrawDLL; - IDirectDraw *ddraw; -#endif #ifdef _WIN32_WCE - HMODULE hAygShell; + void* hAygShell; PFNSHFullScreen SHFullScreen; PFCoordTransform CoordTransform; #endif - const SDL_scancode *key_layout; + const SDL_Scancode *key_layout; DWORD clipboard_count; /* Touch input functions */ - HANDLE userDLL; + void* userDLL; BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT ); BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int ); - BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); + BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG ); SDL_bool ime_com_initialized; struct ITfThreadMgr *ime_threadmgr; @@ -191,7 +152,6 @@ typedef struct SDL_VideoData int ime_candlistindexbase; SDL_bool ime_candvertical; - SDL_Texture *ime_candtex; SDL_bool ime_dirty; SDL_Rect ime_rect; SDL_Rect ime_candlistrect; @@ -199,7 +159,7 @@ typedef struct SDL_VideoData int ime_winheight; HKL ime_hkl; - HMODULE ime_himm32; + void* ime_himm32; UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen); BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow); LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc); @@ -217,6 +177,6 @@ typedef struct SDL_VideoData TSFSink *ime_ippasink; } SDL_VideoData; -#endif /* _SDL_win32video_h */ +#endif /* _SDL_windowsvideo_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32window.c b/project/jni/sdl-1.3/src/video/windows/SDL_windowswindow.c similarity index 60% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32window.c rename to project/jni/sdl-1.3/src/video/windows/SDL_windowswindow.c index da8de070f..ed3a53e91 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32window.c +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowswindow.c @@ -1,45 +1,41 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ - -/* we need to define it, so that raw input is included */ - -#if (_WIN32_WINNT < 0x0501) -#undef _WIN32_WINNT -#define _WIN32_WINNT 0x0501 -#endif - #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_WINDOWS + #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" #include "../../events/SDL_keyboard_c.h" -#include "SDL_win32video.h" -#include "SDL_win32window.h" +#include "SDL_windowsvideo.h" +#include "SDL_windowswindow.h" -/* This is included after SDL_win32video.h, which includes windows.h */ +/* This is included after SDL_windowsvideo.h, which includes windows.h */ #include "SDL_syswm.h" -#include "SDL_gapirender.h" +/* Windows CE compatibility */ +#ifndef SWP_NOCOPYBITS +#define SWP_NOCOPYBITS 0 +#endif /* Fake window to help with DirectInput events. */ HWND SDL_HelperWindow = NULL; @@ -47,11 +43,38 @@ static WCHAR *SDL_HelperWindowClassName = TEXT("SDLHelperWindowInputCatcher"); static WCHAR *SDL_HelperWindowName = TEXT("SDLHelperWindowInputMsgWindow"); static ATOM SDL_HelperWindowClass = 0; +#define STYLE_BASIC (WS_CLIPSIBLINGS | WS_CLIPCHILDREN) +#define STYLE_FULLSCREEN (WS_POPUP) +#define STYLE_BORDERLESS (WS_POPUP) +#define STYLE_NORMAL (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX) +#define STYLE_RESIZABLE (WS_THICKFRAME | WS_MAXIMIZEBOX) +#define STYLE_MASK (STYLE_FULLSCREEN | STYLE_BORDERLESS | STYLE_NORMAL | STYLE_RESIZABLE) + +static DWORD +GetWindowStyle(SDL_Window * window) +{ + DWORD style = 0; + + if (window->flags & SDL_WINDOW_FULLSCREEN) { + style |= STYLE_FULLSCREEN; + } else { + if (window->flags & SDL_WINDOW_BORDERLESS) { + style |= STYLE_BORDERLESS; + } else { + style |= STYLE_NORMAL; + } + if (window->flags & SDL_WINDOW_RESIZABLE) { + style |= STYLE_RESIZABLE; + } + } + return style; +} + static int SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) { SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); SDL_WindowData *data; /* Allocate the window data */ @@ -67,6 +90,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) data->mouse_pressed = SDL_FALSE; data->videodata = videodata; + window->driverdata = data; + /* Associate the data with the window */ if (!SetProp(hwnd, TEXT("SDL_WindowData"), data)) { ReleaseDC(hwnd, data->hdc); @@ -76,13 +101,21 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) } /* Set up the window proc function */ +#ifdef GWLP_WNDPROC data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC); if (data->wndproc == WIN_WindowProc) { data->wndproc = NULL; - } - else { + } else { SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc); } +#else + data->wndproc = (WNDPROC) GetWindowLong(hwnd, GWL_WNDPROC); + if (data->wndproc == WIN_WindowProc) { + data->wndproc = NULL; + } else { + SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR) WIN_WindowProc); + } +#endif /* Fill in the SDL window with the window data */ { @@ -90,10 +123,8 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) point.x = 0; point.y = 0; if (ClientToScreen(hwnd, &point)) { - SDL_Rect bounds; - WIN_GetDisplayBounds(_this, display, &bounds); - window->x = point.x - bounds.x; - window->y = point.y - bounds.y; + window->x = point.x; + window->y = point.y; } } { @@ -120,14 +151,20 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) } else { window->flags &= ~SDL_WINDOW_RESIZABLE; } +#ifdef WS_MAXIMIZE if (style & WS_MAXIMIZE) { window->flags |= SDL_WINDOW_MAXIMIZED; - } else { + } else +#endif + { window->flags &= ~SDL_WINDOW_MAXIMIZED; } +#ifdef WS_MINIMIZE if (style & WS_MINIMIZE) { window->flags |= SDL_WINDOW_MINIMIZED; - } else { + } else +#endif + { window->flags &= ~SDL_WINDOW_MINIMIZED; } } @@ -144,80 +181,38 @@ SetupWindowData(_THIS, SDL_Window * window, HWND hwnd, SDL_bool created) } } - /* Enable multi-touch */ + /* Enable multi-touch */ if (videodata->RegisterTouchWindow) { videodata->RegisterTouchWindow(hwnd, (TWF_FINETOUCH|TWF_WANTPALM)); } /* All done! */ - window->driverdata = data; return 0; } int WIN_CreateWindow(_THIS, SDL_Window * window) { - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); HWND hwnd; RECT rect; - SDL_Rect bounds; - DWORD style = (WS_CLIPSIBLINGS | WS_CLIPCHILDREN); + DWORD style = STYLE_BASIC; int x, y; int w, h; - - if (window->flags & (SDL_WINDOW_BORDERLESS | SDL_WINDOW_FULLSCREEN)) { - style |= WS_POPUP; - } else { - style |= (WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX); - } - if ((window->flags & SDL_WINDOW_RESIZABLE) - && !(window->flags & SDL_WINDOW_FULLSCREEN)) { - style |= (WS_THICKFRAME | WS_MAXIMIZEBOX); - } + + style |= GetWindowStyle(window); /* Figure out what the window area will be */ - rect.left = 0; - rect.top = 0; - rect.right = window->w; - rect.bottom = window->h; + rect.left = window->x; + rect.top = window->y; + rect.right = window->x + window->w; + rect.bottom = window->y + window->h; AdjustWindowRectEx(&rect, style, FALSE, 0); + x = rect.left; + y = rect.top; w = (rect.right - rect.left); h = (rect.bottom - rect.top); - WIN_GetDisplayBounds(_this, display, &bounds); - if (window->flags & SDL_WINDOW_FULLSCREEN) { - /* The bounds when this window is visible is the fullscreen mode */ - SDL_DisplayMode fullscreen_mode; - if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { - bounds.w = fullscreen_mode.w; - bounds.h = fullscreen_mode.h; - } - } - if ((window->flags & SDL_WINDOW_FULLSCREEN) - || window->x == SDL_WINDOWPOS_CENTERED) { - x = bounds.x + (bounds.w - w) / 2; - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { - if (bounds.x == 0) { - x = CW_USEDEFAULT; - } else { - x = bounds.x; - } - } else { - x = bounds.x + window->x + rect.left; - } - if ((window->flags & SDL_WINDOW_FULLSCREEN) - || window->y == SDL_WINDOWPOS_CENTERED) { - y = bounds.y + (bounds.h - h) / 2; - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { - if (bounds.x == 0) { - y = CW_USEDEFAULT; - } else { - y = bounds.y; - } - } else { - y = bounds.y + window->y + rect.top; - } - hwnd = CreateWindow(SDL_Appname, TEXT(""), style, x, y, w, h, NULL, NULL, SDL_Instance, NULL); @@ -225,7 +220,6 @@ WIN_CreateWindow(_THIS, SDL_Window * window) WIN_SetError("Couldn't create window"); return -1; } - //RegisterTouchWindow(hwnd, 0); WIN_PumpEvents(_this); @@ -233,7 +227,7 @@ WIN_CreateWindow(_THIS, SDL_Window * window) DestroyWindow(hwnd); return -1; } -#ifdef SDL_VIDEO_OPENGL_WGL +#if SDL_VIDEO_OPENGL_WGL if (window->flags & SDL_WINDOW_OPENGL) { if (WIN_GL_SetupWindow(_this, window) < 0) { WIN_DestroyWindow(_this, window); @@ -294,58 +288,51 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) { HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; HICON hicon = NULL; + BYTE *icon_bmp; + int icon_len; + SDL_RWops *dst; + SDL_Surface *surface; - if (icon) { - BYTE *icon_bmp; - int icon_len; - SDL_RWops *dst; - SDL_PixelFormat format; - SDL_Surface *surface; + /* Create temporary bitmap buffer */ + icon_len = 40 + icon->h * icon->w * 4; + icon_bmp = SDL_stack_alloc(BYTE, icon_len); + dst = SDL_RWFromMem(icon_bmp, icon_len); + if (!dst) { + SDL_stack_free(icon_bmp); + return; + } - /* Create temporary bitmap buffer */ - icon_len = 40 + icon->h * icon->w * 4; - icon_bmp = SDL_stack_alloc(BYTE, icon_len); - dst = SDL_RWFromMem(icon_bmp, icon_len); - if (!dst) { - SDL_stack_free(icon_bmp); - return; + /* Write the BITMAPINFO header */ + SDL_WriteLE32(dst, 40); + SDL_WriteLE32(dst, icon->w); + SDL_WriteLE32(dst, icon->h * 2); + SDL_WriteLE16(dst, 1); + SDL_WriteLE16(dst, 32); + SDL_WriteLE32(dst, BI_RGB); + SDL_WriteLE32(dst, icon->h * icon->w * 4); + SDL_WriteLE32(dst, 0); + SDL_WriteLE32(dst, 0); + SDL_WriteLE32(dst, 0); + SDL_WriteLE32(dst, 0); + + /* Convert the icon to a 32-bit surface with alpha channel */ + surface = SDL_ConvertSurfaceFormat(icon, SDL_PIXELFORMAT_ARGB8888, 0); + if (surface) { + /* Write the pixels upside down into the bitmap buffer */ + int y = surface->h; + while (y--) { + Uint8 *src = (Uint8 *) surface->pixels + y * surface->pitch; + SDL_RWwrite(dst, src, surface->pitch, 1); } - - /* Write the BITMAPINFO header */ - SDL_WriteLE32(dst, 40); - SDL_WriteLE32(dst, icon->w); - SDL_WriteLE32(dst, icon->h * 2); - SDL_WriteLE16(dst, 1); - SDL_WriteLE16(dst, 32); - SDL_WriteLE32(dst, BI_RGB); - SDL_WriteLE32(dst, icon->h * icon->w * 4); - SDL_WriteLE32(dst, 0); - SDL_WriteLE32(dst, 0); - SDL_WriteLE32(dst, 0); - SDL_WriteLE32(dst, 0); - - /* Convert the icon to a 32-bit surface with alpha channel */ - SDL_InitFormat(&format, 32, - 0x00FF0000, 0x0000FF00, 0x000000FF, 0xFF000000); - surface = SDL_ConvertSurface(icon, &format, 0); - if (surface) { - /* Write the pixels upside down into the bitmap buffer */ - int y = surface->h; - while (y--) { - Uint8 *src = (Uint8 *) surface->pixels + y * surface->pitch; - SDL_RWwrite(dst, src, surface->pitch, 1); - } - SDL_FreeSurface(surface); + SDL_FreeSurface(surface); /* TODO: create the icon in WinCE (CreateIconFromResource isn't available) */ #ifndef _WIN32_WCE - hicon = - CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000); + hicon = CreateIconFromResource(icon_bmp, icon_len, TRUE, 0x00030000); #endif - } - SDL_RWclose(dst); - SDL_stack_free(icon_bmp); } + SDL_RWclose(dst); + SDL_stack_free(icon_bmp); /* Set the icon for the window */ SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM) hicon); @@ -357,10 +344,9 @@ WIN_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) void WIN_SetWindowPosition(_THIS, SDL_Window * window) { - SDL_VideoDisplay *display = window->display; + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; RECT rect; - SDL_Rect bounds; DWORD style; HWND top; BOOL menu; @@ -386,28 +372,8 @@ WIN_SetWindowPosition(_THIS, SDL_Window * window) AdjustWindowRectEx(&rect, style, menu, 0); w = (rect.right - rect.left); h = (rect.bottom - rect.top); - - WIN_GetDisplayBounds(_this, display, &bounds); - if (window->flags & SDL_WINDOW_FULLSCREEN) { - /* The bounds when this window is visible is the fullscreen mode */ - SDL_DisplayMode fullscreen_mode; - if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { - bounds.w = fullscreen_mode.w; - bounds.h = fullscreen_mode.h; - } - } - if ((window->flags & SDL_WINDOW_FULLSCREEN) - || window->x == SDL_WINDOWPOS_CENTERED) { - x = bounds.x + (bounds.w - w) / 2; - } else { - x = bounds.x + window->x + rect.left; - } - if ((window->flags & SDL_WINDOW_FULLSCREEN) - || window->y == SDL_WINDOWPOS_CENTERED) { - y = bounds.y + (bounds.h - h) / 2; - } else { - y = bounds.y + window->y + rect.top; - } + x = window->x + rect.left; + y = window->y + rect.top; SetWindowPos(hwnd, top, x, y, 0, 0, (SWP_NOCOPYBITS | SWP_NOSIZE)); } @@ -445,6 +411,36 @@ WIN_SetWindowSize(_THIS, SDL_Window * window) SetWindowPos(hwnd, top, 0, 0, w, h, (SWP_NOCOPYBITS | SWP_NOMOVE)); } +#ifdef _WIN32_WCE +void WINCE_ShowWindow(_THIS, SDL_Window* window, int visible) +{ + SDL_WindowData* windowdata = (SDL_WindowData*) window->driverdata; + SDL_VideoData *videodata = (SDL_VideoData *) _this->driverdata; + + if(visible) { + if(window->flags & SDL_WINDOW_FULLSCREEN) { + if(videodata->SHFullScreen) + videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON); + + ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE); + } + + ShowWindow(windowdata->hwnd, SW_SHOW); + SetForegroundWindow(windowdata->hwnd); + } else { + ShowWindow(windowdata->hwnd, SW_HIDE); + + if(window->flags & SDL_WINDOW_FULLSCREEN) { + if(videodata->SHFullScreen) + videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON); + + ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW); + + } + } +} +#endif /* _WIN32_WCE */ + void WIN_ShowWindow(_THIS, SDL_Window * window) { @@ -505,7 +501,7 @@ WIN_MinimizeWindow(_THIS, SDL_Window * window) #ifdef _WIN32_WCE if((window->flags & SDL_WINDOW_FULLSCREEN) && videodata->SHFullScreen) - videodata->SHFullScreen(hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON); + videodata->SHFullScreen(hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON); #endif } @@ -517,13 +513,110 @@ WIN_RestoreWindow(_THIS, SDL_Window * window) ShowWindow(hwnd, SW_RESTORE); } +void +WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + HWND hwnd = data->hwnd; + RECT rect; + SDL_Rect bounds; + DWORD style; + HWND top; + BOOL menu; + int x, y; + int w, h; + + if (fullscreen) { + top = HWND_TOPMOST; + } else { + top = HWND_NOTOPMOST; + } + style = GetWindowLong(hwnd, GWL_STYLE); + style &= ~STYLE_MASK; + style |= GetWindowStyle(window); + + WIN_GetDisplayBounds(_this, display, &bounds); + + if (fullscreen) { + x = bounds.x; + y = bounds.y; + w = bounds.w; + h = bounds.h; + } else { + rect.left = 0; + rect.top = 0; + rect.right = window->windowed.w; + rect.bottom = window->windowed.h; +#ifdef _WIN32_WCE + menu = FALSE; +#else + menu = (style & WS_CHILDWINDOW) ? FALSE : (GetMenu(hwnd) != NULL); +#endif + AdjustWindowRectEx(&rect, style, menu, 0); + w = (rect.right - rect.left); + h = (rect.bottom - rect.top); + x = window->windowed.x + rect.left; + y = window->windowed.y + rect.top; + } + SetWindowLong(hwnd, GWL_STYLE, style); + SetWindowPos(hwnd, top, x, y, w, h, SWP_NOCOPYBITS); +} + +int +WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) +{ +#ifdef _WIN32_WCE + SDL_Unsupported(); + return -1; +#else + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; + HDC hdc; + BOOL succeeded = FALSE; + + hdc = CreateDC(data->DeviceName, NULL, NULL, NULL); + if (hdc) { + succeeded = SetDeviceGammaRamp(hdc, (LPVOID)ramp); + if (!succeeded) { + WIN_SetError("SetDeviceGammaRamp()"); + } + DeleteDC(hdc); + } + return succeeded ? 0 : -1; +#endif +} + +int +WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp) +{ +#ifdef _WIN32_WCE + SDL_Unsupported(); + return -1; +#else + SDL_VideoDisplay *display = SDL_GetDisplayForWindow(window); + SDL_DisplayData *data = (SDL_DisplayData *) display->driverdata; + HDC hdc; + BOOL succeeded = FALSE; + + hdc = CreateDC(data->DeviceName, NULL, NULL, NULL); + if (hdc) { + succeeded = GetDeviceGammaRamp(hdc, (LPVOID)ramp); + if (!succeeded) { + WIN_SetError("GetDeviceGammaRamp()"); + } + DeleteDC(hdc); + } + return succeeded ? 0 : -1; +#endif +} + void WIN_SetWindowGrab(_THIS, SDL_Window * window) { HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; - if ((window->flags & (SDL_WINDOW_INPUT_GRABBED | SDL_WINDOW_FULLSCREEN)) - && (window->flags & SDL_WINDOW_INPUT_FOCUS)) { + if ((window->flags & SDL_WINDOW_INPUT_GRABBED) && + (window->flags & SDL_WINDOW_INPUT_FOCUS)) { RECT rect; GetClientRect(hwnd, &rect); ClientToScreen(hwnd, (LPPOINT) & rect); @@ -541,11 +634,22 @@ WIN_DestroyWindow(_THIS, SDL_Window * window) if (data) { #ifdef _WIN32_WCE - WINCE_ShowWindow(_this, window, 0); + WINCE_ShowWindow(_this, window, 0); #endif ReleaseDC(data->hwnd, data->hdc); if (data->created) { DestroyWindow(data->hwnd); + } else { + /* Restore any original event handler... */ + if (data->wndproc != NULL) { +#ifdef GWLP_WNDPROC + SetWindowLongPtr(data->hwnd, GWLP_WNDPROC, + (LONG_PTR) data->wndproc); +#else + SetWindowLong(data->hwnd, GWL_WNDPROC, + (LONG_PTR) data->wndproc); +#endif + } } SDL_free(data); } @@ -557,7 +661,7 @@ WIN_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd; if (info->version.major <= SDL_MAJOR_VERSION) { info->subsystem = SDL_SYSWM_WINDOWS; - info->win.window = hwnd; + info->info.win.window = hwnd; return SDL_TRUE; } else { SDL_SetError("Application not compiled with SDL %d.%d\n", @@ -644,4 +748,6 @@ SDL_HelperWindowDestroy(void) } } +#endif /* SDL_VIDEO_DRIVER_WINDOWS */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/SDL_win32window.h b/project/jni/sdl-1.3/src/video/windows/SDL_windowswindow.h similarity index 53% rename from project/jni/sdl-1.3/src/video/win32/SDL_win32window.h rename to project/jni/sdl-1.3/src/video/windows/SDL_windowswindow.h index 43eeb01bc..fa3eedfdd 100644 --- a/project/jni/sdl-1.3/src/video/win32/SDL_win32window.h +++ b/project/jni/sdl-1.3/src/video/windows/SDL_windowswindow.h @@ -1,28 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#ifndef _SDL_win32window_h -#define _SDL_win32window_h +#ifndef _SDL_windowswindow_h +#define _SDL_windowswindow_h #ifdef _WIN32_WCE #define SHFS_SHOWTASKBAR 0x0001 @@ -38,6 +37,8 @@ typedef struct SDL_Window *window; HWND hwnd; HDC hdc; + HDC mdc; + HBITMAP hbm; WNDPROC wndproc; SDL_bool created; int mouse_pressed; @@ -56,11 +57,14 @@ extern void WIN_RaiseWindow(_THIS, SDL_Window * window); extern void WIN_MaximizeWindow(_THIS, SDL_Window * window); extern void WIN_MinimizeWindow(_THIS, SDL_Window * window); extern void WIN_RestoreWindow(_THIS, SDL_Window * window); +extern void WIN_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); +extern int WIN_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); +extern int WIN_GetWindowGammaRamp(_THIS, SDL_Window * window, Uint16 * ramp); extern void WIN_SetWindowGrab(_THIS, SDL_Window * window); extern void WIN_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool WIN_GetWindowWMInfo(_THIS, SDL_Window * window, struct SDL_SysWMinfo *info); -#endif /* _SDL_win32window_h */ +#endif /* _SDL_windowswindow_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/win32/wmmsg.h b/project/jni/sdl-1.3/src/video/windows/wmmsg.h similarity index 100% rename from project/jni/sdl-1.3/src/video/win32/wmmsg.h rename to project/jni/sdl-1.3/src/video/windows/wmmsg.h diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11clipboard.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11clipboard.c index 6c9740bd7..71f7c9390 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11clipboard.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11clipboard.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_X11 + #include /* For INT_MAX */ #include "SDL_events.h" @@ -38,15 +39,11 @@ static Window GetWindow(_THIS) { - SDL_VideoDisplay *display; SDL_Window *window; - display = _this->displays; - if (display) { - window = display->windows; - if (window) { - return ((SDL_WindowData *) window->driverdata)->xwindow; - } + window = _this->windows; + if (window) { + return ((SDL_WindowData *) window->driverdata)->xwindow; } return None; } @@ -132,25 +129,22 @@ X11_GetClipboardText(_THIS) if (!text) { text = SDL_strdup(""); } + return text; } SDL_bool X11_HasClipboardText(_THIS) { - /* Not an easy way to tell with X11, as far as I know... */ - char *text; - SDL_bool retval; - - text = X11_GetClipboardText(_this); - if (*text) { - retval = SDL_TRUE; - } else { - retval = SDL_FALSE; - } - SDL_free(text); - - return retval; + SDL_bool result = SDL_FALSE; + char *text = X11_GetClipboardText(_this); + if (text) { + result = (SDL_strlen(text)>0) ? SDL_TRUE : SDL_FALSE; + SDL_free(text); + } + return result; } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11clipboard.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11clipboard.h index 6d9bbb085..9004667ec 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11clipboard.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11clipboard.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11dyn.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11dyn.c index 05fc31cc8..d25b1d2c0 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11dyn.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11dyn.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_X11 + #define DEBUG_DYNAMIC_X11 0 #include "SDL_x11dyn.h" @@ -46,26 +47,34 @@ typedef struct #ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT NULL #endif -#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER NULL +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR NULL #endif -#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR -#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR NULL +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA NULL #endif #ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT NULL #endif +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR NULL +#endif #ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS #define SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS NULL #endif +#ifndef SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE +#define SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE NULL +#endif static x11dynlib x11libs[] = { {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC}, {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XEXT}, - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRENDER}, - {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR}, + {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XCURSOR}, + {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINERAMA}, {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XINPUT}, + {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XRANDR}, {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XSS}, + {NULL, SDL_VIDEO_DRIVER_X11_DYNAMIC_XVIDMODE} }; static void @@ -110,7 +119,7 @@ char *(*pXGetICValues) (XIC, ...) = NULL; #endif /* These SDL_X11_HAVE_* flags are here whether you have dynamic X11 or not. */ -#define SDL_X11_MODULE(modname) int SDL_X11_HAVE_##modname = 1; +#define SDL_X11_MODULE(modname) int SDL_X11_HAVE_##modname = 0; #define SDL_X11_SYM(rc,fn,params,args,ret) #include "SDL_x11sym.h" #undef SDL_X11_MODULE @@ -129,7 +138,7 @@ SDL_X11_UnloadSymbols(void) int i; /* set all the function pointers to NULL. */ -#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; +#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 0; #define SDL_X11_SYM(rc,fn,params,args,ret) p##fn = NULL; #include "SDL_x11sym.h" #undef SDL_X11_MODULE @@ -167,6 +176,13 @@ SDL_X11_LoadSymbols(void) x11libs[i].lib = SDL_LoadObject(x11libs[i].libname); } } + +#define SDL_X11_MODULE(modname) SDL_X11_HAVE_##modname = 1; /* default yes */ +#define SDL_X11_SYM(a,fn,x,y,z) +#include "SDL_x11sym.h" +#undef SDL_X11_MODULE +#undef SDL_X11_SYM + #define SDL_X11_MODULE(modname) thismod = &SDL_X11_HAVE_##modname; #define SDL_X11_SYM(a,fn,x,y,z) X11_GetSym(#fn,thismod,(void**)&p##fn); #include "SDL_x11sym.h" @@ -198,4 +214,6 @@ SDL_X11_LoadSymbols(void) return rc; } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11dyn.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11dyn.h index 408deec55..8fb6202fd 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11dyn.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11dyn.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -35,8 +34,8 @@ #endif #include -#include "../Xext/extensions/Xext.h" -#include "../Xext/extensions/extutil.h" +#include +#include #ifndef NO_SHARED_MEMORY #include @@ -44,24 +43,26 @@ #include #endif -#if SDL_VIDEO_DRIVER_X11_XRANDR -#include +#if SDL_VIDEO_DRIVER_X11_XCURSOR +#include +#endif +#if SDL_VIDEO_DRIVER_X11_XINERAMA +#include #endif - #if SDL_VIDEO_DRIVER_X11_XINPUT #include #endif - -#if SDL_VIDEO_DRIVER_X11_XRENDER -#include +#if SDL_VIDEO_DRIVER_X11_XRANDR +#include #endif - -#if SDL_VIDEO_DRIVER_X11_XDAMAGE -#include +#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER +#include #endif - -#if SDL_VIDEO_DRIVER_X11_XFIXES -#include +#if SDL_VIDEO_DRIVER_X11_XSHAPE +#include +#endif +#if SDL_VIDEO_DRIVER_X11_XVIDMODE +#include #endif /* diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11events.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11events.c index 48f7e1093..84daaa8bf 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11events.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11events.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_X11 + #include #include #include @@ -63,6 +64,37 @@ static SDL_bool X11_KeyRepeat(Display *display, XEvent *event) return SDL_FALSE; } +static SDL_bool X11_IsWheelEvent(Display * display,XEvent * event,int * ticks) +{ + XEvent peekevent; + if (XPending(display)) { + /* according to the xlib docs, no specific mouse wheel events exist. + however, mouse wheel events trigger a button press and a button release + immediately. thus, checking if the same button was released at the same + time as it was pressed, should be an adequate hack to derive a mouse + wheel event. */ + XPeekEvent(display,&peekevent); + if ((peekevent.type == ButtonRelease) && + (peekevent.xbutton.button == event->xbutton.button) && + (peekevent.xbutton.time == event->xbutton.time)) { + + /* by default, X11 only knows 5 buttons. on most 3 button + wheel mouse, + Button4 maps to wheel up, Button5 maps to wheel down. */ + if (event->xbutton.button == Button4) { + *ticks = 1; + } + else { + *ticks = -1; + } + + /* remove the following release event, as this is now a wheel event */ + XNextEvent(display,&peekevent); + return SDL_TRUE; + } + } + return SDL_FALSE; +} + static void X11_DispatchEvent(_THIS) { @@ -91,7 +123,7 @@ X11_DispatchEvent(_THIS) SDL_VERSION(&wmmsg.version); wmmsg.subsystem = SDL_SYSWM_X11; - wmmsg.x11.event = xevent; + wmmsg.msg.x11.event = xevent; SDL_SendSysWMEvent(&wmmsg); } @@ -202,7 +234,6 @@ X11_DispatchEvent(_THIS) case KeyPress:{ KeyCode keycode = xevent.xkey.keycode; KeySym keysym = NoSymbol; - SDL_scancode scancode; char text[SDL_TEXTINPUTEVENT_TEXT_SIZE]; Status status = 0; @@ -211,7 +242,7 @@ X11_DispatchEvent(_THIS) #endif SDL_SendKeyboardKey(SDL_PRESSED, videodata->key_layout[keycode]); #if 1 - if (videodata->key_layout[keycode] == SDLK_UNKNOWN) { + if (videodata->key_layout[keycode] == SDL_SCANCODE_UNKNOWN) { int min_keycode, max_keycode; XDisplayKeycodes(display, &min_keycode, &max_keycode); keysym = XKeycodeToKeysym(display, keycode, 0); @@ -314,7 +345,13 @@ X11_DispatchEvent(_THIS) break; case ButtonPress:{ - SDL_SendMouseButton(data->window, SDL_PRESSED, xevent.xbutton.button); + int ticks = 0; + if (X11_IsWheelEvent(display,&xevent,&ticks) == SDL_TRUE) { + SDL_SendMouseWheel(data->window, 0, ticks); + } + else { + SDL_SendMouseButton(data->window, SDL_PRESSED, xevent.xbutton.button); + } } break; @@ -484,6 +521,11 @@ X11_Pending(Display * display) return (0); } + +/* !!! FIXME: this should be exposed in a header, or something. */ +int SDL_GetNumTouch(void); + + void X11_PumpEvents(_THIS) { @@ -507,10 +549,10 @@ X11_PumpEvents(_THIS) #ifdef SDL_INPUT_LINUXEV /* Process Touch events - TODO When X gets touch support, use that instead*/ int i = 0,rd; - char name[256]; struct input_event ev[64]; int size = sizeof (struct input_event); +/* !!! FIXME: clean the tabstops out of here. */ for(i = 0;i < SDL_GetNumTouch();++i) { SDL_Touch* touch = SDL_GetTouchIndex(i); if(!touch) printf("Touch %i/%i DNE\n",i,SDL_GetNumTouch()); @@ -523,12 +565,10 @@ X11_PumpEvents(_THIS) if(data->eventStream <= 0) printf("Error: Couldn't open stream\n"); rd = read(data->eventStream, ev, size * 64); - //printf("Got %i/%i bytes\n",rd,size); if(rd >= size) { for (i = 0; i < rd / sizeof(struct input_event); i++) { switch (ev[i].type) { case EV_ABS: - //printf("Got position x: %i!\n",data->x); switch (ev[i].code) { case ABS_X: data->x = ev[i].value; @@ -547,29 +587,37 @@ X11_PumpEvents(_THIS) } break; case EV_MSC: - if(ev[i].code == MSC_SERIAL) - data->finger = ev[i].value; - break; + if(ev[i].code == MSC_SERIAL) + data->finger = ev[i].value; + break; + case EV_KEY: + if(ev[i].code == BTN_TOUCH) + if(ev[i].value == 0) + data->up = SDL_TRUE; + break; case EV_SYN: - //printf("Id: %i\n",touch->id); - if(data->up) { + if(!data->down) { + data->down = SDL_TRUE; SDL_SendFingerDown(touch->id,data->finger, - SDL_FALSE,data->x,data->y, - data->pressure); + data->down, data->x, data->y, + data->pressure); } - else if(data->x >= 0 || data->y >= 0) + else if(!data->up) SDL_SendTouchMotion(touch->id,data->finger, - SDL_FALSE,data->x,data->y, + SDL_FALSE, data->x,data->y, data->pressure); - - //printf("Synched: %i tx: %i, ty: %i\n", - // data->finger,data->x,data->y); - data->x = -1; - data->y = -1; - data->pressure = -1; - data->finger = 0; - data->up = SDL_FALSE; - + else + { + data->down = SDL_FALSE; + SDL_SendFingerDown(touch->id,data->finger, + data->down, data->x,data->y, + data->pressure); + data->x = -1; + data->y = -1; + data->pressure = -1; + data->finger = 0; + data->up = SDL_FALSE; + } break; } } @@ -609,7 +657,7 @@ gnome_screensaver_enable() void X11_SuspendScreenSaver(_THIS) { -#if SDL_VIDEO_DRIVER_X11_SCRNSAVER +#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; int dummy; int major_version, minor_version; @@ -637,4 +685,6 @@ X11_SuspendScreenSaver(_THIS) #endif } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11events.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11events.h index bd9a8ec89..2c4d1e165 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11events.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11events.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11framebuffer.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11framebuffer.c new file mode 100644 index 000000000..b54a48cfc --- /dev/null +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11framebuffer.c @@ -0,0 +1,220 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_X11 + +#include "SDL_x11video.h" +#include "SDL_x11framebuffer.h" + + +#ifndef NO_SHARED_MEMORY + +/* Shared memory error handler routine */ +static int shm_error; +static int (*X_handler)(Display *, XErrorEvent *) = NULL; +static int shm_errhandler(Display *d, XErrorEvent *e) +{ + if ( e->error_code == BadAccess ) { + shm_error = True; + return(0); + } else + return(X_handler(d,e)); +} + +static SDL_bool have_mitshm(void) +{ + /* Only use shared memory on local X servers */ + if ( (SDL_strncmp(XDisplayName(NULL), ":", 1) == 0) || + (SDL_strncmp(XDisplayName(NULL), "unix:", 5) == 0) ) { + return SDL_X11_HAVE_SHM; + } + return SDL_FALSE; +} + +#endif /* !NO_SHARED_MEMORY */ + +int +X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, Uint32 * format, + void ** pixels, int *pitch) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + XGCValues gcv; + XVisualInfo vinfo; + + /* Free the old framebuffer surface */ + X11_DestroyWindowFramebuffer(_this, window); + + /* Create the graphics context for drawing */ + gcv.graphics_exposures = False; + data->gc = XCreateGC(display, data->xwindow, GCGraphicsExposures, &gcv); + if (!data->gc) { + SDL_SetError("Couldn't create graphics context"); + return -1; + } + + /* Find out the pixel format and depth */ + if (X11_GetVisualInfoFromVisual(display, data->visual, &vinfo) < 0) { + SDL_SetError("Couldn't get window visual information"); + return -1; + } + + *format = X11_GetPixelFormatFromVisualInfo(display, &vinfo); + if (*format == SDL_PIXELFORMAT_UNKNOWN) { + SDL_SetError("Unknown window pixel format"); + return -1; + } + + /* Calculate pitch */ + *pitch = (((window->w * SDL_BYTESPERPIXEL(*format)) + 3) & ~3); + + /* Create the actual image */ +#ifndef NO_SHARED_MEMORY + if (have_mitshm()) { + XShmSegmentInfo *shminfo = &data->shminfo; + + shminfo->shmid = shmget(IPC_PRIVATE, window->h*(*pitch), IPC_CREAT | 0777); + if ( shminfo->shmid >= 0 ) { + shminfo->shmaddr = (char *)shmat(shminfo->shmid, 0, 0); + shminfo->readOnly = False; + if ( shminfo->shmaddr != (char *)-1 ) { + shm_error = False; + X_handler = XSetErrorHandler(shm_errhandler); + XShmAttach(display, shminfo); + XSync(display, True); + XSetErrorHandler(X_handler); + if ( shm_error ) + shmdt(shminfo->shmaddr); + } else { + shm_error = True; + } + shmctl(shminfo->shmid, IPC_RMID, NULL); + } else { + shm_error = True; + } + if (!shm_error) { + data->ximage = XShmCreateImage(display, data->visual, + vinfo.depth, ZPixmap, + shminfo->shmaddr, shminfo, + window->w, window->h); + if (!data->ximage) { + XShmDetach(display, shminfo); + XSync(display, False); + shmdt(shminfo->shmaddr); + } else { + /* Done! */ + data->use_mitshm = SDL_TRUE; + *pixels = shminfo->shmaddr; + return 0; + } + } + } +#endif /* not NO_SHARED_MEMORY */ + + *pixels = SDL_malloc(window->h*(*pitch)); + if (*pixels == NULL) { + SDL_OutOfMemory(); + return -1; + } + + data->ximage = XCreateImage(display, data->visual, + vinfo.depth, ZPixmap, 0, (char *)(*pixels), + window->w, window->h, 32, 0); + if (!data->ximage) { + SDL_free(*pixels); + SDL_SetError("Couldn't create XImage"); + return -1; + } + return 0; +} + +int +X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, SDL_Rect * rects, + int numrects) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + int i; + SDL_Rect *rect; + +#ifndef NO_SHARED_MEMORY + if (data->use_mitshm) { + for (i = 0; i < numrects; ++i) { + rect = &rects[i]; + + if (rect->w == 0 || rect->h == 0) { /* Clipped? */ + continue; + } + XShmPutImage(display, data->xwindow, data->gc, data->ximage, + rect->x, rect->y, + rect->x, rect->y, rect->w, rect->h, False); + } + } + else +#endif /* !NO_SHARED_MEMORY */ + { + for (i = 0; i < numrects; ++i) { + rect = &rects[i]; + + if (rect->w == 0 || rect->h == 0) { /* Clipped? */ + continue; + } + XPutImage(display, data->xwindow, data->gc, data->ximage, + rect->x, rect->y, + rect->x, rect->y, rect->w, rect->h); + } + } + + XSync(display, False); + + return 0; +} + +void +X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + + if (data->ximage) { + XDestroyImage(data->ximage); + +#ifndef NO_SHARED_MEMORY + if (data->use_mitshm) { + XShmDetach(display, &data->shminfo); + XSync(display, False); + shmdt(data->shminfo.shmaddr); + data->use_mitshm = SDL_FALSE; + } +#endif /* !NO_SHARED_MEMORY */ + + data->ximage = NULL; + } + if (data->gc) { + XFreeGC(display, data->gc); + data->gc = NULL; + } +} + +#endif /* SDL_VIDEO_DRIVER_X11 */ + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11framebuffer.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11framebuffer.h new file mode 100644 index 000000000..c88f75b08 --- /dev/null +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11framebuffer.h @@ -0,0 +1,31 @@ +/* + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. +*/ +#include "SDL_config.h" + + +extern int X11_CreateWindowFramebuffer(_THIS, SDL_Window * window, + Uint32 * format, + void ** pixels, int *pitch); +extern int X11_UpdateWindowFramebuffer(_THIS, SDL_Window * window, + SDL_Rect * rects, int numrects); +extern void X11_DestroyWindowFramebuffer(_THIS, SDL_Window * window); + +/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11gamma.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11gamma.c deleted file mode 100644 index 25be411fe..000000000 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11gamma.c +++ /dev/null @@ -1,232 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" -#include "../SDL_sysvideo.h" -#include "SDL_x11video.h" - - /* The size of *all* SDL gamma ramps */ -#define SDL_GammaRampSize (3 * 256 * sizeof(Uint16)) - -static int numCmaps = 0; - -typedef struct -{ - Display *display; - int scrNum; - Colormap colormap; - Visual visual; - Uint16 *ramp; -} cmapTableEntry; - -cmapTableEntry *cmapTable = NULL; - -/* To reduce the overhead as much as possible lets do as little as - possible. When we do have to create a colormap keep track of it and - reuse it. We're going to do this for both DirectColor and - PseudoColor colormaps. */ - -Colormap -X11_LookupColormap(Display * display, int scrNum, VisualID vid) -{ - int i; - - for (i = 0; i < numCmaps; i++) { - if (cmapTable[i].display == display && - cmapTable[i].scrNum == scrNum && - cmapTable[i].visual.visualid == vid) { - return cmapTable[i].colormap; - } - } - - return 0; -} - - -void -X11_TrackColormap(Display * display, int scrNum, Colormap colormap, - Visual * visual, XColor * ramp) -{ - int i; - Uint16 *newramp; - int ncolors; - - /* search the table to find out if we already have this one. We - only want one entry for each display, screen number, visualid, - and colormap combination */ - for (i = 0; i < numCmaps; i++) { - if (cmapTable[i].display == display && - cmapTable[i].scrNum == scrNum && - cmapTable[i].visual.visualid == visual->visualid && - cmapTable[i].colormap == colormap) { - return; - } - } - - /* increase the table by one entry. If the table is NULL create the - first entrty */ - cmapTable = - SDL_realloc(cmapTable, (numCmaps + 1) * sizeof(cmapTableEntry)); - if (NULL == cmapTable) { - SDL_SetError("Out of memory in X11_TrackColormap()"); - return; - } - - cmapTable[numCmaps].display = display; - cmapTable[numCmaps].scrNum = scrNum; - cmapTable[numCmaps].colormap = colormap; - SDL_memcpy(&cmapTable[numCmaps].visual, visual, sizeof(Visual)); - cmapTable[numCmaps].ramp = NULL; - - if (ramp != NULL) { - newramp = SDL_malloc(SDL_GammaRampSize); - if (NULL == newramp) { - SDL_SetError("Out of memory in X11_TrackColormap()"); - return; - } - SDL_memset(newramp, 0, SDL_GammaRampSize); - cmapTable[numCmaps].ramp = newramp; - - ncolors = cmapTable[numCmaps].visual.map_entries; - - for (i = 0; i < ncolors; i++) { - newramp[(0 * 256) + i] = ramp[i].red; - newramp[(1 * 256) + i] = ramp[i].green; - newramp[(2 * 256) + i] = ramp[i].blue; - } - } - - numCmaps++; -} - -/* The problem is that you have to have at least one DirectColor - colormap before you can set the gamma ramps or read the gamma - ramps. If the application has created a DirectColor window then the - cmapTable will have at least one colormap in it and everything is - cool. If not, then we just fail */ - -int -X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * sdl_display, Uint16 * ramp) -{ - Visual *visual; - Display *display; - Colormap colormap; - XColor *colorcells; - int ncolors; - int rmask, gmask, bmask; - int rshift, gshift, bshift; - int i; - int j; - - for (j = 0; j < numCmaps; j++) { - if (cmapTable[j].visual.class == DirectColor) { - display = cmapTable[j].display; - colormap = cmapTable[j].colormap; - ncolors = cmapTable[j].visual.map_entries; - visual = &cmapTable[j].visual; - - colorcells = SDL_malloc(ncolors * sizeof(XColor)); - if (NULL == colorcells) { - SDL_SetError("out of memory in X11_SetDisplayGammaRamp"); - return -1; - } - /* remember the new ramp */ - if (cmapTable[j].ramp == NULL) { - Uint16 *newramp = SDL_malloc(SDL_GammaRampSize); - if (NULL == newramp) { - SDL_SetError("Out of memory in X11_TrackColormap()"); - return -1; - } - cmapTable[j].ramp = newramp; - } - SDL_memcpy(cmapTable[j].ramp, ramp, SDL_GammaRampSize); - - rshift = 0; - rmask = visual->red_mask; - while (0 == (rmask & 1)) { - rshift++; - rmask >>= 1; - } - -/* printf("rmask = %4x rshift = %4d\n", rmask, rshift); */ - - gshift = 0; - gmask = visual->green_mask; - while (0 == (gmask & 1)) { - gshift++; - gmask >>= 1; - } - -/* printf("gmask = %4x gshift = %4d\n", gmask, gshift); */ - - bshift = 0; - bmask = visual->blue_mask; - while (0 == (bmask & 1)) { - bshift++; - bmask >>= 1; - } - -/* printf("bmask = %4x bshift = %4d\n", bmask, bshift); */ - - /* build the color table pixel values */ - for (i = 0; i < ncolors; i++) { - Uint32 rbits = (rmask * i) / (ncolors - 1); - Uint32 gbits = (gmask * i) / (ncolors - 1); - Uint32 bbits = (bmask * i) / (ncolors - 1); - - Uint32 pix = - (rbits << rshift) | (gbits << gshift) | (bbits << bshift); - - colorcells[i].pixel = pix; - - colorcells[i].flags = DoRed | DoGreen | DoBlue; - - colorcells[i].red = ramp[(0 * 256) + i]; - colorcells[i].green = ramp[(1 * 256) + i]; - colorcells[i].blue = ramp[(2 * 256) + i]; - } - - XStoreColors(display, colormap, colorcells, ncolors); - XFlush(display); - SDL_free(colorcells); - } - } - - return 0; -} - -int -X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp) -{ - int i; - - /* find the first DirectColor colormap and use it to get the gamma - ramp */ - - for (i = 0; i < numCmaps; i++) { - if (cmapTable[i].visual.class == DirectColor) { - SDL_memcpy(ramp, cmapTable[i].ramp, SDL_GammaRampSize); - return 0; - } - } - - return -1; -} diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11gamma.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11gamma.h deleted file mode 100644 index 6e998b8c4..000000000 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11gamma.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_x11gamma_h -#define _SDL_x11gamma_h - -extern Colormap X11_LookupColormap(Display * display, int scrNum, - VisualID vid); -extern void X11_TrackColormap(Display * display, int scrNum, - Colormap colormap, - Visual * visual, XColor * ramp); - -extern int X11_SetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp); -extern int X11_GetDisplayGammaRamp(_THIS, SDL_VideoDisplay * display, Uint16 * ramp); - -#endif diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11keyboard.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11keyboard.c index d6d5b7f8d..5940d359d 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11keyboard.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11keyboard.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_X11 + #include "SDL_x11video.h" #include "../../events/SDL_keyboard_c.h" @@ -34,7 +35,7 @@ /* *INDENT-OFF* */ static const struct { KeySym keysym; - SDLKey sdlkey; + SDL_Keycode sdlkey; } KeySymToSDLKey[] = { { XK_Return, SDLK_RETURN }, { XK_Escape, SDLK_ESCAPE }, @@ -134,7 +135,7 @@ static const struct { static const struct { - const SDL_scancode const *table; + const SDL_Scancode const *table; int table_size; } scancode_set[] = { { darwin_scancode_table, SDL_arraysize(darwin_scancode_table) }, @@ -143,7 +144,7 @@ static const struct }; /* *INDENT-OFF* */ -static SDLKey +static SDL_Keycode X11_KeyCodeToSDLKey(Display *display, KeyCode keycode) { KeySym keysym; @@ -157,7 +158,7 @@ X11_KeyCodeToSDLKey(Display *display, KeyCode keycode) ucs4 = X11_KeySymToUcs4(keysym); if (ucs4) { - return (SDLKey) ucs4; + return (SDL_Keycode) ucs4; } for (i = 0; i < SDL_arraysize(KeySymToSDLKey); ++i) { @@ -175,7 +176,7 @@ X11_InitKeyboard(_THIS) int i, j; int min_keycode, max_keycode; struct { - SDL_scancode scancode; + SDL_Scancode scancode; KeySym keysym; int value; } fingerprint[] = { @@ -215,14 +216,14 @@ X11_InitKeyboard(_THIS) printf("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", i, min_keycode, max_keycode, scancode_set[i].table_size); #endif SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table, - sizeof(SDL_scancode) * scancode_set[i].table_size); + sizeof(SDL_Scancode) * scancode_set[i].table_size); fingerprint_detected = SDL_TRUE; break; } } if (!fingerprint_detected) { - SDLKey keymap[SDL_NUM_SCANCODES]; + SDL_Keycode keymap[SDL_NUM_SCANCODES]; printf ("Keyboard layout unknown, please send the following to the SDL mailing list (sdl@libsdl.org):\n"); @@ -233,13 +234,13 @@ X11_InitKeyboard(_THIS) KeySym sym; sym = XKeycodeToKeysym(data->display, i, 0); if (sym != NoSymbol) { - SDLKey key; + SDL_Keycode key; printf("code = %d, sym = 0x%X (%s) ", i - min_keycode, (unsigned int) sym, XKeysymToString(sym)); key = X11_KeyCodeToSDLKey(data->display, i); for (j = 0; j < SDL_arraysize(keymap); ++j) { if (keymap[j] == key) { - data->key_layout[i] = (SDL_scancode) j; + data->key_layout[i] = (SDL_Scancode) j; break; } } @@ -264,8 +265,8 @@ X11_UpdateKeymap(_THIS) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; int i; - SDL_scancode scancode; - SDLKey keymap[SDL_NUM_SCANCODES]; + SDL_Scancode scancode; + SDL_Keycode keymap[SDL_NUM_SCANCODES]; SDL_zero(keymap); @@ -287,4 +288,6 @@ X11_QuitKeyboard(_THIS) { } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11keyboard.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11keyboard.h index 347a51ddf..a475d4c9d 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11keyboard.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11keyboard.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11modes.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11modes.c index fb9cba187..b26c4c062 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11modes.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11modes.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_X11 + #include "SDL_x11video.h" /*#define X11MODES_DEBUG*/ @@ -57,7 +58,23 @@ get_visualinfo(Display * display, int screen, XVisualInfo * vinfo) return -1; } -static Uint32 +int +X11_GetVisualInfoFromVisual(Display * display, Visual * visual, XVisualInfo * vinfo) +{ + XVisualInfo *vi; + int nvis; + + vinfo->visualid = XVisualIDFromVisual(visual); + vi = XGetVisualInfo(display, VisualIDMask, vinfo, &nvis); + if (vi) { + *vinfo = *vi; + XFree(vi); + return 0; + } + return -1; +} + +Uint32 X11_GetPixelFormatFromVisualInfo(Display * display, XVisualInfo * vinfo) { if (vinfo->class == DirectColor || vinfo->class == TrueColor) { @@ -134,6 +151,10 @@ X11_InitModes(_THIS) } mode.format = X11_GetPixelFormatFromVisualInfo(data->display, &vinfo); + if (SDL_ISPIXELFORMAT_INDEXED(mode.format)) { + /* We don't support palettized modes now */ + continue; + } mode.w = DisplayWidth(data->display, screen); mode.h = DisplayHeight(data->display, screen); mode.refresh_rate = 0; @@ -179,6 +200,8 @@ int vm_event, vm_error = -1; static SDL_bool CheckXinerama(Display * display, int *major, int *minor) { + int event_base = 0; + int error_base = 0; const char *env; /* Default the extension not available */ @@ -190,9 +213,14 @@ CheckXinerama(Display * display, int *major, int *minor) return SDL_FALSE; } + if (!SDL_X11_HAVE_XINERAMA) { + return SDL_FALSE; + } + /* Query the extension version */ - if (!SDL_NAME(XineramaQueryExtension) (display, major, minor) || - !SDL_NAME(XineramaIsActive) (display)) { + if (!XineramaQueryExtension(display, &event_base, &error_base) || + !XineramaQueryVersion(display, major, minor) || + !XineramaIsActive(display)) { return SDL_FALSE; } return SDL_TRUE; @@ -226,7 +254,7 @@ CheckXRandR(Display * display, int *major, int *minor) } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ -#if SDL_VIDEO_DRIVER_X11_VIDMODE +#if SDL_VIDEO_DRIVER_X11_XVIDMODE static SDL_bool CheckVidMode(Display * display, int *major, int *minor) { @@ -236,30 +264,34 @@ CheckVidMode(Display * display, int *major, int *minor) *major = *minor = 0; /* Allow environment override */ - env = getenv("SDL_VIDEO_X11_VIDMODE"); + env = getenv("SDL_VIDEO_X11_XVIDMODE"); if (env && !SDL_atoi(env)) { return SDL_FALSE; } + if (!SDL_X11_HAVE_XVIDMODE) { + return SDL_FALSE; + } + /* Query the extension version */ vm_error = -1; - if (!SDL_NAME(XF86VidModeQueryExtension) (display, &vm_event, &vm_error) - || !SDL_NAME(XF86VidModeQueryVersion) (display, major, minor)) { + if (!XF86VidModeQueryExtension(display, &vm_event, &vm_error) + || !XF86VidModeQueryVersion(display, major, minor)) { return SDL_FALSE; } return SDL_TRUE; } static -Bool SDL_NAME(XF86VidModeGetModeInfo) (Display * dpy, int scr, - SDL_NAME(XF86VidModeModeInfo) * info) +Bool XF86VidModeGetModeInfo(Display * dpy, int scr, + XF86VidModeModeInfo* info) { Bool retval; int dotclock; - SDL_NAME(XF86VidModeModeLine) l; + XF86VidModeModeLine l; SDL_zerop(info); SDL_zero(l); - retval = SDL_NAME(XF86VidModeGetModeLine) (dpy, scr, &dotclock, &l); + retval = XF86VidModeGetModeLine(dpy, scr, &dotclock, &l); info->dotclock = dotclock; info->hdisplay = l.hdisplay; info->hsyncstart = l.hsyncstart; @@ -277,7 +309,7 @@ Bool SDL_NAME(XF86VidModeGetModeInfo) (Display * dpy, int scr, } static int -calculate_rate(SDL_NAME(XF86VidModeModeInfo) * info) +calculate_rate(XF86VidModeModeInfo * info) { return (info->htotal && info->vtotal) ? (1000 * info->dotclock / (info->htotal * @@ -287,33 +319,32 @@ calculate_rate(SDL_NAME(XF86VidModeModeInfo) * info) static void save_mode(Display * display, SDL_DisplayData * data) { - SDL_NAME(XF86VidModeGetModeInfo) (display, data->screen, - &data->saved_mode); - SDL_NAME(XF86VidModeGetViewPort) (display, data->screen, - &data->saved_view.x, - &data->saved_view.y); + XF86VidModeGetModeInfo(display, data->screen, + &data->saved_mode); + XF86VidModeGetViewPort(display, data->screen, + &data->saved_view.x, + &data->saved_view.y); } /* static void restore_mode(Display * display, SDL_DisplayData * data) { - SDL_NAME(XF86VidModeModeInfo) mode; + XF86VidModeModeInfo mode; - if (SDL_NAME(XF86VidModeGetModeInfo) (display, data->screen, &mode)) { + if (XF86VidModeGetModeInfo(display, data->screen, &mode)) { if (SDL_memcmp(&mode, &data->saved_mode, sizeof(mode)) != 0) { - SDL_NAME(XF86VidModeSwitchToMode) (display, data->screen, - &data->saved_mode); + XF86VidModeSwitchToMode(display, data->screen, &data->saved_mode); } } if ((data->saved_view.x != 0) || (data->saved_view.y != 0)) { - SDL_NAME(XF86VidModeSetViewPort) (display, data->screen, - data->saved_view.x, - data->saved_view.y); + XF86VidModeSetViewPort(display, data->screen, + data->saved_view.x, + data->saved_view.y); } } */ -#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ +#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) @@ -323,7 +354,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) #if SDL_VIDEO_DRIVER_X11_XINERAMA int xinerama_major, xinerama_minor; int screens; - SDL_NAME(XineramaScreenInfo) * xinerama; + XineramaScreenInfo * xinerama; #endif #if SDL_VIDEO_DRIVER_X11_XRANDR int xrandr_major, xrandr_minor; @@ -331,10 +362,10 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) XRRScreenSize *sizes; short *rates; #endif -#if SDL_VIDEO_DRIVER_X11_VIDMODE +#if SDL_VIDEO_DRIVER_X11_XVIDMODE int vm_major, vm_minor; int nmodes; - SDL_NAME(XF86VidModeModeInfo) ** modes; + XF86VidModeModeInfo ** modes; #endif int screen_w; int screen_h; @@ -361,7 +392,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) #ifdef X11MODES_DEBUG printf("X11 detected Xinerama:\n"); #endif - xinerama = SDL_NAME(XineramaQueryScreens) (display, &screens); + xinerama = XineramaQueryScreens(display, &screens); if (xinerama) { int i; for (i = 0; i < screens; i++) { @@ -444,15 +475,14 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ -#if SDL_VIDEO_DRIVER_X11_VIDMODE +#if SDL_VIDEO_DRIVER_X11_XVIDMODE /* XVidMode */ if (!data->use_xrandr && #if SDL_VIDEO_DRIVER_X11_XINERAMA (!data->use_xinerama || data->xinerama_info.screen_number == 0) && #endif CheckVidMode(display, &vm_major, &vm_minor) && - SDL_NAME(XF86VidModeGetAllModeLines) (display, data->screen, &nmodes, - &modes)) { + XF86VidModeGetAllModeLines(display, data->screen, &nmodes, &modes)) { int i; #ifdef X11MODES_DEBUG @@ -474,7 +504,7 @@ X11_GetDisplayModes(_THIS, SDL_VideoDisplay * sdl_display) data->use_vidmode = vm_major * 100 + vm_minor; save_mode(display, data); } -#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ +#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ if (!data->use_xrandr && !data->use_vidmode) { mode.w = screen_w; @@ -527,18 +557,18 @@ get_real_resolution(Display * display, SDL_DisplayData * data, int *w, int *h, } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ -#if SDL_VIDEO_DRIVER_X11_VIDMODE +#if SDL_VIDEO_DRIVER_X11_XVIDMODE if (data->use_vidmode) { - SDL_NAME(XF86VidModeModeInfo) mode; + XF86VidModeModeInfo mode; - if (SDL_NAME(XF86VidModeGetModeInfo) (display, data->screen, &mode)) { + if (XF86VidModeGetModeInfo(display, data->screen, &mode)) { *w = mode.hdisplay; *h = mode.vdisplay; *rate = calculate_rate(&mode); return; } } -#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ +#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ #if SDL_VIDEO_DRIVER_X11_XINERAMA if (data->use_xinerama) { @@ -624,14 +654,13 @@ set_best_resolution(Display * display, SDL_DisplayData * data, int w, int h, } #endif /* SDL_VIDEO_DRIVER_X11_XRANDR */ -#if SDL_VIDEO_DRIVER_X11_VIDMODE +#if SDL_VIDEO_DRIVER_X11_XVIDMODE if (data->use_vidmode) { - SDL_NAME(XF86VidModeModeInfo) ** modes; + XF86VidModeModeInfo ** modes; int i, nmodes; int best; - if (SDL_NAME(XF86VidModeGetAllModeLines) - (display, data->screen, &nmodes, &modes)) { + if (XF86VidModeGetAllModeLines(display, data->screen, &nmodes, &modes)) { best = -1; for (i = 0; i < nmodes; ++i) { if (modes[i]->hdisplay < w || modes[i]->vdisplay < h) { @@ -666,14 +695,13 @@ set_best_resolution(Display * display, SDL_DisplayData * data, int w, int h, modes[best]->hdisplay, modes[best]->vdisplay, calculate_rate(modes[best])); #endif - SDL_NAME(XF86VidModeSwitchToMode) (display, data->screen, - modes[best]); + XF86VidModeSwitchToMode(display, data->screen, modes[best]); } XFree(modes); } return; } -#endif /* SDL_VIDEO_DRIVER_X11_VIDMODE */ +#endif /* SDL_VIDEO_DRIVER_X11_XVIDMODE */ } int @@ -691,4 +719,6 @@ X11_QuitModes(_THIS) { } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11modes.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11modes.h index 0e31c70c4..d14da2317 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11modes.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11modes.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -36,7 +35,7 @@ typedef struct int use_vidmode; #if SDL_VIDEO_DRIVER_X11_XINERAMA - SDL_NAME(XineramaScreenInfo) xinerama_info; + XineramaScreenInfo xinerama_info; #endif #if SDL_VIDEO_DRIVER_X11_XRANDR XRRScreenConfiguration *screen_config; @@ -44,8 +43,8 @@ typedef struct Rotation saved_rotation; short saved_rate; #endif -#if SDL_VIDEO_DRIVER_X11_VIDMODE - SDL_NAME(XF86VidModeModeInfo) saved_mode; +#if SDL_VIDEO_DRIVER_X11_XVIDMODE + XF86VidModeModeInfo saved_mode; struct { int x, y; @@ -59,6 +58,12 @@ extern void X11_GetDisplayModes(_THIS, SDL_VideoDisplay * display); extern int X11_SetDisplayMode(_THIS, SDL_VideoDisplay * display, SDL_DisplayMode * mode); extern void X11_QuitModes(_THIS); +/* Some utility functions for working with visuals */ +extern int X11_GetVisualInfoFromVisual(Display * display, Visual * visual, + XVisualInfo * vinfo); +extern Uint32 X11_GetPixelFormatFromVisualInfo(Display * display, + XVisualInfo * vinfo); + #endif /* _SDL_x11modes_h */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11mouse.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11mouse.c index dbf5b6189..396bb9ff4 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11mouse.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11mouse.c @@ -1,37 +1,301 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_X11 + +#include "SDL_assert.h" #include "SDL_x11video.h" #include "SDL_x11mouse.h" #include "../../events/SDL_mouse_c.h" + +/* FIXME: Find a better place to put this... */ +static Cursor x11_empty_cursor = None; + +static Display * +GetDisplay(void) +{ + return ((SDL_VideoData *)SDL_GetVideoDevice()->driverdata)->display; +} + +static Cursor +X11_CreateEmptyCursor() +{ + if (x11_empty_cursor == None) { + Display *display = GetDisplay(); + char data[1]; + XColor color; + Pixmap pixmap; + + SDL_zero(data); + color.red = color.green = color.blue = 0; + pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + data, 1, 1); + if (pixmap) { + x11_empty_cursor = XCreatePixmapCursor(display, pixmap, pixmap, + &color, &color, 0, 0); + XFreePixmap(display, pixmap); + } + } + return x11_empty_cursor; +} + +static void +X11_DestroyEmptyCursor(void) +{ + if (x11_empty_cursor != None) { + XFreeCursor(GetDisplay(), x11_empty_cursor); + x11_empty_cursor = None; + } +} + +static SDL_Cursor * +X11_CreateDefaultCursor() +{ + SDL_Cursor *cursor; + + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + /* None is used to indicate the default cursor */ + cursor->driverdata = (void*)None; + } else { + SDL_OutOfMemory(); + } + + return cursor; +} + +#if SDL_VIDEO_DRIVER_X11_XCURSOR +static Cursor +X11_CreateXCursorCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + Display *display = GetDisplay(); + Cursor cursor = None; + XcursorImage *image; + + image = XcursorImageCreate(surface->w, surface->h); + if (!image) { + SDL_OutOfMemory(); + return None; + } + image->xhot = hot_x; + image->yhot = hot_y; + image->delay = 0; + + SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); + SDL_assert(surface->pitch == surface->w * 4); + SDL_memcpy(image->pixels, surface->pixels, surface->h * surface->pitch); + + cursor = XcursorImageLoadCursor(display, image); + + XcursorImageDestroy(image); + + return cursor; +} +#endif /* SDL_VIDEO_DRIVER_X11_XCURSOR */ + +static Cursor +X11_CreatePixmapCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + Display *display = GetDisplay(); + XColor fg, bg; + Cursor cursor = None; + Uint32 *ptr; + Uint8 *data_bits, *mask_bits; + Pixmap data_pixmap, mask_pixmap; + int x, y; + unsigned int rfg, gfg, bfg, rbg, gbg, bbg, fgBits, bgBits; + unsigned int width_bytes = ((surface->w + 7) & ~7) / 8; + + data_bits = SDL_calloc(1, surface->h * width_bytes); + mask_bits = SDL_calloc(1, surface->h * width_bytes); + if (!data_bits || !mask_bits) { + SDL_OutOfMemory(); + return None; + } + + /* Code below assumes ARGB pixel format */ + SDL_assert(surface->format->format == SDL_PIXELFORMAT_ARGB8888); + + rfg = gfg = bfg = rbg = gbg = bbg = fgBits = bgBits = 0; + for (y = 0; y < surface->h; ++y) { + ptr = (Uint32 *)((Uint8 *)surface->pixels + y * surface->pitch); + for (x = 0; x < surface->w; ++x) { + int alpha = (*ptr >> 24) & 0xff; + int red = (*ptr >> 16) & 0xff; + int green = (*ptr >> 8) & 0xff; + int blue = (*ptr >> 0) & 0xff; + if (alpha > 25) { + mask_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8)); + + if ((red + green + blue) > 0x40) { + fgBits++; + rfg += red; + gfg += green; + bfg += blue; + data_bits[y * width_bytes + x / 8] |= (0x01 << (x % 8)); + } else { + bgBits++; + rbg += red; + gbg += green; + bbg += blue; + } + } + ++ptr; + } + } + + if (fgBits) { + fg.red = rfg * 257 / fgBits; + fg.green = gfg * 257 / fgBits; + fg.blue = bfg * 257 / fgBits; + } + else fg.red = fg.green = fg.blue = 0; + + if (bgBits) { + bg.red = rbg * 257 / bgBits; + bg.green = gbg * 257 / bgBits; + bg.blue = bbg * 257 / bgBits; + } + else bg.red = bg.green = bg.blue = 0; + + data_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + (char*)data_bits, + surface->w, surface->h); + mask_pixmap = XCreateBitmapFromData(display, DefaultRootWindow(display), + (char*)mask_bits, + surface->w, surface->h); + cursor = XCreatePixmapCursor(display, data_pixmap, mask_pixmap, + &fg, &bg, hot_x, hot_y); + XFreePixmap(display, data_pixmap); + XFreePixmap(display, mask_pixmap); + + return cursor; +} + +static SDL_Cursor * +X11_CreateCursor(SDL_Surface * surface, int hot_x, int hot_y) +{ + SDL_Cursor *cursor; + + cursor = SDL_calloc(1, sizeof(*cursor)); + if (cursor) { + Cursor x11_cursor = None; + +#if SDL_VIDEO_DRIVER_X11_XCURSOR + if (SDL_X11_HAVE_XCURSOR) { + x11_cursor = X11_CreateXCursorCursor(surface, hot_x, hot_y); + } +#endif + if (x11_cursor == None) { + x11_cursor = X11_CreatePixmapCursor(surface, hot_x, hot_y); + } + cursor->driverdata = (void*)x11_cursor; + } else { + SDL_OutOfMemory(); + } + + return cursor; +} + +static void +X11_FreeCursor(SDL_Cursor * cursor) +{ + Cursor x11_cursor = (Cursor)cursor->driverdata; + + if (x11_cursor != None) { + XFreeCursor(GetDisplay(), x11_cursor); + } + SDL_free(cursor); +} + +static int +X11_ShowCursor(SDL_Cursor * cursor) +{ + Cursor x11_cursor = 0; + + if (cursor) { + x11_cursor = (Cursor)cursor->driverdata; + } else { + x11_cursor = X11_CreateEmptyCursor(); + } + + /* FIXME: Is there a better way than this? */ + { + SDL_VideoDevice *video = SDL_GetVideoDevice(); + Display *display = GetDisplay(); + SDL_Window *window; + SDL_WindowData *data; + + for (window = video->windows; window; window = window->next) { + data = (SDL_WindowData *)window->driverdata; + if (x11_cursor != None) { + XDefineCursor(display, data->xwindow, x11_cursor); + } else { + XUndefineCursor(display, data->xwindow); + } + } + XFlush(display); + } + return 0; +} + +static void +X11_WarpMouse(SDL_Window * window, int x, int y) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + + XWarpPointer(display, None, data->xwindow, 0, 0, 0, 0, x, y); + XSync(display, False); +} + +static int +X11_SetRelativeMouseMode(SDL_bool enabled) +{ + SDL_Unsupported(); + return -1; +} + void X11_InitMouse(_THIS) { + SDL_Mouse *mouse = SDL_GetMouse(); + + mouse->CreateCursor = X11_CreateCursor; + mouse->ShowCursor = X11_ShowCursor; + mouse->FreeCursor = X11_FreeCursor; + mouse->WarpMouse = X11_WarpMouse; + mouse->SetRelativeMouseMode = X11_SetRelativeMouseMode; + + SDL_SetDefaultCursor(X11_CreateDefaultCursor()); } void X11_QuitMouse(_THIS) { + X11_DestroyEmptyCursor(); } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11mouse.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11mouse.h index 30af4c1e4..c5c473190 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11mouse.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11mouse.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11opengl.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11opengl.c index ed536ea00..0cb186b57 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11opengl.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11opengl.c @@ -1,27 +1,29 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_X11 + #include "SDL_x11video.h" +#include "SDL_assert.h" /* GLX implementation of SDL OpenGL support */ @@ -64,6 +66,20 @@ #define GLX_CONTEXT_FLAGS_ARB 0x2094 #define GLX_CONTEXT_DEBUG_BIT_ARB 0x0001 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002 + +#ifndef GLX_EXT_swap_control +#define GLX_SWAP_INTERVAL_EXT 0x20F1 +#define GLX_MAX_SWAP_INTERVAL_EXT 0x20F2 +#endif + +/* Typedef for the GL 3.0 context creation function */ +typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, + GLXFBConfig config, + GLXContext + share_context, + Bool direct, + const int + *attrib_list); #endif #define OPENGL_REQUIRS_DLOPEN @@ -80,14 +96,6 @@ static void X11_GL_InitExtensions(_THIS); -/* Typedef for the GL 3.0 context creation function */ -typedef GLXContext(*PFNGLXCREATECONTEXTATTRIBSARBPROC) (Display * dpy, - GLXFBConfig config, - GLXContext - share_context, - Bool direct, - const int - *attrib_list); int X11_GL_LoadLibrary(_THIS, const char *path) @@ -138,6 +146,9 @@ X11_GL_LoadLibrary(_THIS, const char *path) _this->gl_data->glXSwapBuffers = (void (*)(Display *, GLXDrawable)) X11_GL_GetProcAddress(_this, "glXSwapBuffers"); + _this->gl_data->glXQueryDrawable = + (void (*)(Display*,GLXDrawable,int,unsigned int*)) + X11_GL_GetProcAddress(_this, "glXQueryDrawable"); if (!_this->gl_data->glXChooseVisual || !_this->gl_data->glXCreateContext || @@ -219,7 +230,7 @@ static void X11_GL_InitExtensions(_THIS) { Display *display = ((SDL_VideoData *) _this->driverdata)->display; - int screen = ((SDL_DisplayData *) SDL_CurrentDisplay->driverdata)->screen; + int screen = DefaultScreen(display); XVisualInfo *vinfo; XSetWindowAttributes xattr; Window w; @@ -254,22 +265,28 @@ X11_GL_InitExtensions(_THIS) extensions = NULL; } - /* Check for SGI_swap_control */ - if (HasExtension("GLX_SGI_swap_control", extensions)) { - _this->gl_data->glXSwapIntervalSGI = - (int (*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); + /* Check for GLX_EXT_swap_control */ + if (HasExtension("GLX_EXT_swap_control", extensions)) { + _this->gl_data->glXSwapIntervalEXT = + (int (*)(Display*,GLXDrawable,int)) + X11_GL_GetProcAddress(_this, "glXSwapIntervalEXT"); } /* Check for GLX_MESA_swap_control */ if (HasExtension("GLX_MESA_swap_control", extensions)) { _this->gl_data->glXSwapIntervalMESA = - (GLint(*)(unsigned)) X11_GL_GetProcAddress(_this, - "glXSwapIntervalMESA"); + (int(*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalMESA"); _this->gl_data->glXGetSwapIntervalMESA = - (GLint(*)(void)) X11_GL_GetProcAddress(_this, + (int(*)(void)) X11_GL_GetProcAddress(_this, "glXGetSwapIntervalMESA"); } + /* Check for GLX_SGI_swap_control */ + if (HasExtension("GLX_SGI_swap_control", extensions)) { + _this->gl_data->glXSwapIntervalSGI = + (int (*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); + } + /* Check for GLX_EXT_visual_rating */ if (HasExtension("GLX_EXT_visual_rating", extensions)) { _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE; @@ -283,15 +300,14 @@ X11_GL_InitExtensions(_THIS) X11_PumpEvents(_this); } -XVisualInfo * -X11_GL_GetVisual(_THIS, Display * display, int screen) +int +X11_GL_GetAttributes(_THIS, Display * display, int screen, int * attribs, int size) { - XVisualInfo *vinfo; - - /* 64 seems nice. */ - int attribs[64]; int i = 0; + /* assert buffer is large enough to hold all SDL attributes. */ + /* assert(size >= 32);*/ + /* Setup our GLX attributes according to the gl_config. */ attribs[i++] = GLX_RGBA; attribs[i++] = GLX_RED_SIZE; @@ -364,22 +380,23 @@ X11_GL_GetVisual(_THIS, Display * display, int screen) GLX_SLOW_VISUAL_EXT; } -#ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ - if (X11_UseDirectColorVisuals()) { - attribs[i++] = GLX_X_VISUAL_TYPE; - attribs[i++] = GLX_DIRECT_COLOR; - } -#endif - attribs[i++] = None; + + return i; +} + +XVisualInfo * +X11_GL_GetVisual(_THIS, Display * display, int screen) +{ + XVisualInfo *vinfo; + + /* 64 seems nice. */ + const int max_attrs = 64; + int attribs[max_attrs]; + const int i = X11_GL_GetAttributes(_this,display,screen,attribs,max_attrs); + SDL_assert(i <= max_attrs); vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); -#ifdef GLX_DIRECT_COLOR - if (!vinfo && X11_UseDirectColorVisuals()) { /* No DirectColor visual? Try again.. */ - attribs[i - 3] = None; - vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); - } -#endif if (!vinfo) { SDL_SetError("Couldn't find matching GLX visual"); } @@ -392,7 +409,7 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; int screen = - ((SDL_DisplayData *) window->display->driverdata)->screen; + ((SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata)->screen; XWindowAttributes xattr; XVisualInfo v, *vinfo; int n; @@ -434,6 +451,8 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) SDL_SetError("GL 3.x is not supported"); context = temp_context; } else { + int glxAttribs[64]; + /* Create a GL 3.x context */ GLXFBConfig *framebuffer_config = NULL; int fbcount = 0; @@ -448,10 +467,12 @@ X11_GL_CreateContext(_THIS, SDL_Window * window) int *)) _this->gl_data-> glXGetProcAddress((GLubyte *) "glXChooseFBConfig"); + X11_GL_GetAttributes(_this,display,screen,glxAttribs,64); + if (!glXChooseFBConfig || !(framebuffer_config = glXChooseFBConfig(display, - DefaultScreen(display), NULL, + DefaultScreen(display), glxAttribs, &fbcount))) { SDL_SetError ("No good framebuffers found. GL 3.x disabled"); @@ -504,12 +525,11 @@ X11_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) } /* - 0 is a valid argument to glxSwapIntervalMESA and setting it to 0 - with the MESA version of the extension will undo the effect of a - previous call with a value that is greater than zero (or at least - that is what the FM says. OTOH, 0 is an invalid argument to - glxSwapIntervalSGI and it returns an error if you call it with 0 as - an argument. + 0 is a valid argument to glxSwapInterval(MESA|EXT) and setting it to 0 + will undo the effect of a previous call with a value that is greater + than zero (or at least that is what the docs say). OTOH, 0 is an invalid + argument to glxSwapIntervalSGI and it returns an error if you call it + with 0 as an argument. */ static int swapinterval = -1; @@ -518,7 +538,19 @@ X11_GL_SetSwapInterval(_THIS, int interval) { int status; - if (_this->gl_data->glXSwapIntervalMESA) { + if (_this->gl_data->glXSwapIntervalEXT) { + Display *display = ((SDL_VideoData *) _this->driverdata)->display; + const SDL_WindowData *windowdata = (SDL_WindowData *) + _this->current_glwin->driverdata; + Window drawable = windowdata->xwindow; + status = _this->gl_data->glXSwapIntervalEXT(display,drawable,interval); + if (status != 0) { + SDL_SetError("glxSwapIntervalEXT failed"); + status = -1; + } else { + swapinterval = interval; + } + } else if (_this->gl_data->glXSwapIntervalMESA) { status = _this->gl_data->glXSwapIntervalMESA(interval); if (status != 0) { SDL_SetError("glxSwapIntervalMESA failed"); @@ -544,7 +576,16 @@ X11_GL_SetSwapInterval(_THIS, int interval) int X11_GL_GetSwapInterval(_THIS) { - if (_this->gl_data->glXGetSwapIntervalMESA) { + if (_this->gl_data->glXSwapIntervalEXT) { + Display *display = ((SDL_VideoData *) _this->driverdata)->display; + const SDL_WindowData *windowdata = (SDL_WindowData *) + _this->current_glwin->driverdata; + Window drawable = windowdata->xwindow; + unsigned int value = 0; + _this->gl_data->glXQueryDrawable(display, drawable, + GLX_SWAP_INTERVAL_EXT, &value); + return (int) value; + } else if (_this->gl_data->glXGetSwapIntervalMESA) { return _this->gl_data->glXGetSwapIntervalMESA(); } else { return swapinterval; @@ -572,4 +613,6 @@ X11_GL_DeleteContext(_THIS, SDL_GLContext context) #endif /* SDL_VIDEO_OPENGL_GLX */ +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11opengl.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11opengl.h index 50a285ec1..cb5cb3d9c 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11opengl.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11opengl.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -32,26 +31,17 @@ struct SDL_GLDriverData { SDL_bool HAS_GLX_EXT_visual_rating; - void *(*glXGetProcAddress) (const GLubyte * procName); - - XVisualInfo *(*glXChooseVisual) - (Display * dpy, int screen, int *attribList); - - GLXContext(*glXCreateContext) - (Display * dpy, XVisualInfo * vis, GLXContext shareList, Bool direct); - - void (*glXDestroyContext) - (Display * dpy, GLXContext ctx); - - Bool(*glXMakeCurrent) - (Display * dpy, GLXDrawable drawable, GLXContext ctx); - - void (*glXSwapBuffers) - (Display * dpy, GLXDrawable drawable); - - int (*glXSwapIntervalSGI) (int interval); - GLint(*glXSwapIntervalMESA) (unsigned interval); - GLint(*glXGetSwapIntervalMESA) (void); + void *(*glXGetProcAddress) (const GLubyte*); + XVisualInfo *(*glXChooseVisual) (Display*,int,int*); + GLXContext (*glXCreateContext) (Display*,XVisualInfo*,GLXContext,Bool); + void (*glXDestroyContext) (Display*, GLXContext); + Bool(*glXMakeCurrent) (Display*,GLXDrawable,GLXContext); + void (*glXSwapBuffers) (Display*, GLXDrawable); + void (*glXQueryDrawable) (Display*,GLXDrawable,int,unsigned int*); + int (*glXSwapIntervalEXT) (Display*,GLXDrawable,int); + int (*glXSwapIntervalSGI) (int); + int (*glXSwapIntervalMESA) (int); + int (*glXGetSwapIntervalMESA) (void); }; /* OpenGL functions */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11opengles.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11opengles.c index b7eb008ea..0e545d257 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11opengles.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11opengles.c @@ -1,31 +1,26 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org - - Open Pandora SDL driver - Copyright (C) 2009 David Carré - (cpasjuste@gmail.com) + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" -#if SDL_VIDEO_OPENGL_ES +#if SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES #include "SDL_x11video.h" #include "SDL_x11opengles.h" @@ -365,6 +360,6 @@ X11_GLES_DeleteContext(_THIS, SDL_GLContext context) } -#endif /* SDL_VIDEO_OPENGL_ES */ +#endif /* SDL_VIDEO_DRIVER_X11 && SDL_VIDEO_OPENGL_ES */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11opengles.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11opengles.h index c15424639..7c879c43e 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11opengles.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11opengles.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11render.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11render.c deleted file mode 100644 index a18d71e6f..000000000 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11render.c +++ /dev/null @@ -1,2360 +0,0 @@ -/* - - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#if SDL_VIDEO_RENDER_X11 - -#include /* For INT_MIN and INT_MAX */ - -#include "SDL_x11video.h" -#include "SDL_x11render.h" -#include "../SDL_rect_c.h" -#include "../SDL_pixels_c.h" -#include "../SDL_yuv_sw_c.h" - -/* X11 renderer implementation */ - -static SDL_Renderer *X11_CreateRenderer(SDL_Window * window, Uint32 flags); -static int X11_DisplayModeChanged(SDL_Renderer * renderer); -static int X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int X11_QueryTexturePixels(SDL_Renderer * renderer, - SDL_Texture * texture, void **pixels, - int *pitch); -static int X11_SetTextureRGBAMod(SDL_Renderer * renderer, - SDL_Texture * texture); -static int X11_SetTextureBlendMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int X11_SetTextureScaleMode(SDL_Renderer * renderer, - SDL_Texture * texture); -static int X11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, - int pitch); -static int X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, - void **pixels, int *pitch); -static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture); -static int X11_SetDrawBlendMode(SDL_Renderer * renderer); -static int X11_RenderDrawPoints(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int X11_RenderDrawLines(SDL_Renderer * renderer, - const SDL_Point * points, int count); -static int X11_RenderDrawRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int X11_RenderFillRects(SDL_Renderer * renderer, - const SDL_Rect ** rects, int count); -static int X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect); -static int X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch); -static int X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch); -static void X11_RenderPresent(SDL_Renderer * renderer); -static void X11_DestroyTexture(SDL_Renderer * renderer, - SDL_Texture * texture); -static void X11_DestroyRenderer(SDL_Renderer * renderer); - - -SDL_RenderDriver X11_RenderDriver = { - X11_CreateRenderer, - { - "x11", - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY | - SDL_RENDERER_PRESENTFLIP2 | SDL_RENDERER_PRESENTFLIP3 | - SDL_RENDERER_PRESENTDISCARD | SDL_RENDERER_ACCELERATED), - SDL_TEXTUREMODULATE_NONE, - SDL_BLENDMODE_NONE, - SDL_SCALEMODE_NONE, - 0, - {0}, - 0, - 0} -}; - -typedef struct -{ - Display *display; - int screen; - Visual *visual; - int depth; - int scanline_pad; - Window xwindow; - Pixmap pixmaps[3]; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - Pixmap stencil; - Pixmap brush; - Picture brush_pict; - Picture xwindow_pict; - Picture pixmap_picts[3]; - Picture drawable_pict; - Picture stencil_pict; - int blend_op; - XRenderPictFormat *xwindow_pict_fmt; - XRenderPictFormat *drawable_pict_fmt; - GC stencil_gc; - SDL_bool use_xrender; -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - SDL_bool use_xdamage; - Damage stencil_damage; - XserverRegion stencil_parts; -#endif -#endif - int current_pixmap; - Drawable drawable; - SDL_PixelFormat format; - GC gc; - SDL_DirtyRectList dirty; - SDL_bool makedirty; -} X11_RenderData; - -typedef struct -{ - SDL_SW_YUVTexture *yuv; - Uint32 format; - Pixmap pixmap; - int depth; - Visual *visual; - GC gc; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - Picture picture; - Pixmap modulated_pixmap; - Picture modulated_picture; - XRenderPictFormat* picture_fmt; - int blend_op; - const char* filter; -#endif - XImage *image; -#ifndef NO_SHARED_MEMORY - /* MIT shared memory extension information */ - XShmSegmentInfo shminfo; -#endif - XImage *scaling_image; - void *pixels; - int pitch; -} X11_TextureData; - -#ifndef NO_SHARED_MEMORY -/* Shared memory error handler routine */ -static int shm_error; -static int (*X_handler) (Display *, XErrorEvent *) = NULL; -static int -shm_errhandler(Display * d, XErrorEvent * e) -{ - if (e->error_code == BadAccess) { - shm_error = True; - return (0); - } else { - return (X_handler(d, e)); - } -} -#endif /* ! NO_SHARED_MEMORY */ - -static void -UpdateYUVTextureData(SDL_Texture * texture) -{ - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - SDL_Rect rect; - - rect.x = 0; - rect.y = 0; - rect.w = texture->w; - rect.h = texture->h; - SDL_SW_CopyYUVToRGB(data->yuv, &rect, data->format, texture->w, - texture->h, data->pixels, data->pitch); -} - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER -static SDL_bool -CheckXRender(Display *display, int *major, int *minor) -{ - const char *env; - - *major = *minor = 0; - - env = SDL_getenv("SDL_VIDEO_X11_XRENDER"); - - if (env && !SDL_atoi(env)) { - return SDL_FALSE; - } - - if (!SDL_X11_HAVE_XRENDER) { - return SDL_FALSE; - } - - if (!XRenderQueryVersion(display, major, minor)) { - return SDL_FALSE; - } - - if (*major != 0 || *minor < 10) { - return SDL_FALSE; - } - - return SDL_TRUE; -} -#endif - -#ifdef SDL_VIDEO_DRIVER_X11_XFIXES -static SDL_bool -CheckXFixes(Display *display, int *major, int *minor) -{ - const char *env; - - *major = *minor = 0; - - env = SDL_getenv("SDL_VIDEO_X11_XFIXES"); - - if (env && !SDL_atoi(env)) { - return SDL_FALSE; - } - - if (!SDL_X11_HAVE_XFIXES) { - return SDL_FALSE; - } - - if (!XFixesQueryVersion(display, major, minor)) { - return SDL_FALSE; - } - - if (*major < 2) { - return SDL_FALSE; - } - - return SDL_TRUE; -} -#endif - -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE -static SDL_bool -CheckXDamage(Display *display, int *major, int *minor) -{ - const char *env; - - *major = *minor = 0; - - env = SDL_getenv("SDL_VIDEO_X11_XDAMAGE"); - - if (env && !SDL_atoi(env)) { - return SDL_FALSE; - } - - if (!SDL_X11_HAVE_XDAMAGE) { - return SDL_FALSE; - } - - if (!XDamageQueryVersion(display, major, minor)) { - return SDL_FALSE; - } - - return SDL_TRUE; -} -#endif - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER -static Uint32 -XRenderPictFormatToSDLPixelFormatEnum(XRenderPictFormat *pict_format) -{ - if (pict_format->type != PictTypeDirect) { - SDL_SetError("Indexed pict formats not supported ATM"); - return 0; - } - Uint32 Amask, Rmask, Gmask, Bmask; - int bpp; - - Rmask = pict_format->direct.redMask << pict_format->direct.red; - Gmask = pict_format->direct.greenMask << pict_format->direct.green; - Bmask = pict_format->direct.blueMask << pict_format->direct.blue; - Amask = pict_format->direct.alphaMask << pict_format->direct.alpha; - bpp = pict_format->depth; - - Uint32 format; - format = SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask); - return format; -} -#endif - -void -X11_AddRenderDriver(_THIS) -{ - SDL_RendererInfo *info = &X11_RenderDriver.info; - SDL_DisplayMode *mode = &SDL_CurrentDisplay->desktop_mode; - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - int i; - - info->texture_formats[info->num_texture_formats++] = mode->format; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YV12; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_IYUV; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YUY2; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_UYVY; - info->texture_formats[info->num_texture_formats++] = SDL_PIXELFORMAT_YVYU; - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - int major, minor; - if (CheckXRender(data->display, &major, &minor)) { - XRenderPictFormat templ; - templ.type = PictTypeDirect; - XRenderPictFormat *pict_format; - Uint32 format; - int i = 0; - /* Convert each XRenderPictFormat into appropriate - * SDLPixelFormatEnum. */ - while (info->num_texture_formats < 50) { - pict_format = - XRenderFindFormat(data->display, PictFormatType, &templ, i++); - if (pict_format) { - format = XRenderPictFormatToSDLPixelFormatEnum(pict_format); - if (format != SDL_PIXELTYPE_UNKNOWN) { - info->texture_formats[info->num_texture_formats++] = format; - } - } - else - break; - } - /* Update the capabilities of the renderer. */ - info->blend_modes |= (SDL_BLENDMODE_BLEND | SDL_BLENDMODE_ADD | - SDL_BLENDMODE_MOD | SDL_BLENDMODE_MASK); - info->scale_modes |= (SDL_SCALEMODE_FAST | SDL_SCALEMODE_SLOW | - SDL_SCALEMODE_BEST); - info->mod_modes |= (SDL_TEXTUREMODULATE_COLOR | SDL_TEXTUREMODULATE_ALPHA); - } -#endif - - for (i = 0; i < _this->num_displays; ++i) { - SDL_AddRenderDriver(&_this->displays[i], &X11_RenderDriver); - } -} - -SDL_Renderer * -X11_CreateRenderer(SDL_Window * window, Uint32 flags) -{ - SDL_VideoDisplay *display = window->display; - SDL_DisplayData *displaydata = (SDL_DisplayData *) display->driverdata; - SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata; - SDL_Renderer *renderer; - X11_RenderData *data; - XGCValues gcv; - gcv.graphics_exposures = False; - int i, n; - int bpp; - Uint32 Rmask, Gmask, Bmask, Amask; - - renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer)); - if (!renderer) { - SDL_OutOfMemory(); - return NULL; - } - - data = (X11_RenderData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - X11_DestroyRenderer(renderer); - SDL_OutOfMemory(); - return NULL; - } - data->display = windowdata->videodata->display; - data->screen = displaydata->screen; - data->visual = displaydata->visual; - data->depth = displaydata->depth; - data->scanline_pad = displaydata->scanline_pad; - data->xwindow = windowdata->xwindow; - - renderer->DisplayModeChanged = X11_DisplayModeChanged; - renderer->CreateTexture = X11_CreateTexture; - renderer->QueryTexturePixels = X11_QueryTexturePixels; - renderer->SetTextureAlphaMod = X11_SetTextureRGBAMod; - renderer->SetTextureColorMod = X11_SetTextureRGBAMod; - renderer->SetTextureBlendMode = X11_SetTextureBlendMode; - renderer->SetTextureScaleMode = X11_SetTextureScaleMode; - renderer->UpdateTexture = X11_UpdateTexture; - renderer->LockTexture = X11_LockTexture; - renderer->UnlockTexture = X11_UnlockTexture; - renderer->SetDrawBlendMode = X11_SetDrawBlendMode; - renderer->RenderDrawPoints = X11_RenderDrawPoints; - renderer->RenderDrawLines = X11_RenderDrawLines; - renderer->RenderDrawRects = X11_RenderDrawRects; - renderer->RenderFillRects = X11_RenderFillRects; - renderer->RenderCopy = X11_RenderCopy; - renderer->RenderReadPixels = X11_RenderReadPixels; - renderer->RenderWritePixels = X11_RenderWritePixels; - renderer->RenderPresent = X11_RenderPresent; - renderer->DestroyTexture = X11_DestroyTexture; - renderer->DestroyRenderer = X11_DestroyRenderer; - renderer->info = X11_RenderDriver.info; - renderer->window = window; - renderer->driverdata = data; - - renderer->info.flags = SDL_RENDERER_ACCELERATED; - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - int major, minor; - data->use_xrender = CheckXRender(data->display, &major, &minor); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (CheckXDamage(data->display, &major, &minor)) { - if (CheckXFixes(data->display, &major, &minor)) { - data->use_xdamage = SDL_TRUE; - } - } -#endif - if (data->use_xrender) { - /* Find the PictFormat from the visual. - * Should be an RGB PictFormat most of the time. */ - data->xwindow_pict_fmt = XRenderFindVisualFormat(data->display, - data->visual); - if (!data->xwindow_pict_fmt) { - SDL_SetError("XRenderFindVisualFormat() failed"); - return NULL; - } - data->xwindow_pict = XRenderCreatePicture(data->display, - data->xwindow, - data->xwindow_pict_fmt, - 0, NULL); - if (!data->xwindow_pict) { - SDL_SetError("XRenderCreatePicture() failed"); - return NULL; - } - // FIXME: Clear the window. Is this required? - XRenderComposite(data->display, - PictOpClear, - data->xwindow_pict, - None, - data->xwindow_pict, - 0, 0, - 0, 0, - 0, 0, - window->w, window->h); - /* Create a clip mask that is used for rendering primitives. */ - data->stencil = XCreatePixmap(data->display, data->xwindow, - window->w, window->h, 32); - if (!data->stencil) { - SDL_SetError("XCreatePixmap() failed."); - return NULL; - } - - /* Create the GC for the clip mask. */ - data->stencil_gc = XCreateGC(data->display, data->stencil, - GCGraphicsExposures, &gcv); - /* Set the GC parameters. */ - XSetBackground(data->display, data->stencil_gc, 0); - XSetForeground(data->display, data->stencil_gc, 0); - XFillRectangle(data->display, data->stencil, data->stencil_gc, - 0, 0, window->w, window->h); - XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF); - - /* Create an XRender Picture for the clip mask. */ - data->stencil_pict = - XRenderCreatePicture(data->display, data->stencil, - XRenderFindStandardFormat(data->display, - PictStandardARGB32), - 0, NULL); - if (!data->stencil_pict) { - SDL_SetError("XRenderCreatePicture() failed."); - return NULL; - } -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) { - data->stencil_damage = - XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty); - if (!data->stencil_damage) { - SDL_SetError("XDamageCreate() failed."); - return NULL; - } - XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); - } -#endif - /* Create a brush pixmap for the color being - * drawn at any given time. */ - data->brush = - XCreatePixmap(data->display, data->xwindow, 1, 1, 32); - if (!data->brush) { - SDL_SetError("XCreatePixmap() failed."); - return NULL; - } - - /* Set some parameters for the brush. */ - XRenderPictureAttributes brush_attr; - brush_attr.repeat = RepeatNormal; - /* Create an XRender Picture for the brush - * with the above parameters. */ - data->brush_pict = - XRenderCreatePicture(data->display, data->brush, - XRenderFindStandardFormat(data->display, - PictStandardARGB32), - CPRepeat, &brush_attr); - if (!data->brush_pict) { - SDL_SetError("XRenderCreatePicture() failed."); - return NULL; - } - // FIXME: Is the following necessary? - /* Set the default blending mode. */ - renderer->blendMode = SDL_BLENDMODE_BLEND; - data->blend_op = PictOpOver; - } -#endif - if (flags & SDL_RENDERER_SINGLEBUFFER) { - renderer->info.flags |= - (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTCOPY); - n = 0; - } else if (flags & SDL_RENDERER_PRESENTFLIP2) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP2; - n = 2; - } else if (flags & SDL_RENDERER_PRESENTFLIP3) { - renderer->info.flags |= SDL_RENDERER_PRESENTFLIP3; - n = 3; - } else { - renderer->info.flags |= SDL_RENDERER_PRESENTCOPY; - n = 1; - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) { - if (n > 0) - data->drawable_pict_fmt = - XRenderFindStandardFormat(data->display, PictStandardARGB32); - else - data->drawable_pict_fmt = data->xwindow_pict_fmt; - } -#endif - for (i = 0; i < n; ++i) { -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) { - data->pixmaps[i] = XCreatePixmap(data->display, - data->xwindow, - window->w, - window->h, - 32); - } - else -#endif - { - data->pixmaps[i] = - XCreatePixmap(data->display, data->xwindow, window->w, window->h, - displaydata->depth); - } - if (!data->pixmaps[i]) { - X11_DestroyRenderer(renderer); - SDL_SetError("XCreatePixmap() failed"); - return NULL; - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) { - /* Create XRender pictures for each of the pixmaps - * and clear the pixmaps. */ - data->pixmap_picts[i] = - XRenderCreatePicture(data->display, - data->pixmaps[i], - XRenderFindStandardFormat(data->display, - PictStandardARGB32), - 0, None); - if (!data->pixmap_picts[i]) { - SDL_SetError("XRenderCreatePicture() failed"); - return NULL; - } - - XRenderComposite(data->display, - PictOpClear, - data->pixmap_picts[i], - None, - data->pixmap_picts[i], - 0, 0, - 0, 0, - 0, 0, - window->w, window->h); - } -#endif - } - if (n > 0) { - data->drawable = data->pixmaps[0]; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if(data->use_xrender == SDL_TRUE) - data->drawable_pict = data->pixmap_picts[0]; -#endif - data->makedirty = SDL_TRUE; - } else { - data->drawable = data->xwindow; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if(data->use_xrender == SDL_TRUE) - data->drawable_pict = data->xwindow_pict; -#endif - data->makedirty = SDL_FALSE; - } - data->current_pixmap = 0; - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - /* When using XRender the drawable format - * is not the same as the screen format. */ - if (data->use_xrender) { - bpp = data->drawable_pict_fmt->depth; - Rmask = ((data->drawable_pict_fmt->direct.redMask) - << (data->drawable_pict_fmt->direct.red)); - Gmask = ((data->drawable_pict_fmt->direct.greenMask) - << (data->drawable_pict_fmt->direct.green)); - Bmask = ((data->drawable_pict_fmt->direct.blueMask) - << (data->drawable_pict_fmt->direct.blue)); - Amask = ((data->drawable_pict_fmt->direct.alphaMask) - << (data->drawable_pict_fmt->direct.alpha)); - } - else -#endif - { - /* Get the format of the window */ - if (!SDL_PixelFormatEnumToMasks - (display->current_mode.format, &bpp, &Rmask, &Gmask, &Bmask, - &Amask)) { - SDL_SetError("Unknown display format"); - X11_DestroyRenderer(renderer); - return NULL; - } - } - SDL_InitFormat(&data->format, bpp, Rmask, Gmask, Bmask, Amask); - - /* Create the drawing context */ - gcv.graphics_exposures = False; - data->gc = - XCreateGC(data->display, data->drawable, GCGraphicsExposures, &gcv); - if (!data->gc) { - X11_DestroyRenderer(renderer); - SDL_SetError("XCreateGC() failed"); - return NULL; - } - - return renderer; -} - -static int -X11_DisplayModeChanged(SDL_Renderer * renderer) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - int i, n; - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) { - XRenderFreePicture(data->display, data->xwindow_pict); - - data->xwindow_pict_fmt = - XRenderFindVisualFormat(data->display, data->visual); - if (!data->xwindow_pict_fmt) { - SDL_SetError("XRenderFindVisualFormat() failed."); - return -1; - } - - data->xwindow_pict = - XRenderCreatePicture(data->display, data->xwindow, - data->xwindow_pict_fmt, 0, NULL); - if (!data->xwindow_pict) { - SDL_SetError("XRenderCreatePicture() failed."); - return -1; - } - - XRenderComposite(data->display, - PictOpClear, - data->xwindow_pict, - None, - data->xwindow_pict, - 0, 0, - 0, 0, - 0, 0, - window->w, window->h); - - XFreePixmap(data->display, data->stencil); - data->stencil = XCreatePixmap(data->display, data->xwindow, - window->w, window->h, 32); - if (!data->stencil) { - SDL_SetError("XCreatePixmap() failed."); - return -1; - } - - XRenderFreePicture(data->display, data->stencil_pict); - data->stencil_pict = - XRenderCreatePicture(data->display, data->stencil, - XRenderFindStandardFormat(data->display, - PictStandardARGB32), - 0, NULL); - if (!data->stencil_pict) { - SDL_SetError("XRenderCreatePicture() failed."); - return -1; - } -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) { - XDamageDestroy(data->display, data->stencil_damage); - data->stencil_damage = - XDamageCreate(data->display, data->stencil, XDamageReportNonEmpty); - if (!data->stencil_damage) { - SDL_SetError("XDamageCreate() failed."); - return -1; - } - XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); - } -#endif - } -#endif - if (renderer->info.flags & SDL_RENDERER_SINGLEBUFFER) { - n = 0; - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { - n = 2; - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { - n = 3; - } else { - n = 1; - } - for (i = 0; i < n; ++i) { - if (data->pixmaps[i] != None) { - XFreePixmap(data->display, data->pixmaps[i]); - data->pixmaps[i] = None; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - XRenderFreePicture(data->display, data->pixmap_picts[i]); - data->pixmap_picts[i] = None; -#endif - } - } - for (i = 0; i < n; ++i) { -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) { - data->pixmaps[i] = - XCreatePixmap(data->display, - data->xwindow, - window->w, - window->h, - 32); - } - else -#endif - { - data->pixmaps[i] = - XCreatePixmap(data->display, data->xwindow, window->w, window->h, - data->depth); - } - if (data->pixmaps[i] == None) { - SDL_SetError("XCreatePixmap() failed"); - return -1; - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) { - data->pixmap_picts[i] = - XRenderCreatePicture(data->display, - data->pixmaps[i], - XRenderFindStandardFormat(data->display, - PictStandardARGB32), - 0, None); - if (!data->pixmap_picts[i]) { - SDL_SetError("XRenderCreatePicture() failed"); - return -1; - } - XRenderComposite(data->display, - PictOpClear, - data->pixmap_picts[i], - None, - data->pixmap_picts[i], - 0, 0, - 0, 0, - 0, 0, - window->w, window->h); - - } -#endif - } - if (n > 0) { - data->drawable = data->pixmaps[0]; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - data->drawable_pict = data->pixmap_picts[0]; -#endif - } - data->current_pixmap = 0; - - return 0; -} - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER -static void -SDLMaskToXRenderMask(Uint32 sdl_mask, short *comp, short *compMask) -{ - if (sdl_mask == 0) { - *comp = 0; - *compMask = 0; - } else { - (*comp) = 0; - (*compMask) = 0; - while(!(sdl_mask & 1)) { - (*comp)++; - sdl_mask >>= 1; - } - while(sdl_mask & 1) { - (*compMask) = ((*compMask) << 1) | 1; - sdl_mask >>= 1; - } - } -} - -static XRenderPictFormat* -PixelFormatEnumToXRenderPictFormat(SDL_Renderer * renderer, Uint32 format) -{ - XRenderPictFormat* pict_fmt = NULL; - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - - if (data->use_xrender) { - - int bpp; - Uint32 Amask, Rmask, Gmask, Bmask; - if(!SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask)) { - SDL_SetError("Unknown pixel format"); - return NULL; - } - XRenderPictFormat templ; - unsigned long mask = (PictFormatType | PictFormatDepth | PictFormatRed | - PictFormatRedMask | PictFormatGreen | PictFormatGreenMask | - PictFormatBlue | PictFormatBlueMask | PictFormatAlpha | - PictFormatAlphaMask); - - templ.type = PictTypeDirect; - templ.depth = bpp; - SDLMaskToXRenderMask(Amask, &(templ.direct.alpha), &(templ.direct.alphaMask)); - SDLMaskToXRenderMask(Rmask, &(templ.direct.red), &(templ.direct.redMask)); - SDLMaskToXRenderMask(Gmask, &(templ.direct.green), &(templ.direct.greenMask)); - SDLMaskToXRenderMask(Bmask, &(templ.direct.blue), &(templ.direct.blueMask)); - pict_fmt = XRenderFindFormat(data->display, mask, &templ, 0); - } - - return pict_fmt; -} - -static Visual* -PixelFormatEnumToVisual(SDL_Renderer * renderer, Uint32 format) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - - if (data->use_xrender) { - int bpp; - Uint32 Amask, Rmask, Gmask, Bmask; - SDL_PixelFormatEnumToMasks(format, &bpp, &Rmask, &Gmask, &Bmask, &Amask); - - XVisualInfo vinfo_templ; - long vinfo_mask; - int nitems_return; - - vinfo_mask = (VisualDepthMask | VisualRedMaskMask | - VisualGreenMaskMask | VisualBlueMaskMask); - vinfo_templ.depth = bpp; - vinfo_templ.red_mask = Rmask; - vinfo_templ.green_mask = Gmask; - vinfo_templ.blue_mask = Bmask; - - XVisualInfo * ret = XGetVisualInfo(data->display, vinfo_mask, - &vinfo_templ, &nitems_return); - - if (nitems_return) { - return ret[0].visual; - } - } - - return NULL; -} - -static XRenderColor -SDLColorToXRenderColor(Uint8 r, Uint8 g, Uint8 b, Uint8 a) -{ - double rd, gd, bd, ad; - XRenderColor ret; - rd = r / 255.0; - gd = g / 255.0; - bd = b / 255.0; - ad = a / 255.0; - - ret.red = (unsigned short) (rd * ad * 0xFFFF); - ret.green = (unsigned short) (gd * ad * 0xFFFF); - ret.blue = (unsigned short) (bd * ad * 0xFFFF); - ret.alpha = (unsigned short) (ad * 0xFFFF); - - return ret; -} -#endif - -static int -X11_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - X11_TextureData *data; - int pitch_alignmask = ((renderdata->scanline_pad / 8) - 1); - XGCValues gcv; - - data = (X11_TextureData *) SDL_calloc(1, sizeof(*data)); - if (!data) { - SDL_OutOfMemory(); - return -1; - } - data->depth = renderdata->depth; - data->visual = renderdata->visual; - data->gc = renderdata->gc; - - texture->driverdata = data; - if (SDL_ISPIXELFORMAT_FOURCC(texture->format)) { - data->yuv = - SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h); - if (!data->yuv) { - return -1; - } - data->format = display->current_mode.format; - } else { -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (renderdata->use_xrender) - { - Uint32 Amask, Rmask, Gmask, Bmask; - SDL_PixelFormatEnumToMasks(texture->format, &(data->depth), - &Rmask, &Gmask, &Bmask, &Amask); - data->visual = PixelFormatEnumToVisual(renderer, texture->format); - } - else -#endif - { - if (texture->format != display->current_mode.format) - { - SDL_SetError("Texture format doesn't match window format"); - return -1; - } - } - data->format = texture->format; - } - - if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) { -#ifndef NO_SHARED_MEMORY - XShmSegmentInfo *shminfo = &data->shminfo; - - shm_error = True; - - if (SDL_X11_HAVE_SHM) { - data->image = - XShmCreateImage(renderdata->display, data->visual, - data->depth, ZPixmap, NULL, - shminfo, texture->w, texture->h); - if (data->image) { - shminfo->shmid = - shmget(IPC_PRIVATE, texture->h * data->image->bytes_per_line, - IPC_CREAT | 0777); - if (shminfo->shmid >= 0) { - shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); - shminfo->readOnly = False; - if (shminfo->shmaddr != (char *) -1) { - shm_error = False; - X_handler = XSetErrorHandler(shm_errhandler); - XShmAttach(renderdata->display, shminfo); - XSync(renderdata->display, False); - XSetErrorHandler(X_handler); - if (shm_error) { - XShmDetach(renderdata->display, shminfo); - shmdt(shminfo->shmaddr); - XDestroyImage(data->image); - XSync(renderdata->display, False); - } - else { - data->pixels = data->image->data = shminfo->shmaddr; - shmctl(shminfo->shmid, IPC_RMID, NULL); - data->pixmap = - XCreatePixmap(renderdata->display, renderdata->xwindow, - texture->w, texture->h, data->depth); - if (!data->pixmap) { - SDL_SetError("XCreatePixmap() failed"); - return -1; - } - } - } - } - } - } - if (shm_error) { - shminfo->shmaddr = NULL; - } - if (!data->image) -#endif /* not NO_SHARED_MEMORY */ - { - data->image = - XCreateImage(renderdata->display, data->visual, - data->depth, ZPixmap, 0, NULL, - texture->w, texture->h, - SDL_BYTESPERPIXEL(data->format) * 8, - 0); - if (!data->image) { - X11_DestroyTexture(renderer, texture); - SDL_SetError("XCreateImage() failed"); - return -1; - } - data->pixels = SDL_malloc(texture->h * data->image->bytes_per_line); - if (!data->pixels) { - X11_DestroyTexture(renderer, texture); - SDL_OutOfMemory(); - return -1; - } - data->image->data = data->pixels; - data->pixmap = - XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, - texture->h, data->depth); - if (data->pixmap == None) { - X11_DestroyTexture(renderer, texture); - SDL_SetError("XCreatePixmap() failed"); - return -1; - } - } - } else { - data->image = - XCreateImage(renderdata->display, data->visual, - data->depth, ZPixmap, 0, NULL, - texture->w, texture->h, - SDL_BYTESPERPIXEL(data->format) * 8, - 0); - if (!data->image) { - X11_DestroyTexture(renderer, texture); - SDL_SetError("XCreateImage() failed"); - return -1; - } - data->pixmap = - XCreatePixmap(renderdata->display, renderdata->xwindow, texture->w, - texture->h, data->depth); - if (data->pixmap == None) { - X11_DestroyTexture(renderer, texture); - SDL_SetError("XCreatePixmap() failed"); - return -1; - } - } - - data->pitch = data->image->bytes_per_line; - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if(renderdata->use_xrender && !data->yuv) { - gcv.graphics_exposures = False; - data->gc = - XCreateGC(renderdata->display, data->pixmap, GCGraphicsExposures, &gcv); - if (!data->gc) { - SDL_SetError("XCreateGC() failed"); - return -1; - } - data->picture_fmt = - PixelFormatEnumToXRenderPictFormat(renderer, texture->format); - if (data->picture_fmt == NULL) { - X11_DestroyTexture(renderer, texture); - SDL_SetError("Texture format not supported by driver"); - return -1; - } - data->picture = - XRenderCreatePicture(renderdata->display, data->pixmap, - data->picture_fmt, 0, NULL); - if (!data->picture) { - X11_DestroyTexture(renderer, texture); - SDL_SetError("XRenderCreatePicture() failed"); - return -1; - } - data->modulated_pixmap = - XCreatePixmap(renderdata->display, renderdata->xwindow, - texture->w, texture->h, data->depth); - if (!data->modulated_pixmap) { - X11_DestroyTexture(renderer, texture); - SDL_SetError("XCreatePixmap() failed"); - return -1; - } - data->modulated_picture = - XRenderCreatePicture(renderdata->display, data->modulated_pixmap, - data->picture_fmt, 0, NULL); - if (!data->modulated_picture) { - X11_DestroyTexture(renderer, texture); - SDL_SetError("XRenderCreatePicture() failed"); - return -1; - } - // FIXME: Is the following required? - /* Set the default blending and scaling modes. */ - texture->blendMode = SDL_BLENDMODE_NONE; - texture->scaleMode = SDL_SCALEMODE_NONE; - data->blend_op = PictOpSrc; - data->filter = NULL; - } -#endif - return 0; -} - -static int -X11_QueryTexturePixels(SDL_Renderer * renderer, SDL_Texture * texture, - void **pixels, int *pitch) -{ - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - - if (data->yuv) { - return SDL_SW_QueryYUVTexturePixels(data->yuv, pixels, pitch); - } else { - *pixels = data->pixels; - *pitch = data->pitch; - return 0; - } -} - -static int -X11_SetTextureRGBAMod(SDL_Renderer * renderer, SDL_Texture * texture) -{ -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; - - if (renderdata->use_xrender) { - - Uint8 r = 0xFF, g = 0xFF, b = 0xFF, a = 0xFF; - - /* Check if alpha modulation is required. */ - if (texture->modMode & SDL_TEXTUREMODULATE_ALPHA) { - a = texture->a; - } - - /* Check if color modulation is required. */ - if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { - r = texture->r; - g = texture->g; - b = texture->b; - } - - /* We can save some labour if no modulation is required. */ - if (texture->modMode != SDL_TEXTUREMODULATE_NONE) { - XRenderColor mod_color = - SDLColorToXRenderColor(r, g, b, a); - XRenderFillRectangle(renderdata->display, PictOpSrc, - renderdata->brush_pict, &mod_color, - 0, 0, 1, 1); - } - - /* We can save some labour dealing with component alpha - * if color modulation is not required. */ - XRenderPictureAttributes attr; - if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { - attr.component_alpha = True; - XRenderChangePicture(renderdata->display, renderdata->brush_pict, - CPComponentAlpha, &attr); - } - - /* Again none of this is necessary is no modulation - * is required. */ - if (texture->modMode != SDL_TEXTUREMODULATE_NONE) { - XRenderComposite(renderdata->display, PictOpSrc, - data->picture, renderdata->brush_pict, - data->modulated_picture, - 0, 0, 0, 0, 0, 0, texture->w, texture->h); - } - - /* We only need to reset the component alpha - * attribute if color modulation is required. */ - if (texture->modMode & SDL_TEXTUREMODULATE_COLOR) { - attr.component_alpha = False; - XRenderChangePicture(renderdata->display, renderdata->brush_pict, - CPComponentAlpha, &attr); - } - - return 0; - } else { - SDL_Unsupported(); - return -1; - } -#else - SDL_Unsupported(); - return -1; -#endif -} - -static int -X11_SetTextureBlendMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; - switch (texture->blendMode) { - case SDL_BLENDMODE_NONE: -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (renderdata->use_xrender) { - data->blend_op = PictOpSrc; - return 0; - } - case SDL_BLENDMODE_MOD: - case SDL_BLENDMODE_MASK: - case SDL_BLENDMODE_BLEND: - if (renderdata->use_xrender) { - data->blend_op = PictOpOver; - return 0; - } - case SDL_BLENDMODE_ADD: - if (renderdata->use_xrender) { - data->blend_op = PictOpAdd; - return 0; - } -#endif - return 0; - default: - SDL_Unsupported(); - texture->blendMode = SDL_BLENDMODE_NONE; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (renderdata->use_xrender) { - texture->blendMode = SDL_BLENDMODE_BLEND; - data->blend_op = PictOpOver; - } -#endif - return -1; - } -} - -static int -X11_SetTextureScaleMode(SDL_Renderer * renderer, SDL_Texture * texture) -{ - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; - - switch (texture->scaleMode) { - case SDL_SCALEMODE_NONE: -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (renderdata->use_xrender) { - data->filter = NULL; - } -#endif - return 0; - case SDL_SCALEMODE_FAST: - /* We can sort of fake it for streaming textures */ - if (data->yuv || texture->access == SDL_TEXTUREACCESS_STREAMING) { - return 0; - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (renderdata->use_xrender) { - data->filter = FilterFast; - return 0; - } - case SDL_SCALEMODE_SLOW: - if (renderdata->use_xrender) { - data->filter = FilterGood; - return 0; - } - case SDL_SCALEMODE_BEST: - if (renderdata->use_xrender) { - data->filter = FilterBest; - return 0; - } -#endif - /* Fall through to unsupported case */ - default: - SDL_Unsupported(); -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (renderdata->use_xrender) { - texture->scaleMode = SDL_SCALEMODE_NONE; - data->filter = NULL; - } - else -#endif - texture->scaleMode = SDL_SCALEMODE_NONE; - return -1; - } - return 0; -} - -static int -X11_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, const void *pixels, int pitch) -{ - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - - if (data->yuv) { - if (SDL_SW_UpdateYUVTexture(data->yuv, rect, pixels, pitch) < 0) { - return -1; - } - UpdateYUVTextureData(texture); - return 0; - } else { - X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; - - if (data->pixels) { - Uint8 *src, *dst; - int row; - size_t length; - - src = (Uint8 *) pixels; - dst = - (Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format); - length = rect->w * SDL_BYTESPERPIXEL(texture->format); - for (row = 0; row < rect->h; ++row) { - SDL_memcpy(dst, src, length); - src += pitch; - dst += data->pitch; - } - } else { - data->image->width = rect->w; - data->image->height = rect->h; - data->image->data = (char *) pixels; - data->image->bytes_per_line = pitch; - XPutImage(renderdata->display, data->pixmap, data->gc, - data->image, 0, 0, rect->x, rect->y, rect->w, rect->h); - } - return 0; - } -} - -static int -X11_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * rect, int markDirty, void **pixels, - int *pitch) -{ - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - - if (data->yuv) { - return SDL_SW_LockYUVTexture(data->yuv, rect, markDirty, pixels, - pitch); - } else if (data->pixels) { - *pixels = - (void *) ((Uint8 *) data->pixels + rect->y * data->pitch + - rect->x * SDL_BYTESPERPIXEL(texture->format)); - *pitch = data->pitch; - return 0; - } else { - SDL_SetError("No pixels available"); - return -1; - } -} - -static void -X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - - if (data->yuv) { - SDL_SW_UnlockYUVTexture(data->yuv); - UpdateYUVTextureData(texture); - } -} - -static int -X11_SetDrawBlendMode(SDL_Renderer * renderer) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - switch (renderer->blendMode) { - case SDL_BLENDMODE_NONE: -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - //PictOpSrc - data->blend_op = PictOpSrc; - return 0; - case SDL_BLENDMODE_MOD: - case SDL_BLENDMODE_MASK: - case SDL_BLENDMODE_BLEND: // PictOpOver - data->blend_op = PictOpOver; - return 0; - case SDL_BLENDMODE_ADD: // PictOpAdd - data->blend_op = PictOpAdd; - return 0; - /* FIXME case SDL_BLENDMODE_MOD: */ -#endif - return 0; - default: - SDL_Unsupported(); -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if(data->use_xrender) { - renderer->blendMode = SDL_BLENDMODE_BLEND; - data->blend_op = PictOpOver; - } - else -#endif - { - renderer->blendMode = SDL_BLENDMODE_NONE; - } - return -1; - } -} - -static Uint32 -renderdrawcolor(SDL_Renderer * renderer, int premult) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - Uint8 r = renderer->r; - Uint8 g = renderer->g; - Uint8 b = renderer->b; - Uint8 a = renderer->a; - if (premult) - return SDL_MapRGBA(&data->format, ((int) r * (int) a) / 255, - ((int) g * (int) a) / 255, - ((int) b * (int) a) / 255, 255); - else - return SDL_MapRGBA(&data->format, r, g, b, a); -} - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER -static XRenderColor -xrenderdrawcolor(SDL_Renderer *renderer) -{ - XRenderColor xrender_color; - if(renderer->blendMode == SDL_BLENDMODE_NONE) { - xrender_color = - SDLColorToXRenderColor(renderer->r, renderer->g, renderer->b, 0xFF); - } - else { - xrender_color = - SDLColorToXRenderColor(renderer->r, renderer->g, renderer->b, renderer->a); - } - return xrender_color; -} -#endif - -static int -X11_RenderDrawPoints(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - XPoint *xpoints, *xpoint; - int i, xcount; - SDL_Rect clip; - - clip.x = 0; - clip.y = 0; - clip.w = window->w; - clip.h = window->h; - if (data->makedirty) { - SDL_Rect rect; - - /* Get the smallest rectangle that contains everything */ - rect.x = 0; - rect.y = 0; - rect.w = window->w; - rect.h = window->h; - if (!SDL_EnclosePoints(points, count, &rect, &rect)) { - /* Nothing to draw */ - return 0; - } - SDL_AddDirtyRect(&data->dirty, &rect); - } - { - xpoint = xpoints = SDL_stack_alloc(XPoint, count); - xcount = 0; - for (i = 0; i < count; ++i) { - int x = points[i].x; - int y = points[i].y; - if (x < 0 || x >= window->w || y < 0 || y >= window->h) { - continue; - } - xpoint->x = (short)x; - xpoint->y = (short)y; - ++xpoint; - ++xcount; - } - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender && - (renderer->blendMode != SDL_BLENDMODE_NONE) && - !(renderer->a == 0xFF && - renderer->blendMode != SDL_BLENDMODE_ADD && - renderer->blendMode != SDL_BLENDMODE_MOD)) - { - XSetForeground(data->display, data->stencil_gc, 0); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - { - /* Update only those parts which were changed - * in the previous drawing operation */ - XFixesSetGCClipRegion(data->display, data->stencil_gc, - 0, 0, data->stencil_parts); - } -#endif - XFillRectangle(data->display, data->stencil, data->stencil_gc, - 0, 0, window->w, window->h); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - { - XFixesSetGCClipRegion(data->display, data->stencil_gc, 0, 0, None); - } -#endif - XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF); - - XDrawPoints(data->display, data->stencil, data->stencil_gc, xpoints, xcount, - CoordModeOrigin); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - { - /* Store the damaged region in stencil_parts */ - XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); - } -#endif - } -#endif - } - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender && - (renderer->blendMode != SDL_BLENDMODE_NONE) && - !(renderer->a == 0xFF && - renderer->blendMode != SDL_BLENDMODE_ADD && - renderer->blendMode != SDL_BLENDMODE_MOD)) - { - XRenderColor foreground; - foreground = xrenderdrawcolor(renderer); - - XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, - &foreground, 0, 0, 1, 1); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - { - /* Update only those parts which drawn - * to in the current drawing operation */ - XFixesSetPictureClipRegion(data->display, data->drawable_pict, - 0, 0, data->stencil_parts); - } -#endif - XRenderComposite(data->display, data->blend_op, data->brush_pict, - data->stencil_pict, data->drawable_pict, - 0, 0, 0, 0, 0, 0, window->w, window->h); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - { - XFixesSetPictureClipRegion(data->display, data->drawable_pict, 0, 0, None); - } -#endif - } - else -#endif - { - unsigned long foreground = renderdrawcolor(renderer, 1); - XSetForeground(data->display, data->gc, foreground); - - - if (xcount > 0) { - XDrawPoints(data->display, data->drawable, data->gc, xpoints, xcount, - CoordModeOrigin); - } - } - - SDL_stack_free(xpoints); - - return 0; -} - -static int -X11_RenderDrawLines(SDL_Renderer * renderer, const SDL_Point * points, - int count) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_Rect clip; - unsigned long foreground; - XPoint *xpoints, *xpoint; - int i, xcount; - int minx, miny; - int maxx, maxy; - - clip.x = 0; - clip.y = 0; - clip.w = window->w; - clip.h = window->h; - { - Pixmap drawable; - GC gc; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender && - (renderer->blendMode != SDL_BLENDMODE_NONE) && - !(renderer->a == 0xFF && - renderer->blendMode != SDL_BLENDMODE_ADD && - renderer->blendMode != SDL_BLENDMODE_MOD)) - { - drawable = data->stencil; - gc = data->stencil_gc; - - XSetForeground(data->display, data->stencil_gc, 0); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - XFixesSetGCClipRegion(data->display, data->stencil_gc, - 0, 0, data->stencil_parts); -#endif - XFillRectangle(data->display, data->stencil, data->stencil_gc, - 0, 0, window->w, window->h); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - XFixesSetGCClipRegion(data->display, data->stencil_gc, - 0, 0, None); -#endif - XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF); - } - else -#endif - { - drawable = data->drawable; - gc = data->gc; - } - - foreground = renderdrawcolor(renderer, 1); - XSetForeground(data->display, data->gc, foreground); - - xpoint = xpoints = SDL_stack_alloc(XPoint, count); - xcount = 0; - minx = INT_MAX; - miny = INT_MAX; - maxx = INT_MIN; - maxy = INT_MIN; - for (i = 0; i < count; ++i) { - int x = points[i].x; - int y = points[i].y; - - /* If the point is inside the window, add it to the list */ - if (x >= 0 && x < window->w && y >= 0 && y < window->h) { - if (x < minx) { - minx = x; - } else if (x > maxx) { - maxx = x; - } - if (y < miny) { - miny = y; - } else if (y > maxy) { - maxy = y; - } - xpoint->x = (short)x; - xpoint->y = (short)y; - ++xpoint; - ++xcount; - continue; - } - - /* We need to clip the line segments joined by this point */ - if (xcount > 0) { - int x1 = xpoint[-1].x; - int y1 = xpoint[-1].y; - int x2 = x; - int y2 = y; - if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { - if (x2 < minx) { - minx = x2; - } else if (x2 > maxx) { - maxx = x2; - } - if (y2 < miny) { - miny = y2; - } else if (y2 > maxy) { - maxy = y2; - } - xpoint->x = (short)x2; - xpoint->y = (short)y2; - ++xpoint; - ++xcount; - } - XDrawLines(data->display, drawable, gc, - xpoints, xcount, CoordModeOrigin); - if (xpoints[0].x != x2 || xpoints[0].y != y2) { - XDrawPoint(data->display, drawable, gc, x2, y2); - } - if (data->makedirty) { - SDL_Rect rect; - - rect.x = minx; - rect.y = miny; - rect.w = (maxx - minx) + 1; - rect.h = (maxy - miny) + 1; - SDL_AddDirtyRect(&data->dirty, &rect); - } - xpoint = xpoints; - xcount = 0; - minx = INT_MAX; - miny = INT_MAX; - maxx = INT_MIN; - maxy = INT_MIN; - } - if (i < (count-1)) { - int x1 = x; - int y1 = y; - int x2 = points[i+1].x; - int y2 = points[i+1].y; - if (SDL_IntersectRectAndLine(&clip, &x1, &y1, &x2, &y2)) { - if (x1 < minx) { - minx = x1; - } else if (x1 > maxx) { - maxx = x1; - } - if (y1 < miny) { - miny = y1; - } else if (y1 > maxy) { - maxy = y1; - } - xpoint->x = (short)x1; - xpoint->y = (short)y1; - ++xpoint; - ++xcount; - } - } - } - if (xcount > 1) { - int x2 = xpoint[-1].x; - int y2 = xpoint[-1].y; - XDrawLines(data->display, drawable, gc, xpoints, xcount, - CoordModeOrigin); - if (xpoints[0].x != x2 || xpoints[0].y != y2) { - XDrawPoint(data->display, drawable, gc, x2, y2); - } - if (data->makedirty) { - SDL_Rect rect; - - rect.x = minx; - rect.y = miny; - rect.w = (maxx - minx) + 1; - rect.h = (maxy - miny) + 1; - SDL_AddDirtyRect(&data->dirty, &rect); - } - } - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender && - (renderer->blendMode != SDL_BLENDMODE_NONE) && - !(renderer->a == 0xFF && - renderer->blendMode != SDL_BLENDMODE_ADD && - renderer->blendMode != SDL_BLENDMODE_MOD)) - { - XRenderColor xrforeground = xrenderdrawcolor(renderer); - XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, - &xrforeground, 0, 0, 1, 1); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - { - XDamageSubtract(data->display, data->stencil_damage, None, data->stencil_parts); - - XFixesSetPictureClipRegion(data->display, data->drawable_pict, - 0, 0, data->stencil_parts); - } -#endif - XRenderComposite(data->display, data->blend_op, data->brush_pict, - data->stencil_pict, data->drawable_pict, - 0, 0, 0, 0, 0, 0, window->w, window->h); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - XFixesSetPictureClipRegion(data->display, data->drawable_pict, - 0, 0, None); -#endif - } -#endif - SDL_stack_free(xpoints); - - return 0; -} - -static int -X11_RenderDrawRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_Rect clip, rect; - int i, xcount; - XRectangle *xrects, *xrect; - xrect = xrects = SDL_stack_alloc(XRectangle, count); - xcount = 0; - - clip.x = 0; - clip.y = 0; - clip.w = window->w; - clip.h = window->h; - { - - for (i = 0; i < count; ++i) { - if (!SDL_IntersectRect(rects[i], &clip, &rect)) { - continue; - } - - xrect->x = (short)rect.x; - xrect->y = (short)rect.y; - xrect->width = (unsigned short)rect.w - 1; - xrect->height = (unsigned short)rect.h - 1; - ++xrect; - ++xcount; - - if (data->makedirty) { - SDL_AddDirtyRect(&data->dirty, &rect); - } - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender && - (renderer->blendMode != SDL_BLENDMODE_NONE) && - !(renderer->a == 0xFF && - renderer->blendMode != SDL_BLENDMODE_ADD && - renderer->blendMode != SDL_BLENDMODE_MOD)) - { - XSetForeground(data->display, data->stencil_gc, 0); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - XFixesSetGCClipRegion(data->display, data->stencil_gc, - 0, 0, data->stencil_parts); -#endif - XFillRectangle(data->display, data->stencil, data->stencil_gc, - 0, 0, window->w, window->h); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - XFixesSetGCClipRegion(data->display, data->stencil_gc, - 0, 0, None); -#endif - XSetForeground(data->display, data->stencil_gc, 0xFFFFFFFF); - - XDrawRectangles(data->display, data->stencil, data->stencil_gc, xrects, xcount); - -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - XDamageSubtract(data->display, data->stencil_damage, - None, data->stencil_parts); -#endif - } -#endif - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender && - (renderer->blendMode != SDL_BLENDMODE_NONE) && - !(renderer->a == 0xFF && - renderer->blendMode != SDL_BLENDMODE_ADD && - renderer->blendMode != SDL_BLENDMODE_MOD)) - { - XRenderColor foreground; - foreground = xrenderdrawcolor(renderer); - XRenderFillRectangle(data->display, PictOpSrc, data->brush_pict, - &foreground, 0, 0, 1, 1); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - XFixesSetPictureClipRegion(data->display, data->drawable_pict, - 0, 0, data->stencil_parts); -#endif - XRenderComposite(data->display, data->blend_op, data->brush_pict, - data->stencil_pict, data->drawable_pict, - 0, 0, 0, 0, 0, 0, window->w, window->h); -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage) - XFixesSetPictureClipRegion(data->display, data->drawable_pict, - 0, 0, None); -#endif - } - else -#endif - { - unsigned long foreground; - - foreground = renderdrawcolor(renderer, 1); - XSetForeground(data->display, data->gc, foreground); - - if (xcount > 0) { - XDrawRectangles(data->display, data->drawable, data->gc, - xrects, xcount); - } - } - SDL_stack_free(xrects); - - return 0; -} - -static int -X11_RenderFillRects(SDL_Renderer * renderer, const SDL_Rect ** rects, int count) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_Rect clip, rect; - - clip.x = 0; - clip.y = 0; - clip.w = window->w; - clip.h = window->h; - - int i, xcount; - XRectangle *xrects, *xrect; - xrect = xrects = SDL_stack_alloc(XRectangle, count); - xcount = 0; - for (i = 0; i < count; ++i) { - if (!SDL_IntersectRect(rects[i], &clip, &rect)) { - continue; - } - - xrect->x = (short)rect.x; - xrect->y = (short)rect.y; - xrect->width = (unsigned short)rect.w; - xrect->height = (unsigned short)rect.h; - ++xrect; - ++xcount; - - if (data->makedirty) { - SDL_AddDirtyRect(&data->dirty, &rect); - } - } - -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) { - XRenderColor foreground; - foreground = xrenderdrawcolor(renderer); - if (xcount == 1) { - XRenderFillRectangle(data->display, data->blend_op, data->drawable_pict, - &foreground, xrects[0].x, xrects[0].y, - xrects[0].width, xrects[0].height); - } - else if (xcount > 1) { - XRenderFillRectangles(data->display, data->blend_op, data->drawable_pict, - &foreground, xrects, xcount); - } - } - else -#endif - { - unsigned long foreground; - - foreground = renderdrawcolor(renderer, 1); - XSetForeground(data->display, data->gc, foreground); - - XFillRectangles(data->display, data->drawable, data->gc, - xrects, xcount); - } - - SDL_stack_free(xrects); - return 0; -} - -static int -X11_RenderCopy(SDL_Renderer * renderer, SDL_Texture * texture, - const SDL_Rect * srcrect, const SDL_Rect * dstrect) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - X11_TextureData *texturedata = (X11_TextureData *) texture->driverdata; - - if (data->makedirty) { - SDL_AddDirtyRect(&data->dirty, dstrect); - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender && !texturedata->yuv) { - if(texture->access == SDL_TEXTUREACCESS_STREAMING) { -#ifndef NO_SHARED_MEMORY - if(texturedata->shminfo.shmaddr) { - XShmPutImage(data->display, texturedata->pixmap, texturedata->gc, - texturedata->image, srcrect->x, srcrect->y, - srcrect->x, srcrect->y, srcrect->w, srcrect->h, - False); - } - else -#endif - if (texturedata->pixels) { - XPutImage(data->display, texturedata->pixmap, texturedata->gc, - texturedata->image, srcrect->x, srcrect->y, srcrect->x, - srcrect->y, srcrect->w, srcrect->h); - } - XSync(data->display, False); - } - Picture src, mask; - XRenderPictureAttributes attr; - const SDL_Rect *mrect; - /* mrect is the rectangular area of the mask - * picture that is aligned with the source. */ - - if (texture->modMode == SDL_TEXTUREMODULATE_NONE) { - src = texturedata->picture; - } - else { - src = texturedata->modulated_picture; - } - - if(texture->blendMode == SDL_BLENDMODE_NONE) - { - mask = None; - mrect = srcrect; - } - else if (texture->blendMode == SDL_BLENDMODE_MOD) - { - /* SDL_BLENDMODE_MOD requires a temporary buffer - * i.e. stencil_pict */ - mask = data->stencil_pict; - mrect = dstrect; - } - else - { - /* This trick allows on-the-fly multiplication - * of the src color channels with it's alpha - * channel. */ - mask = src; - mrect = srcrect; - } - - if(srcrect->w == dstrect->w && srcrect->h == dstrect->h) { - if (texture->blendMode == SDL_BLENDMODE_MOD) { - XRenderComposite(data->display, PictOpSrc, data->drawable_pict, - src, data->stencil_pict, - dstrect->x, dstrect->y, srcrect->x, srcrect->y, - dstrect->x, dstrect->y, dstrect->w, dstrect->h); - attr.component_alpha = True; - XRenderChangePicture(data->display, data->stencil_pict, - CPComponentAlpha, &attr); - } - XRenderComposite(data->display, texturedata->blend_op, - src, mask, data->drawable_pict, srcrect->x, srcrect->y, - mrect->x, mrect->y, dstrect->x, dstrect->y, - dstrect->w, dstrect->h); - } else { - /* The transformation is from the dst to src picture. */ - double xscale = ((double) srcrect->w) / dstrect->w; - double yscale = ((double) srcrect->h) / dstrect->h; - XTransform xform = {{ - {XDoubleToFixed(xscale), XDoubleToFixed(0), XDoubleToFixed(0)}, - {XDoubleToFixed(0), XDoubleToFixed(yscale), XDoubleToFixed(0)}, - {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}}; - XRenderSetPictureTransform(data->display, src, &xform); - - /* Black magic follows. */ - if (texture->blendMode == SDL_BLENDMODE_MOD) { - /* Copy the dst to a temp buffer. */ - XRenderComposite(data->display, PictOpSrc, data->drawable_pict, - src, data->stencil_pict, - dstrect->x, dstrect->y, srcrect->x, srcrect->y, - dstrect->x, dstrect->y, dstrect->w, dstrect->h); - /* Set the compnent alpha flag on the temp buffer. */ - attr.component_alpha = True; - XRenderChangePicture(data->display, data->stencil_pict, - CPComponentAlpha, &attr); - } - - /* Set the picture filter only if a scaling mode is set. */ - if (texture->scaleMode != SDL_SCALEMODE_NONE) { - XRenderSetPictureFilter(data->display, src, - texturedata->filter, 0, 0); - } - - XRenderComposite(data->display, texturedata->blend_op, - src, mask, data->drawable_pict, - srcrect->x, srcrect->y, mrect->x, mrect->y, - dstrect->x, dstrect->y, dstrect->w, dstrect->h); - /* Set the texture transformation back to the identity matrix. */ - XTransform identity = {{ - {XDoubleToFixed(1), XDoubleToFixed(0), XDoubleToFixed(0)}, - {XDoubleToFixed(0), XDoubleToFixed(1), XDoubleToFixed(0)}, - {XDoubleToFixed(0), XDoubleToFixed(0), XDoubleToFixed(1)}}}; - XRenderSetPictureTransform(data->display, src, &identity); - } - - /* Reset the component alpha flag only when - * the blending mode is SDL_BLENDMODE_MOD. */ - if (renderer->blendMode == SDL_BLENDMODE_MOD) { - attr.component_alpha = False; - XRenderChangePicture(data->display, data->stencil_pict, - CPComponentAlpha, &attr); - } - } - else -#endif - { - if (srcrect->w == dstrect->w && srcrect->h == dstrect->h) { -#ifndef NO_SHARED_MEMORY - if (texturedata->shminfo.shmaddr) { - XShmPutImage(data->display, data->drawable, data->gc, - texturedata->image, srcrect->x, srcrect->y, - dstrect->x, dstrect->y, srcrect->w, srcrect->h, - False); - } else -#endif - if (texturedata->pixels) { - XPutImage(data->display, data->drawable, data->gc, - texturedata->image, srcrect->x, srcrect->y, dstrect->x, - dstrect->y, srcrect->w, srcrect->h); - } else { - XCopyArea(data->display, texturedata->pixmap, data->drawable, - data->gc, srcrect->x, srcrect->y, dstrect->w, - dstrect->h, dstrect->x, dstrect->y); - } - } else if (texturedata->yuv - || texture->access == SDL_TEXTUREACCESS_STREAMING) { - SDL_Surface src, dst; - SDL_PixelFormat fmt; - SDL_Rect rect; - XImage *image = texturedata->scaling_image; - - if (!image) { - void *pixels; - int pitch; - - pitch = dstrect->w * SDL_BYTESPERPIXEL(texturedata->format); - pixels = SDL_malloc(dstrect->h * pitch); - if (!pixels) { - SDL_OutOfMemory(); - return -1; - } - - image = - XCreateImage(data->display, data->visual, data->depth, - ZPixmap, 0, pixels, dstrect->w, dstrect->h, - SDL_BYTESPERPIXEL(texturedata->format) * 8, - pitch); - if (!image) { - SDL_SetError("XCreateImage() failed"); - return -1; - } - texturedata->scaling_image = image; - - } else if (image->width != dstrect->w || image->height != dstrect->h - || !image->data) { - image->width = dstrect->w; - image->height = dstrect->h; - image->bytes_per_line = - image->width * SDL_BYTESPERPIXEL(texturedata->format); - image->data = - (char *) SDL_realloc(image->data, - image->height * image->bytes_per_line); - if (!image->data) { - SDL_OutOfMemory(); - return -1; - } - } - - /* Set up fake surfaces for SDL_SoftStretch() */ - SDL_zero(src); - src.format = &fmt; - src.w = texture->w; - src.h = texture->h; -#ifndef NO_SHARED_MEMORY - if (texturedata->shminfo.shmaddr) { - src.pixels = texturedata->shminfo.shmaddr; - } else -#endif - src.pixels = texturedata->pixels; - src.pitch = texturedata->pitch; - - SDL_zero(dst); - dst.format = &fmt; - dst.w = image->width; - dst.h = image->height; - dst.pixels = image->data; - dst.pitch = image->bytes_per_line; - - fmt.BytesPerPixel = SDL_BYTESPERPIXEL(texturedata->format); - - rect.x = 0; - rect.y = 0; - rect.w = dstrect->w; - rect.h = dstrect->h; - if (SDL_SoftStretch(&src, srcrect, &dst, &rect) < 0) { - return -1; - } - XPutImage(data->display, data->drawable, data->gc, image, 0, 0, - dstrect->x, dstrect->y, dstrect->w, dstrect->h); - } else { - XCopyArea(data->display, texturedata->pixmap, data->drawable, - data->gc, srcrect->x, srcrect->y, dstrect->w, dstrect->h, - srcrect->x, srcrect->y); - } - } - return 0; -} - -static int -X11_RenderReadPixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, void * pixels, int pitch) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - Uint32 screen_format = display->current_mode.format; - XImage *image; - - image = XGetImage(data->display, data->drawable, rect->x, rect->y, - rect->w, rect->h, AllPlanes, ZPixmap); - - SDL_ConvertPixels(rect->w, rect->h, - screen_format, image->data, image->bytes_per_line, - format, pixels, pitch); - - XDestroyImage(image); - return 0; -} - -static int -X11_RenderWritePixels(SDL_Renderer * renderer, const SDL_Rect * rect, - Uint32 format, const void * pixels, int pitch) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_Window *window = renderer->window; - SDL_VideoDisplay *display = window->display; - Uint32 screen_format = display->current_mode.format; - XImage *image; - void *image_pixels; - int image_pitch; - - image_pitch = rect->w * SDL_BYTESPERPIXEL(screen_format); - image_pixels = SDL_malloc(rect->h * image_pitch); - if (!image_pixels) { - SDL_OutOfMemory(); - return -1; - } - - image = XCreateImage(data->display, data->visual, - data->depth, ZPixmap, 0, image_pixels, - rect->w, rect->h, - SDL_BYTESPERPIXEL(screen_format) * 8, - image_pitch); - if (!image) { - SDL_SetError("XCreateImage() failed"); - return -1; - } - - SDL_ConvertPixels(rect->w, rect->h, - format, pixels, pitch, - screen_format, image->data, image->bytes_per_line); - - XPutImage(data->display, data->drawable, data->gc, - image, 0, 0, rect->x, rect->y, rect->w, rect->h); - - image->data = NULL; - XDestroyImage(image); - - SDL_free(image_pixels); - return 0; -} - -static void -X11_RenderPresent(SDL_Renderer * renderer) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - SDL_DirtyRect *dirty; - - /* Send the data to the display */ - if (!(renderer->info.flags & SDL_RENDERER_SINGLEBUFFER)) { - for (dirty = data->dirty.list; dirty; dirty = dirty->next) { - const SDL_Rect *rect = &dirty->rect; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) - { - XRenderComposite(data->display, - data->blend_op, - data->drawable_pict, - None, - data->xwindow_pict, - rect->x, rect->y, - 0, 0, - rect->x, rect->y, - rect->w, rect->h); - } - else -#endif - { - XCopyArea(data->display, data->drawable, data->xwindow, - data->gc, rect->x, rect->y, rect->w, rect->h, - rect->x, rect->y); - } - } - SDL_ClearDirtyRects(&data->dirty); - } - XSync(data->display, False); - - /* Update the flipping chain, if any */ - if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP2) { - data->current_pixmap = (data->current_pixmap + 1) % 2; - data->drawable = data->pixmaps[data->current_pixmap]; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - data->drawable_pict = data->pixmap_picts[data->current_pixmap]; -#endif - } else if (renderer->info.flags & SDL_RENDERER_PRESENTFLIP3) { - data->current_pixmap = (data->current_pixmap + 1) % 3; - data->drawable = data->pixmaps[data->current_pixmap]; -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - data->drawable_pict = data->pixmap_picts[data->current_pixmap]; -#endif - } -} - -static void -X11_DestroyTexture(SDL_Renderer * renderer, SDL_Texture * texture) -{ - X11_RenderData *renderdata = (X11_RenderData *) renderer->driverdata; - X11_TextureData *data = (X11_TextureData *) texture->driverdata; - - if (!data) { - return; - } - if (data->yuv) { - SDL_SW_DestroyYUVTexture(data->yuv); - } - if (data->pixmap != None) { - XFreePixmap(renderdata->display, data->pixmap); - } - if (data->image) { - data->image->data = NULL; - XDestroyImage(data->image); - } -#ifndef NO_SHARED_MEMORY - if (data->shminfo.shmaddr) { - XShmDetach(renderdata->display, &data->shminfo); - XSync(renderdata->display, False); - shmdt(data->shminfo.shmaddr); - data->pixels = NULL; - } -#endif -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (renderdata->use_xrender) { - if (data->picture) { - XRenderFreePicture(renderdata->display, data->picture); - } - if (data->modulated_pixmap) { - XFreePixmap(renderdata->display, data->modulated_pixmap); - } - if (data->modulated_picture) { - XRenderFreePicture(renderdata->display, data->modulated_picture); - } - } -#endif - if (data->scaling_image) { - SDL_free(data->scaling_image->data); - data->scaling_image->data = NULL; - XDestroyImage(data->scaling_image); - } - if (data->pixels) { - SDL_free(data->pixels); - } - SDL_free(data); - texture->driverdata = NULL; -} - -static void -X11_DestroyRenderer(SDL_Renderer * renderer) -{ - X11_RenderData *data = (X11_RenderData *) renderer->driverdata; - int i; - - if (data) { - for (i = 0; i < SDL_arraysize(data->pixmaps); ++i) { - if (data->pixmaps[i] != None) { - XFreePixmap(data->display, data->pixmaps[i]); - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender && data->pixmap_picts[i]) { - XRenderFreePicture(data->display, data->pixmap_picts[i]); - } -#endif - } - if (data->gc) { - XFreeGC(data->display, data->gc); - } -#ifdef SDL_VIDEO_DRIVER_X11_XRENDER - if (data->use_xrender) { - if (data->stencil_gc) { - XFreeGC(data->display, data->stencil_gc); - } - if (data->stencil) { - XFreePixmap(data->display, data->stencil); - } - if (data->stencil_pict) { - XRenderFreePicture(data->display, data->stencil_pict); - } - if (data->xwindow_pict) { - XRenderFreePicture(data->display, data->xwindow_pict); - } -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE - if (data->use_xdamage && data->stencil_damage) { - XDamageDestroy(data->display, data->stencil_damage); - } -#endif - } -#endif - SDL_FreeDirtyRects(&data->dirty); - SDL_free(data); - } - SDL_free(renderer); -} - -#endif /* SDL_VIDEO_RENDER_X11 */ - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11render.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11render.h deleted file mode 100644 index 95f6ee143..000000000 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11render.h +++ /dev/null @@ -1,30 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* SDL surface based renderer implementation */ - -#if SDL_VIDEO_RENDER_X11 -extern void X11_AddRenderDriver(_THIS); -#endif - -/* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11shape.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11shape.c index 74ee903a8..b98ad554b 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11shape.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11shape.c @@ -1,29 +1,32 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_X11 #include "SDL_assert.h" #include "SDL_x11video.h" #include "SDL_x11shape.h" #include "SDL_x11window.h" +#include "../SDL_shape_internals.h" SDL_Window* X11_CreateShapedWindow(const char *title,unsigned int x,unsigned int y,unsigned int w,unsigned int h,Uint32 flags) { @@ -108,3 +111,6 @@ X11_SetWindowShape(SDL_WindowShaper *shaper,SDL_Surface *shape,SDL_WindowShapeMo return 0; } + +#endif /* SDL_VIDEO_DRIVER_X11 */ + diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11shape.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11shape.h index fa8ea1c6d..714149ba8 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11shape.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11shape.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 2010 Eli Gottlieb + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Eli Gottlieb - eligottlieb@gmail.com + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11sym.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11sym.h index 3d83f1333..5b47b1c61 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11sym.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11sym.h @@ -1,136 +1,105 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ /* *INDENT-OFF* */ SDL_X11_MODULE(BASEXLIB) SDL_X11_SYM(XClassHint*,XAllocClassHint,(void),(),return) -SDL_X11_SYM(Status,XAllocColor,(Display* a,Colormap b,XColor* c),(a,b,c),return) -SDL_X11_SYM(Status,XAllocColorCells,(Display *a,Colormap b,Bool c,unsigned long d[],unsigned int e,unsigned long f[],unsigned int g),(a,b,c,d,e,f,g),return) SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void),(),return) -SDL_X11_SYM(XStandardColormap *,XAllocStandardColormap,(void),(),return) SDL_X11_SYM(XWMHints*,XAllocWMHints,(void),(),return) SDL_X11_SYM(int,XAutoRepeatOn,(Display* a),(a),return) SDL_X11_SYM(int,XAutoRepeatOff,(Display* a),(a),return) SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return) SDL_X11_SYM(int,XChangeProperty,(Display* a,Window b,Atom c,Atom d,int e,int f,_Xconst unsigned char* g,int h),(a,b,c,d,e,f,g,h),return) -SDL_X11_SYM(int,XChangeWindowAttributes,(Display* a,Window b,unsigned long c,XSetWindowAttributes* d),(a,b,c,d),return) -SDL_X11_SYM(Bool,XCheckWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return) -SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return) SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return) SDL_X11_SYM(int,XConvertSelection,(Display* a,Atom b,Atom c,Atom d,Window e,Time f),(a,b,c,d,e,f),return) -SDL_X11_SYM(int,XCopyArea,(Display* a,Drawable b,Drawable c,GC d,int e,int f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return) SDL_X11_SYM(Pixmap,XCreateBitmapFromData,(Display *dpy,Drawable d,_Xconst char *data,unsigned int width,unsigned int height),(dpy,d,data,width,height),return) SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return) SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return) SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return) SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return) -SDL_X11_SYM(Pixmap,XCreatePixmap,(Display* a,Drawable b,unsigned int c,unsigned int d,unsigned int e),(a,b,c,d,e),return) -SDL_X11_SYM(Pixmap,XCreatePixmapFromBitmapData,(Display* a,Drawable b,char* c,unsigned int d,unsigned int e,unsigned long f,unsigned long g,unsigned int h),(a,b,c,d,e,f,g,h),return) -SDL_X11_SYM(Window,XCreateSimpleWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,unsigned long h,unsigned long i),(a,b,c,d,e,f,g,h,i),return) SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return) SDL_X11_SYM(int,XDefineCursor,(Display* a,Window b,Cursor c),(a,b,c),return) SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return) SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return) SDL_X11_SYM(int,XDisplayKeycodes,(Display* a,int* b,int* c),(a,b,c),return) -SDL_X11_SYM(int,XDrawLines,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return) -SDL_X11_SYM(int,XDrawPoint,(Display* a, Drawable b, GC c, int d, int e),(a,b,c,d,e),return) -SDL_X11_SYM(int,XDrawPoints,(Display* a, Drawable b, GC c, XPoint* d, int e, int f),(a,b,c,d,e,f),return) -SDL_X11_SYM(int,XDrawRectangles,(Display* a,Drawable b,GC c,XRectangle* d,int e),(a,b,c,d,e),return) -SDL_X11_SYM(int,XFillRectangles,(Display* a,Drawable b,GC c,XRectangle* d,int e),(a,b,c,d,e),return) SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return) SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return) SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event,Window w),(event,w),return) SDL_X11_SYM(int,XFlush,(Display* a),(a),return) SDL_X11_SYM(int,XFree,(void*a),(a),return) -SDL_X11_SYM(int,XFreeColormap,(Display* a,Colormap b),(a,b),return) -SDL_X11_SYM(int,XFreeColors,(Display* a,Colormap b,unsigned long* c,int d,unsigned long e),(a,b,c,d,e),return) SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return) SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return) SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return) SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return) SDL_X11_SYM(char*,XGetAtomName,(Display *a,Atom b),(a,b),return) +SDL_X11_SYM(int,XGetInputFocus,(Display *a,Window *b,int *c),(a,b,c),return) SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return) -SDL_X11_SYM(XImage*,XGetImage,(Display* a,Drawable b,int c,int d,unsigned int e,unsigned int f,unsigned long g, int h),(a,b,c,d,e,f,g,h),return) SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return) SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return) -SDL_X11_SYM(int,XGetRGBColormaps,(Display* a,Window b,XStandardColormap **c,int *d,Atom e),(a,b,c,d,e),return) SDL_X11_SYM(Window,XGetSelectionOwner,(Display* a,Atom b),(a,b),return) -SDL_X11_SYM(Status,XGetTextProperty,(Display *a,Window b,XTextProperty *c,Atom d),(a,b,c,d),return) SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return) SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return) SDL_X11_SYM(int,XGetWindowProperty,(Display* a,Window b,Atom c,long d,long e,Bool f,Atom g,Atom* h,int* i,unsigned long* j,unsigned long *k,unsigned char **l),(a,b,c,d,e,f,g,h,i,j,k,l),return) SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(Status,XGetWMNormalHints,(Display *a,Window b, XSizeHints *c, long *d),(a,b,c,d),return) SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a,b,c,d,e,f),return) SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return) SDL_X11_SYM(int,XGrabServer,(Display* a),(a),return) SDL_X11_SYM(Status,XIconifyWindow,(Display* a,Window b,int c),(a,b,c),return) -SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return) SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display* a,KeySym b),(a,b),return) SDL_X11_SYM(char*,XKeysymToString,(KeySym a),(a),return) -SDL_X11_SYM(int,XKillClient,(Display* a,XID b),(a,b),return) SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return) SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return) SDL_X11_SYM(KeySym,XLookupKeysym,(XKeyEvent* a,int b),(a,b),return) SDL_X11_SYM(int,XLookupString,(XKeyEvent* a,char* b,int c,KeySym* d,XComposeStatus* e),(a,b,c,d,e),return) SDL_X11_SYM(int,XMapRaised,(Display* a,Window b),(a,b),return) -SDL_X11_SYM(int,XMapWindow,(Display* a,Window b),(a,b),return) -SDL_X11_SYM(int,XMaskEvent,(Display* a,long b,XEvent* c),(a,b,c),return) SDL_X11_SYM(Status,XMatchVisualInfo,(Display* a,int b,int c,int d,XVisualInfo* e),(a,b,c,d,e),return) SDL_X11_SYM(int,XMissingExtension,(Display* a,_Xconst char* b),(a,b),return) -SDL_X11_SYM(int,XMoveResizeWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f),(a,b,c,d,e,f),return) SDL_X11_SYM(int,XMoveWindow,(Display* a,Window b,int c,int d),(a,b,c,d),return) SDL_X11_SYM(int,XNextEvent,(Display* a,XEvent* b),(a,b),return) SDL_X11_SYM(Display*,XOpenDisplay,(_Xconst char* a),(a),return) SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return) SDL_X11_SYM(int,XPending,(Display* a),(a),return) SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return) -SDL_X11_SYM(int,XQueryColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return) SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return) SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return) SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return) -SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return) SDL_X11_SYM(int,XResetScreenSaver,(Display* a),(a),return) SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return) SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return) SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return) SDL_X11_SYM(int,XSetClassHint,(Display* a,Window b,XClassHint* c),(a,b,c),return) -SDL_X11_SYM(int,XSetCloseDownMode,(Display *a, int b),(a,b),return) -SDL_X11_SYM(int,XSetForeground,(Display* a,GC b,unsigned long c),(a,b,c),return) SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return) SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return) -SDL_X11_SYM(void,XSetRGBColormaps,( Display *a,Window b,XStandardColormap *c,int d,Atom e),(a,b,c,d,e),return) SDL_X11_SYM(int,XSetSelectionOwner,(Display* a,Atom b,Window c,Time d),(a,b,c,d),return) SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return) SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),) -SDL_X11_SYM(int,XSetWindowBackground,(Display* a,Window b,unsigned long c),(a,b,c),return) -SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display* a,Window b,Pixmap c),(a,b,c),return) -SDL_X11_SYM(int,XSetWindowColormap,(Display* a,Window b,Colormap c),(a,b,c),return) SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return) SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),) SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return) SDL_X11_SYM(int,XStoreColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return) SDL_X11_SYM(Status,XStringListToTextProperty,(char** a,int b,XTextProperty* c),(a,b,c),return) SDL_X11_SYM(int,XSync,(Display* a,Bool b),(a,b),return) +SDL_X11_SYM(int,XUndefineCursor,(Display* a,Window b),(a,b),return) SDL_X11_SYM(int,XUngrabKeyboard,(Display* a,Time b),(a,b),return) SDL_X11_SYM(int,XUngrabPointer,(Display* a,Time b),(a,b),return) SDL_X11_SYM(int,XUngrabServer,(Display* a),(a),return) @@ -156,11 +125,6 @@ SDL_X11_SYM(unsigned long,_XSetLastRequestRead,(Display* a,xGenericReply* b),(a, SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display* a,Bool b),(a,b),return) SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return) SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return) -SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return) -SDL_X11_SYM(int,XFillRectangle,(Display *dpy,Drawable d,GC gc,int x,int y,unsigned int width,unsigned int height),(dpy,d,gc,x,y,width,height),return) -SDL_X11_SYM(int,XSetBackground,(Display *dpy,GC gc,unsigned long background),(dpy,gc,background),return) -SDL_X11_SYM(Status,XInitImage,(XImage *image),(image),return) -SDL_X11_SYM(int,XSetClipMask,(Display *dpy,GC gc,Pixmap pixmap),(dpy,gc,pixmap),return) #if NeedWidePrototypes SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return) @@ -212,17 +176,21 @@ SDL_X11_SYM(int,ipAllocateData,(ChannelPtr a,IPCard b,IPDataPtr * c),(a,b,c),ret SDL_X11_SYM(int,ipUnallocateAndSendData,(ChannelPtr a,IPCard b),(a,b),return) #endif -/* Xrandr support. */ -#if SDL_VIDEO_DRIVER_X11_XRANDR -SDL_X11_MODULE(XRANDR) -SDL_X11_SYM(Status,XRRQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) -SDL_X11_SYM(XRRScreenConfiguration *,XRRGetScreenInfo,(Display *dpy,Drawable draw),(dpy,draw),return) -SDL_X11_SYM(SizeID,XRRConfigCurrentConfiguration,(XRRScreenConfiguration *config,Rotation *rotation),(config,rotation),return) -SDL_X11_SYM(short,XRRConfigCurrentRate,(XRRScreenConfiguration *config),(config),return) -SDL_X11_SYM(short *,XRRConfigRates,(XRRScreenConfiguration *config,int sizeID,int *nrates),(config,sizeID,nrates),return) -SDL_X11_SYM(XRRScreenSize *,XRRConfigSizes,(XRRScreenConfiguration *config,int *nsizes),(config,nsizes),return) -SDL_X11_SYM(Status,XRRSetScreenConfigAndRate,(Display *dpy,XRRScreenConfiguration *config,Drawable draw,int size_index,Rotation rotation,short rate,Time timestamp),(dpy,config,draw,size_index,rotation,rate,timestamp),return) -SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration *config),(config),) +/* XCursor support */ +#if SDL_VIDEO_DRIVER_X11_XCURSOR +SDL_X11_MODULE(XCURSOR) +SDL_X11_SYM(XcursorImage*,XcursorImageCreate,(int a,int b),(a,b),return) +SDL_X11_SYM(void,XcursorImageDestroy,(XcursorImage *a),(a),) +SDL_X11_SYM(Cursor,XcursorImageLoadCursor,(Display *a,const XcursorImage *b),(a,b),return) +#endif + +/* Xinerama support */ +#if SDL_VIDEO_DRIVER_X11_XINERAMA +SDL_X11_MODULE(XINERAMA) +SDL_X11_SYM(Bool,XineramaIsActive,(Display *a),(a),return) +SDL_X11_SYM(Bool,XineramaQueryExtension,(Display *a,int *b,int *c),(a,b,c),return) +SDL_X11_SYM(Status,XineramaQueryVersion,(Display *a,int *b,int *c),(a,b,c),return) +SDL_X11_SYM(XineramaScreenInfo*,XineramaQueryScreens,(Display *a, int *b),(a,b),return) #endif /* XInput support for multiple mice, tablets, etc. */ @@ -235,55 +203,42 @@ SDL_X11_SYM(XDevice*,XOpenDevice,(Display *a,XID b),(a,b),return) SDL_X11_SYM(int,XCloseDevice,(Display* a,XDevice* b),(a,b),return) #endif +/* XRandR support */ +#if SDL_VIDEO_DRIVER_X11_XRANDR +SDL_X11_MODULE(XRANDR) +SDL_X11_SYM(Status,XRRQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) +SDL_X11_SYM(XRRScreenConfiguration *,XRRGetScreenInfo,(Display *dpy,Drawable draw),(dpy,draw),return) +SDL_X11_SYM(SizeID,XRRConfigCurrentConfiguration,(XRRScreenConfiguration *config,Rotation *rotation),(config,rotation),return) +SDL_X11_SYM(short,XRRConfigCurrentRate,(XRRScreenConfiguration *config),(config),return) +SDL_X11_SYM(short *,XRRConfigRates,(XRRScreenConfiguration *config,int sizeID,int *nrates),(config,sizeID,nrates),return) +SDL_X11_SYM(XRRScreenSize *,XRRConfigSizes,(XRRScreenConfiguration *config,int *nsizes),(config,nsizes),return) +SDL_X11_SYM(Status,XRRSetScreenConfigAndRate,(Display *dpy,XRRScreenConfiguration *config,Drawable draw,int size_index,Rotation rotation,short rate,Time timestamp),(dpy,config,draw,size_index,rotation,rate,timestamp),return) +SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration *config),(config),) +#endif + /* MIT-SCREEN-SAVER support */ -#if SDL_VIDEO_DRIVER_X11_SCRNSAVER +#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER SDL_X11_MODULE(XSS) SDL_X11_SYM(Bool,XScreenSaverQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return) SDL_X11_SYM(Status,XScreenSaverQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) SDL_X11_SYM(void,XScreenSaverSuspend,(Display *dpy,Bool suspend),(dpy,suspend),return) #endif -/* XRender support */ -#if SDL_VIDEO_DRIVER_X11_XRENDER -SDL_X11_MODULE(XRENDER) -SDL_X11_SYM(Bool,XRenderQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return) -SDL_X11_SYM(Bool,XRenderQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return) -SDL_X11_SYM(XRenderPictFormat*,XRenderFindVisualFormat,(Display *dpy,_Xconst Visual *visual),(dpy,visual),return) -SDL_X11_SYM(XRenderPictFormat*,XRenderFindStandardFormat,(Display *dpy,int format),(dpy,format),return) -SDL_X11_SYM(XRenderPictFormat*,XRenderFindFormat,(Display *dpy,unsigned long mask,_Xconst XRenderPictFormat* templ,int count),(dpy,mask,templ,count),return) -SDL_X11_SYM(Picture,XRenderCreatePicture,(Display *dpy,Drawable drawable,_Xconst XRenderPictFormat* format,unsigned long valuemask,_Xconst XRenderPictureAttributes* attributes),(dpy,drawable,format,valuemask,attributes),return) -SDL_X11_SYM(void,XRenderFreePicture,(Display *dpy,Picture picture),(dpy,picture),return) -SDL_X11_SYM(void,XRenderChangePicture,(Display *dpy,Picture picture,unsigned long valuemask,_Xconst XRenderPictureAttributes* attributes),(dpy,picture,valuemask,attributes),return) -SDL_X11_SYM(void,XRenderComposite,(Display *dpy,int op,Picture src,Picture mask,Picture dst,int src_x,int src_y,int mask_x,int mask_y,int dst_x,int dst_y,unsigned int width,unsigned int height),(dpy,op,src,mask,dst,src_x,src_y,mask_x,mask_y,dst_x,dst_y,width,height),return) -SDL_X11_SYM(Picture,XRenderCreateSolidFill,(Display *dpy,const XRenderColor *color),(dpy,color),return) -SDL_X11_SYM(void,XRenderSetPictureTransform,(Display *dpy,Picture picture,XTransform *transform),(dpy,picture,transform),return) -SDL_X11_SYM(void,XRenderFillRectangle,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,int x,int y,unsigned int width,unsigned int height),(dpy,op,dst,color,x,y,width,height),return) -SDL_X11_SYM(void,XRenderFillRectangles,(Display *dpy,int op,Picture dst,_Xconst XRenderColor *color,_Xconst XRectangle *rectangles,int n_rects),(dpy,op,dst,color,rectangles,n_rects),return) -SDL_X11_SYM(void,XRenderSetPictureFilter,(Display *dpy,Picture picture,const char *filter,XFixed *params,int nparams),(dpy,picture,filter,params,nparams),return) -#endif - -#ifdef SDL_VIDEO_DRIVER_X11_XDAMAGE -SDL_X11_MODULE(XDAMAGE) -SDL_X11_SYM(Bool,XDamageQueryExtension,(Display *dpy,int *event_base_return,int *error_base_return),(dpy,event_base_return,error_base_return),return) -SDL_X11_SYM(Status,XDamageQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return) -SDL_X11_SYM(Damage,XDamageCreate,(Display *dpy,Drawable d,int level),(dpy,d,level),return) -SDL_X11_SYM(void,XDamageSubtract,(Display *dpy,Damage damage,XserverRegion repair,XserverRegion parts),(dpy,damage,repair,parts),return) -SDL_X11_SYM(void,XDamageDestroy,(Display *dpy,Damage damage),(dpy,damage),return) -#endif - -#ifdef SDL_VIDEO_DRIVER_X11_XFIXES -SDL_X11_MODULE(XFIXES) -SDL_X11_SYM(Bool,XFixesQueryExtension,(Display *dpy,int *event_base,int *error_base),(dpy,event_base,error_base),return) -SDL_X11_SYM(Status,XFixesQueryVersion,(Display *dpy,int *major,int *minor),(dpy,major,minor),return) -SDL_X11_SYM(void,XFixesSetGCClipRegion,(Display *dpy,GC gc,int clip_x,int clip_y,XserverRegion region),(dpy,gc,clip_x,clip_y,region),return) -SDL_X11_SYM(void,XFixesSetPictureClipRegion,(Display *dpy,XID picture,int clip_x,int clip_y,XserverRegion region),(dpy,picture,clip_x,clip_y,region),return) -#endif - #if SDL_VIDEO_DRIVER_X11_XSHAPE SDL_X11_MODULE(XSHAPE) SDL_X11_SYM(void,XShapeCombineMask,(Display *dpy,Window dest,int dest_kind,int x_off,int y_off,Pixmap src,int op),(dpy,dest,dest_kind,x_off,y_off,src,op),) #endif +#if SDL_VIDEO_DRIVER_X11_XVIDMODE +SDL_X11_MODULE(XVIDMODE) +SDL_X11_SYM(Bool,XF86VidModeGetAllModeLines,(Display *a,int b,int *c,XF86VidModeModeInfo ***d),(a,b,c,d),return) +SDL_X11_SYM(Bool,XF86VidModeGetModeLine,(Display *a,int b,int *c,XF86VidModeModeLine *d),(a,b,c,d),return) +SDL_X11_SYM(Bool,XF86VidModeGetViewPort,(Display *a,int b,int *c,int *d),(a,b,c,d),return) +SDL_X11_SYM(Bool,XF86VidModeQueryExtension,(Display *a,int *b,int *c),(a,b,c),return) +SDL_X11_SYM(Bool,XF86VidModeQueryVersion,(Display *a,int *b,int *c),(a,b,c),return) +SDL_X11_SYM(Bool,XF86VidModeSwitchToMode,(Display *a,int b,XF86VidModeModeInfo *c),(a,b,c),return) +#endif + /* *INDENT-ON* */ /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11touch.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11touch.c index 157d158d8..c9f65c783 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11touch.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11touch.c @@ -1,25 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_X11 + #include "SDL_x11video.h" #include "SDL_x11touch.h" #include "../../events/SDL_touch_c.h" @@ -34,65 +36,58 @@ void X11_InitTouch(_THIS) { #ifdef SDL_INPUT_LINUXEV - printf("Initializing touch...\n"); - FILE *fd; fd = fopen("/proc/bus/input/devices","r"); - - char c; + int i = 0; + int tsfd; char line[256]; char tstr[256]; int vendor = -1,product = -1,event = -1; while(!feof(fd)) { if(fgets(line,256,fd) <=0) continue; - //printf("%s",line); if(line[0] == '\n') { - if(vendor == 1386){ - printf("Wacom... Assuming it is a touch device\n"); - sprintf(tstr,"/dev/input/event%i",event); - printf("At location: %s\n",tstr); + if(vendor == 1386 || vendor==1) { - SDL_Touch touch; - touch.pressure_max = 0; - touch.pressure_min = 0; - touch.id = event; - + sprintf(tstr,"/dev/input/event%i",event); - touch.driverdata = SDL_malloc(sizeof(EventTouchData)); - EventTouchData* data = (EventTouchData*)(touch.driverdata); + tsfd = open( tstr, O_RDONLY | O_NONBLOCK ); + if ( tsfd == -1 ) + continue; /* Maybe not enough permissions ? */ - data->x = -1; - data->y = -1; - data->pressure = -1; - data->finger = 0; - data->up = SDL_FALSE; - + SDL_Touch touch; + touch.pressure_max = 0; + touch.pressure_min = 0; + touch.id = event; - printf("Opening device...\n"); - //printf("New Touch - DataPtr: %i\n",data); - data->eventStream = open(tstr, - O_RDONLY | O_NONBLOCK); - ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr); - printf ("Reading From : %s\n", tstr); + touch.driverdata = SDL_malloc(sizeof(EventTouchData)); + EventTouchData* data = (EventTouchData*)(touch.driverdata); + data->x = -1; + data->y = -1; + data->pressure = -1; + data->finger = 0; + data->up = SDL_FALSE; + data->down = SDL_FALSE; + data->eventStream = tsfd; + ioctl (data->eventStream, EVIOCGNAME (sizeof (tstr)), tstr); - int abs[5]; - ioctl(data->eventStream,EVIOCGABS(0),abs); - touch.x_min = abs[1]; - touch.x_max = abs[2]; - touch.native_xres = touch.x_max - touch.x_min; - ioctl(data->eventStream,EVIOCGABS(ABS_Y),abs); - touch.y_min = abs[1]; - touch.y_max = abs[2]; - touch.native_yres = touch.y_max - touch.y_min; - ioctl(data->eventStream,EVIOCGABS(ABS_PRESSURE),abs); - touch.pressure_min = abs[1]; - touch.pressure_max = abs[2]; - touch.native_pressureres = touch.pressure_max - touch.pressure_min; + int abs[5]; + ioctl(data->eventStream,EVIOCGABS(0),abs); + touch.x_min = abs[1]; + touch.x_max = abs[2]; + touch.native_xres = touch.x_max - touch.x_min; + ioctl(data->eventStream,EVIOCGABS(ABS_Y),abs); + touch.y_min = abs[1]; + touch.y_max = abs[2]; + touch.native_yres = touch.y_max - touch.y_min; + ioctl(data->eventStream,EVIOCGABS(ABS_PRESSURE),abs); + touch.pressure_min = abs[1]; + touch.pressure_max = abs[2]; + touch.native_pressureres = touch.pressure_max - touch.pressure_min; - SDL_AddTouch(&touch, tstr); + SDL_AddTouch(&touch, tstr); } vendor = -1; product = -1; @@ -101,21 +96,21 @@ X11_InitTouch(_THIS) else if(line[0] == 'I') { i = 1; while(line[i]) { - sscanf(&line[i],"Vendor=%x",&vendor); - sscanf(&line[i],"Product=%x",&product); - i++; + sscanf(&line[i],"Vendor=%x",&vendor); + sscanf(&line[i],"Product=%x",&product); + i++; } } else if(line[0] == 'H') { i = 1; while(line[i]) { - sscanf(&line[i],"event%d",&event); - i++; + sscanf(&line[i],"event%d",&event); + i++; } } } - - close(fd); + + fclose(fd); #endif } @@ -125,4 +120,6 @@ X11_QuitTouch(_THIS) SDL_TouchQuit(); } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11touch.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11touch.h index 72f15d748..476e1f02e 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11touch.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11touch.h @@ -1,37 +1,41 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef _SDL_x11touch_h #define _SDL_x11touch_h +/* +!!! FIXME: remove the evdev code; +!!! FIXME: this should be using XInput 2.1's new multitouch API. +*/ -//What should this be? +/* What should this be? */ #ifdef SDL_INPUT_LINUXEV typedef struct EventTouchData { - int x,y,pressure,finger; //Temporary Variables until sync + int x,y,pressure,finger; /* Temporary Variables until sync */ int eventStream; SDL_bool up; + SDL_bool down; } EventTouchData; #endif diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11video.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11video.c index ef6d8c4a9..ac97e63e6 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11video.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11video.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_X11 + #include /* For getpid() and readlink() */ #include "SDL_video.h" @@ -29,7 +30,7 @@ #include "../SDL_pixels_c.h" #include "SDL_x11video.h" -#include "SDL_x11render.h" +#include "SDL_x11framebuffer.h" #include "SDL_x11shape.h" #include "SDL_x11touch.h" @@ -186,8 +187,6 @@ X11_CreateDevice(int devindex) device->VideoQuit = X11_VideoQuit; device->GetDisplayModes = X11_GetDisplayModes; device->SetDisplayMode = X11_SetDisplayMode; - device->SetDisplayGammaRamp = X11_SetDisplayGammaRamp; - device->GetDisplayGammaRamp = X11_GetDisplayGammaRamp; device->SuspendScreenSaver = X11_SuspendScreenSaver; device->PumpEvents = X11_PumpEvents; @@ -203,13 +202,20 @@ X11_CreateDevice(int devindex) device->MaximizeWindow = X11_MaximizeWindow; device->MinimizeWindow = X11_MinimizeWindow; device->RestoreWindow = X11_RestoreWindow; + device->SetWindowFullscreen = X11_SetWindowFullscreen; + device->SetWindowGammaRamp = X11_SetWindowGammaRamp; device->SetWindowGrab = X11_SetWindowGrab; device->DestroyWindow = X11_DestroyWindow; + device->CreateWindowFramebuffer = X11_CreateWindowFramebuffer; + device->UpdateWindowFramebuffer = X11_UpdateWindowFramebuffer; + device->DestroyWindowFramebuffer = X11_DestroyWindowFramebuffer; device->GetWindowWMInfo = X11_GetWindowWMInfo; + device->shape_driver.CreateShaper = X11_CreateShaper; device->shape_driver.SetWindowShape = X11_SetWindowShape; device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape; -#ifdef SDL_VIDEO_OPENGL_GLX + +#if SDL_VIDEO_OPENGL_GLX device->GL_LoadLibrary = X11_GL_LoadLibrary; device->GL_GetProcAddress = X11_GL_GetProcAddress; device->GL_UnloadLibrary = X11_GL_UnloadLibrary; @@ -350,10 +356,6 @@ X11_VideoInit(_THIS) return -1; } -#if SDL_VIDEO_RENDER_X11 - X11_AddRenderDriver(_this); -#endif - if (X11_InitKeyboard(_this) != 0) { return -1; } @@ -386,10 +388,9 @@ X11_VideoQuit(_THIS) SDL_bool X11_UseDirectColorVisuals(void) { - /* Once we implement DirectColor colormaps and gamma ramp support... - return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE; - */ - return SDL_FALSE; + return SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ? SDL_FALSE : SDL_TRUE; } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vim: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11video.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11video.h index 5b936edca..042dccbe6 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11video.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11video.h @@ -1,68 +1,62 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" #ifndef _SDL_x11video_h #define _SDL_x11video_h +#include "SDL_keycode.h" + #include "../SDL_sysvideo.h" #include #include #include +#if SDL_VIDEO_DRIVER_X11_XCURSOR +#include +#endif #if SDL_VIDEO_DRIVER_X11_XINERAMA -#include "../Xext/extensions/Xinerama.h" -#endif -#if SDL_VIDEO_DRIVER_X11_XRANDR -#include -#endif -#if SDL_VIDEO_DRIVER_X11_VIDMODE -#include "../Xext/extensions/xf86vmode.h" +#include #endif #if SDL_VIDEO_DRIVER_X11_XINPUT #include #endif -#if SDL_VIDEO_DRIVER_X11_SCRNSAVER +#if SDL_VIDEO_DRIVER_X11_XRANDR +#include +#endif +#if SDL_VIDEO_DRIVER_X11_XSCRNSAVER #include #endif -#if SDL_VIDEO_DRIVER_X11_XRENDER -#include -#endif -#if SDL_VIDEO_DRIVER_X11_XDAMAGE -#include -#endif -#if SDL_VIDEO_DRIVER_X11_XFIXES -#include -#endif #if SDL_VIDEO_DRIVER_X11_XSHAPE #include #endif +#if SDL_VIDEO_DRIVER_X11_XVIDMODE +#include +#endif #include "SDL_x11dyn.h" #include "SDL_x11clipboard.h" #include "SDL_x11events.h" -#include "SDL_x11gamma.h" #include "SDL_x11keyboard.h" #include "SDL_x11modes.h" #include "SDL_x11mouse.h" @@ -96,7 +90,7 @@ typedef struct SDL_VideoData Atom _NET_WM_ICON; Atom UTF8_STRING; - SDL_scancode key_layout[256]; + SDL_Scancode key_layout[256]; SDL_bool selection_waiting; } SDL_VideoData; diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11window.c b/project/jni/sdl-1.3/src/video/x11/SDL_x11window.c index 8aac3d2d8..94664fa47 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11window.c +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11window.c @@ -1,26 +1,27 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" +#if SDL_VIDEO_DRIVER_X11 + #include "../SDL_sysvideo.h" #include "../SDL_pixels_c.h" #include "../../events/SDL_keyboard_c.h" @@ -28,9 +29,7 @@ #include "SDL_x11video.h" #include "SDL_x11mouse.h" -#include "SDL_x11gamma.h" #include "SDL_x11shape.h" -#include "../Xext/extensions/StdCmap.h" #ifdef SDL_VIDEO_DRIVER_PANDORA #include "SDL_x11opengles.h" @@ -87,31 +86,6 @@ X11_GetWMStateProperty(_THIS, SDL_Window * window, Atom atoms[3]) return count; } -static void -X11_GetDisplaySize(_THIS, SDL_Window * window, int *w, int *h) -{ - SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; - SDL_DisplayData *displaydata = - (SDL_DisplayData *) window->display->driverdata; - XWindowAttributes attr; - - XGetWindowAttributes(data->display, RootWindow(data->display, displaydata->screen), &attr); - if (window->flags & SDL_WINDOW_FULLSCREEN) { - /* The bounds when this window is visible is the fullscreen mode */ - SDL_DisplayMode fullscreen_mode; - if (SDL_GetWindowDisplayMode(window, &fullscreen_mode) == 0) { - attr.width = fullscreen_mode.w; - attr.height = fullscreen_mode.h; - } - } - if (w) { - *w = attr.width; - } - if (h) { - *h = attr.height; - } -} - static int SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) { @@ -176,6 +150,8 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) } else { window->flags &= ~SDL_WINDOW_SHOWN; } + data->visual = attrib.visual; + data->colormap = attrib.colormap; } { @@ -215,6 +191,21 @@ SetupWindowData(_THIS, SDL_Window * window, Window w, BOOL created) } } + { + Window FocalWindow; + int RevertTo=0; + XGetInputFocus(data->videodata->display, &FocalWindow, &RevertTo); + if (FocalWindow==w) + { + window->flags |= SDL_WINDOW_INPUT_FOCUS; + SDL_SetKeyboardFocus(data->window); + } + + if (window->flags & SDL_WINDOW_INPUT_GRABBED) { + /* Tell x11 to clip mouse */ + } + } + /* FIXME: How can I tell? { DWORD style = GetWindowLong(hwnd, GWL_STYLE); @@ -260,25 +251,21 @@ X11_CreateWindow(_THIS, SDL_Window * window) { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) window->display->driverdata; + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->display; int screen = displaydata->screen; Visual *visual; int depth; XSetWindowAttributes xattr; - int x, y; Window w; XSizeHints *sizehints; XWMHints *wmhints; XClassHint *classhints; - SDL_bool oldstyle_fullscreen; Atom _NET_WM_WINDOW_TYPE; Atom _NET_WM_WINDOW_TYPE_NORMAL; int wmstate_count; Atom wmstate_atoms[3]; - - /* ICCCM2.0-compliant window managers can handle fullscreen windows */ - oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); + Uint32 fevent = 0; #if SDL_VIDEO_DRIVER_X11_XINERAMA /* FIXME @@ -288,7 +275,7 @@ X11_CreateWindow(_THIS, SDL_Window * window) } */ #endif -#ifdef SDL_VIDEO_OPENGL_GLX +#if SDL_VIDEO_OPENGL_GLX if (window->flags & SDL_WINDOW_OPENGL) { XVisualInfo *vinfo; @@ -319,246 +306,94 @@ X11_CreateWindow(_THIS, SDL_Window * window) depth = displaydata->depth; } - if (oldstyle_fullscreen) { - xattr.override_redirect = True; - } else { - xattr.override_redirect = False; - } + xattr.override_redirect = False; xattr.background_pixel = 0; xattr.border_pixel = 0; - if (visual->class == PseudoColor) { - printf("asking for PseudoColor\n"); - -/* Status status; */ + if (visual->class == DirectColor) { XColor *colorcells; - Colormap colormap; - Sint32 pix; - Sint32 ncolors; - Sint32 nbits; - Sint32 rmax, gmax, bmax; - Sint32 rwidth, gwidth, bwidth; - Sint32 rmask, gmask, bmask; - Sint32 rshift, gshift, bshift; - Sint32 r, g, b; - - /* Is the colormap we need already registered in SDL? */ - if ((colormap = - X11_LookupColormap(display, screen, visual->visualid))) { - xattr.colormap = colormap; -/* printf("found existing colormap\n"); */ - } else { - /* The colormap is not known to SDL so we will create it */ - colormap = XCreateColormap(display, RootWindow(display, screen), - visual, AllocAll); -/* printf("colormap = %x\n", colormap); */ - - /* If we can't create a colormap, then we must die */ - if (!colormap) { - SDL_SetError - ("Couldn't create window: Could not create writable colormap"); - return -1; - } - - /* OK, we got a colormap, now fill it in as best as we can */ - - colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); - if (NULL == colorcells) { - SDL_SetError("out of memory in X11_CreateWindow"); - return -1; - } - - ncolors = visual->map_entries; - nbits = visual->bits_per_rgb; - -/* printf("ncolors = %d nbits = %d\n", ncolors, nbits); */ - - /* what if ncolors != (1 << nbits)? That can happen on a - true PseudoColor display. I'm assuming that we will - always have ncolors == (1 << nbits) */ - - /* I'm making a lot of assumptions here. */ - - /* Compute the width of each field. If there is one extra - bit, give it to green. If there are two extra bits give - them to red and greed. We can get extra bits when the - number of bits per pixel is not a multiple of 3. For - example when we have 16 bits per pixel and need a 5/6/5 - layout for the RGB fields */ - - rwidth = (nbits / 3) + (((nbits % 3) == 2) ? 1 : 0); - gwidth = (nbits / 3) + (((nbits % 3) >= 1) ? 1 : 0); - bwidth = (nbits / 3); - - rshift = gwidth + bwidth; - gshift = bwidth; - bshift = 0; - - rmax = 1 << rwidth; - gmax = 1 << gwidth; - bmax = 1 << bwidth; - - rmask = rmax - 1; - gmask = gmax - 1; - bmask = bmax - 1; - -/* printf("red mask = %4x shift = %4d width = %d\n", rmask, rshift, rwidth); */ -/* printf("green mask = %4x shift = %4d width = %d\n", gmask, gshift, gwidth); */ -/* printf("blue mask = %4x shift = %4d width = %d\n", bmask, bshift, bwidth); */ - - /* build the color table pixel values */ - pix = 0; - for (r = 0; r < rmax; r++) { - for (g = 0; g < gmax; g++) { - for (b = 0; b < bmax; b++) { - colorcells[pix].pixel = - (r << rshift) | (g << gshift) | (b << bshift); - colorcells[pix].red = (0xffff * r) / rmask; - colorcells[pix].green = (0xffff * g) / gmask; - colorcells[pix].blue = (0xffff * b) / bmask; -/* printf("%4x:%4x [%4x %4x %4x]\n", */ -/* pix, */ -/* colorcells[pix].pixel, */ -/* colorcells[pix].red, */ -/* colorcells[pix].green, */ -/* colorcells[pix].blue); */ - pix++; - } - } - } - -/* status = */ -/* XStoreColors(display, colormap, colorcells, ncolors); */ - - xattr.colormap = colormap; - X11_TrackColormap(display, screen, colormap, visual, NULL); - - SDL_free(colorcells); - } - } else if (visual->class == DirectColor) { - Status status; - XColor *colorcells; - Colormap colormap; int i; int ncolors; int rmax, gmax, bmax; int rmask, gmask, bmask; int rshift, gshift, bshift; - /* Is the colormap we need already registered in SDL? */ - if ((colormap = - X11_LookupColormap(display, screen, visual->visualid))) { - xattr.colormap = colormap; -/* printf("found existing colormap\n"); */ - } else { - /* The colormap is not known to SDL so we will create it */ - colormap = XCreateColormap(display, RootWindow(display, screen), - visual, AllocAll); -/* printf("colormap = %x\n", colormap); */ + xattr.colormap = + XCreateColormap(display, RootWindow(display, screen), + visual, AllocAll); - /* If we can't create a colormap, then we must die */ - if (!colormap) { - SDL_SetError - ("Couldn't create window: Could not create writable colormap"); - return -1; - } - - /* OK, we got a colormap, now fill it in as best as we can */ - colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); - if (NULL == colorcells) { - SDL_SetError("out of memory in X11_CreateWindow"); - return -1; - } - ncolors = visual->map_entries; - rmax = 0xffff; - gmax = 0xffff; - bmax = 0xffff; - - rshift = 0; - rmask = visual->red_mask; - while (0 == (rmask & 1)) { - rshift++; - rmask >>= 1; - } - -/* printf("rmask = %4x rshift = %4d\n", rmask, rshift); */ - - gshift = 0; - gmask = visual->green_mask; - while (0 == (gmask & 1)) { - gshift++; - gmask >>= 1; - } - -/* printf("gmask = %4x gshift = %4d\n", gmask, gshift); */ - - bshift = 0; - bmask = visual->blue_mask; - while (0 == (bmask & 1)) { - bshift++; - bmask >>= 1; - } - -/* printf("bmask = %4x bshift = %4d\n", bmask, bshift); */ - - /* build the color table pixel values */ - for (i = 0; i < ncolors; i++) { - Uint32 red = (rmax * i) / (ncolors - 1); - Uint32 green = (gmax * i) / (ncolors - 1); - Uint32 blue = (bmax * i) / (ncolors - 1); - - Uint32 rbits = (rmask * i) / (ncolors - 1); - Uint32 gbits = (gmask * i) / (ncolors - 1); - Uint32 bbits = (bmask * i) / (ncolors - 1); - - Uint32 pix = - (rbits << rshift) | (gbits << gshift) | (bbits << bshift); - - colorcells[i].pixel = pix; - - colorcells[i].red = red; - colorcells[i].green = green; - colorcells[i].blue = blue; - - colorcells[i].flags = DoRed | DoGreen | DoBlue; -/* printf("%2d:%4x [%4x %4x %4x]\n", i, pix, red, green, blue); */ - } - - status = - XStoreColors(display, colormap, colorcells, ncolors); - - xattr.colormap = colormap; - X11_TrackColormap(display, screen, colormap, visual, colorcells); - - SDL_free(colorcells); + /* If we can't create a colormap, then we must die */ + if (!xattr.colormap) { + SDL_SetError("Could not create writable colormap"); + return -1; } + + /* OK, we got a colormap, now fill it in as best as we can */ + colorcells = SDL_malloc(visual->map_entries * sizeof(XColor)); + if (!colorcells) { + SDL_OutOfMemory(); + return -1; + } + ncolors = visual->map_entries; + rmax = 0xffff; + gmax = 0xffff; + bmax = 0xffff; + + rshift = 0; + rmask = visual->red_mask; + while (0 == (rmask & 1)) { + rshift++; + rmask >>= 1; + } + + gshift = 0; + gmask = visual->green_mask; + while (0 == (gmask & 1)) { + gshift++; + gmask >>= 1; + } + + bshift = 0; + bmask = visual->blue_mask; + while (0 == (bmask & 1)) { + bshift++; + bmask >>= 1; + } + + /* build the color table pixel values */ + for (i = 0; i < ncolors; i++) { + Uint32 red = (rmax * i) / (ncolors - 1); + Uint32 green = (gmax * i) / (ncolors - 1); + Uint32 blue = (bmax * i) / (ncolors - 1); + + Uint32 rbits = (rmask * i) / (ncolors - 1); + Uint32 gbits = (gmask * i) / (ncolors - 1); + Uint32 bbits = (bmask * i) / (ncolors - 1); + + Uint32 pix = + (rbits << rshift) | (gbits << gshift) | (bbits << bshift); + + colorcells[i].pixel = pix; + + colorcells[i].red = red; + colorcells[i].green = green; + colorcells[i].blue = blue; + + colorcells[i].flags = DoRed | DoGreen | DoBlue; + } + + XStoreColors(display, xattr.colormap, colorcells, ncolors); + + SDL_free(colorcells); } else { xattr.colormap = XCreateColormap(display, RootWindow(display, screen), visual, AllocNone); } - if (oldstyle_fullscreen - || window->x == SDL_WINDOWPOS_CENTERED) { - X11_GetDisplaySize(_this, window, &x, NULL); - x = (x - window->w) / 2; - } else if (window->x == SDL_WINDOWPOS_UNDEFINED) { - x = 0; - } else { - x = window->x; - } - if (oldstyle_fullscreen - || window->y == SDL_WINDOWPOS_CENTERED) { - X11_GetDisplaySize(_this, window, NULL, &y); - y = (y - window->h) / 2; - } else if (window->y == SDL_WINDOWPOS_UNDEFINED) { - y = 0; - } else { - y = window->y; - } - - w = XCreateWindow(display, RootWindow(display, screen), x, y, - window->w, window->h, 0, depth, InputOutput, visual, + w = XCreateWindow(display, RootWindow(display, screen), + window->x, window->y, window->w, window->h, + 0, depth, InputOutput, visual, (CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap), &xattr); if (!w) { @@ -581,24 +416,19 @@ X11_CreateWindow(_THIS, SDL_Window * window) sizehints = XAllocSizeHints(); if (sizehints) { - if (!(window->flags & SDL_WINDOW_RESIZABLE) - || oldstyle_fullscreen) { + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { sizehints->min_width = sizehints->max_width = window->w; sizehints->min_height = sizehints->max_height = window->h; sizehints->flags = PMaxSize | PMinSize; } - if (!oldstyle_fullscreen - && window->x != SDL_WINDOWPOS_UNDEFINED - && window->y != SDL_WINDOWPOS_UNDEFINED) { - sizehints->x = x; - sizehints->y = y; - sizehints->flags |= USPosition; - } + sizehints->x = window->x; + sizehints->y = window->y; + sizehints->flags |= USPosition; XSetWMNormalHints(display, w, sizehints); XFree(sizehints); } - if ((window->flags & SDL_WINDOW_BORDERLESS) || oldstyle_fullscreen) { + if (window->flags & SDL_WINDOW_BORDERLESS) { SDL_bool set; Atom WM_HINTS; @@ -723,29 +553,23 @@ X11_CreateWindow(_THIS, SDL_Window * window) XDestroyWindow(display, w); return -1; } + #ifdef X_HAVE_UTF8_STRING - { - Uint32 fevent = 0; + if (SDL_X11_HAVE_UTF8) { pXGetICValues(((SDL_WindowData *) window->driverdata)->ic, XNFilterEvents, &fevent, NULL); - XSelectInput(display, w, - (FocusChangeMask | EnterWindowMask | LeaveWindowMask | - ExposureMask | ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | KeyPressMask | KeyReleaseMask | - PropertyChangeMask | StructureNotifyMask | - KeymapStateMask | fevent)); - } -#else - { - XSelectInput(display, w, - (FocusChangeMask | EnterWindowMask | LeaveWindowMask | - ExposureMask | ButtonPressMask | ButtonReleaseMask | - PointerMotionMask | KeyPressMask | KeyReleaseMask | - PropertyChangeMask | StructureNotifyMask | - KeymapStateMask)); } #endif + XSelectInput(display, w, + (FocusChangeMask | EnterWindowMask | LeaveWindowMask | + ExposureMask | ButtonPressMask | ButtonReleaseMask | + PointerMotionMask | KeyPressMask | KeyReleaseMask | + PropertyChangeMask | StructureNotifyMask | + KeymapStateMask | fevent)); + + XFlush(display); + return 0; } @@ -776,14 +600,14 @@ X11_GetWindowTitle(_THIS, Window xwindow) status = XGetWindowProperty(display, xwindow, data->_NET_WM_NAME, 0L, 8192L, False, data->UTF8_STRING, &real_type, &real_format, &items_read, &items_left, &propdata); - if (status == Success) { + if (status == Success && propdata) { title = SDL_strdup(SDL_static_cast(char*, propdata)); XFree(propdata); } else { status = XGetWindowProperty(display, xwindow, XA_WM_NAME, 0L, 8192L, False, XA_STRING, &real_type, &real_format, &items_read, &items_left, &propdata); - if (status == Success) { + if (status == Success && propdata) { title = SDL_iconv_string("UTF-8", "", SDL_static_cast(char*, propdata), items_read+1); } else { title = SDL_strdup(""); @@ -858,6 +682,7 @@ X11_SetWindowTitle(_THIS, SDL_Window * window) } #endif } + XFlush(display); } void @@ -874,8 +699,7 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) long *propdata; /* Convert the icon to ARGB for modern window managers */ - SDL_InitFormat(&format, 32, 0x00FF0000, 0x0000FF00, 0x000000FF, - 0xFF000000); + SDL_InitFormat(&format, SDL_PIXELFORMAT_ARGB8888); surface = SDL_ConvertSurface(icon, &format, 0); if (!surface) { return; @@ -906,6 +730,7 @@ X11_SetWindowIcon(_THIS, SDL_Window * window, SDL_Surface * icon) } else { XDeleteProperty(display, data->xwindow, _NET_WM_ICON); } + XFlush(display); } void @@ -913,27 +738,9 @@ X11_SetWindowPosition(_THIS, SDL_Window * window) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; Display *display = data->videodata->display; - SDL_bool oldstyle_fullscreen; - int x, y; - /* ICCCM2.0-compliant window managers can handle fullscreen windows */ - oldstyle_fullscreen = X11_IsWindowOldFullscreen(_this, window); - - if (oldstyle_fullscreen - || window->x == SDL_WINDOWPOS_CENTERED) { - X11_GetDisplaySize(_this, window, &x, NULL); - x = (x - window->w) / 2; - } else { - x = window->x; - } - if (oldstyle_fullscreen - || window->y == SDL_WINDOWPOS_CENTERED) { - X11_GetDisplaySize(_this, window, NULL, &y); - y = (y - window->h) / 2; - } else { - y = window->y; - } - XMoveWindow(display, data->xwindow, x, y); + XMoveWindow(display, data->xwindow, window->x, window->y); + XFlush(display); } void @@ -944,7 +751,23 @@ X11_SetWindowSize(_THIS, SDL_Window * window) if (SDL_IsShapedWindow(window)) X11_ResizeWindowShape(window); - XResizeWindow(display, data->xwindow, window->w, window->h); + if (!(window->flags & SDL_WINDOW_RESIZABLE)) { + /* Apparently, if the X11 Window is set to a 'non-resizable' window, you cannot resize it using the XResizeWindow, thus + we must set the size hints to adjust the window size.*/ + XSizeHints *sizehints = XAllocSizeHints(); + long userhints; + + XGetWMNormalHints(display, data->xwindow, sizehints, &userhints); + + sizehints->min_width = sizehints->max_height = window->w; + sizehints->min_height = sizehints->max_height = window->h; + + XSetWMNormalHints(display, data->xwindow, sizehints); + + XFree(sizehints); + } else + XResizeWindow(display, data->xwindow, window->w, window->h); + XFlush(display); } void @@ -954,6 +777,7 @@ X11_ShowWindow(_THIS, SDL_Window * window) Display *display = data->videodata->display; XMapRaised(display, data->xwindow); + XFlush(display); } void @@ -963,6 +787,7 @@ X11_HideWindow(_THIS, SDL_Window * window) Display *display = data->videodata->display; XUnmapWindow(display, data->xwindow); + XFlush(display); } void @@ -972,14 +797,15 @@ X11_RaiseWindow(_THIS, SDL_Window * window) Display *display = data->videodata->display; XRaiseWindow(display, data->xwindow); + XFlush(display); } static void -X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) +SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) window->display->driverdata; + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT; @@ -1020,12 +846,13 @@ X11_SetWindowMaximized(_THIS, SDL_Window * window, SDL_bool maximized) XDeleteProperty(display, data->xwindow, _NET_WM_STATE); } } + XFlush(display); } void X11_MaximizeWindow(_THIS, SDL_Window * window) { - X11_SetWindowMaximized(_this, window, SDL_TRUE); + SetWindowMaximized(_this, window, SDL_TRUE); } void @@ -1033,19 +860,136 @@ X11_MinimizeWindow(_THIS, SDL_Window * window) { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) window->display->driverdata; + (SDL_DisplayData *) SDL_GetDisplayForWindow(window)->driverdata; Display *display = data->videodata->display; XIconifyWindow(display, data->xwindow, displaydata->screen); + XFlush(display); } void X11_RestoreWindow(_THIS, SDL_Window * window) { - X11_SetWindowMaximized(_this, window, SDL_FALSE); + SetWindowMaximized(_this, window, SDL_FALSE); X11_ShowWindow(_this, window); } +void +X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * _display, SDL_bool fullscreen) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + SDL_DisplayData *displaydata = (SDL_DisplayData *) _display->driverdata; + Display *display = data->videodata->display; + Atom _NET_WM_STATE = data->videodata->_NET_WM_STATE; + Atom _NET_WM_STATE_MAXIMIZED_VERT = data->videodata->_NET_WM_STATE_MAXIMIZED_VERT; + Atom _NET_WM_STATE_MAXIMIZED_HORZ = data->videodata->_NET_WM_STATE_MAXIMIZED_HORZ; + Atom _NET_WM_STATE_FULLSCREEN = data->videodata->_NET_WM_STATE_FULLSCREEN; + + if (X11_IsWindowMapped(_this, window)) { + XEvent e; + + SDL_zero(e); + e.xany.type = ClientMessage; + e.xclient.message_type = _NET_WM_STATE; + e.xclient.format = 32; + e.xclient.window = data->xwindow; + e.xclient.data.l[0] = + fullscreen ? _NET_WM_STATE_ADD : _NET_WM_STATE_REMOVE; + e.xclient.data.l[1] = _NET_WM_STATE_FULLSCREEN; + e.xclient.data.l[3] = 0l; + + XSendEvent(display, RootWindow(display, displaydata->screen), 0, + SubstructureNotifyMask | SubstructureRedirectMask, &e); + } else { + int count = 0; + Atom atoms[3]; + + if (fullscreen) { + atoms[count++] = _NET_WM_STATE_FULLSCREEN; + } + if (window->flags & SDL_WINDOW_MAXIMIZED) { + atoms[count++] = _NET_WM_STATE_MAXIMIZED_VERT; + atoms[count++] = _NET_WM_STATE_MAXIMIZED_HORZ; + } + if (count > 0) { + XChangeProperty(display, data->xwindow, _NET_WM_STATE, XA_ATOM, 32, + PropModeReplace, (unsigned char *)atoms, count); + } else { + XDeleteProperty(display, data->xwindow, _NET_WM_STATE); + } + } + XFlush(display); +} + +int +X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + Visual *visual = data->visual; + Colormap colormap = data->colormap; + XColor *colorcells; + int ncolors; + int rmask, gmask, bmask; + int rshift, gshift, bshift; + int i; + + if (visual->class != DirectColor) { + SDL_SetError("Window doesn't have DirectColor visual"); + return -1; + } + + ncolors = visual->map_entries; + colorcells = SDL_malloc(ncolors * sizeof(XColor)); + if (!colorcells) { + SDL_OutOfMemory(); + return -1; + } + + rshift = 0; + rmask = visual->red_mask; + while (0 == (rmask & 1)) { + rshift++; + rmask >>= 1; + } + + gshift = 0; + gmask = visual->green_mask; + while (0 == (gmask & 1)) { + gshift++; + gmask >>= 1; + } + + bshift = 0; + bmask = visual->blue_mask; + while (0 == (bmask & 1)) { + bshift++; + bmask >>= 1; + } + + /* build the color table pixel values */ + for (i = 0; i < ncolors; i++) { + Uint32 rbits = (rmask * i) / (ncolors - 1); + Uint32 gbits = (gmask * i) / (ncolors - 1); + Uint32 bbits = (bmask * i) / (ncolors - 1); + Uint32 pix = (rbits << rshift) | (gbits << gshift) | (bbits << bshift); + + colorcells[i].pixel = pix; + + colorcells[i].red = ramp[(0 * 256) + i]; + colorcells[i].green = ramp[(1 * 256) + i]; + colorcells[i].blue = ramp[(2 * 256) + i]; + + colorcells[i].flags = DoRed | DoGreen | DoBlue; + } + + XStoreColors(display, colormap, colorcells, ncolors); + XFlush(display); + SDL_free(colorcells); + + return 0; +} + void X11_SetWindowGrab(_THIS, SDL_Window * window) { @@ -1111,6 +1055,7 @@ X11_DestroyWindow(_THIS, SDL_Window * window) #endif if (data->created) { XDestroyWindow(display, data->xwindow); + XFlush(display); } SDL_free(data); } @@ -1125,8 +1070,8 @@ X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) if (info->version.major == SDL_MAJOR_VERSION && info->version.minor == SDL_MINOR_VERSION) { info->subsystem = SDL_SYSWM_X11; - info->x11.display = display; - info->x11.window = data->xwindow; + info->info.x11.display = display; + info->info.x11.window = data->xwindow; return SDL_TRUE; } else { SDL_SetError("Application not compiled with SDL %d.%d\n", @@ -1135,4 +1080,6 @@ X11_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info) } } +#endif /* SDL_VIDEO_DRIVER_X11 */ + /* vi: set ts=4 sw=4 expandtab: */ diff --git a/project/jni/sdl-1.3/src/video/x11/SDL_x11window.h b/project/jni/sdl-1.3/src/video/x11/SDL_x11window.h index 06d2c268d..97b4d99d7 100644 --- a/project/jni/sdl-1.3/src/video/x11/SDL_x11window.h +++ b/project/jni/sdl-1.3/src/video/x11/SDL_x11window.h @@ -1,23 +1,22 @@ /* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2010 Sam Lantinga + Simple DirectMedia Layer + Copyright (C) 1997-2011 Sam Lantinga - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. */ #include "SDL_config.h" @@ -28,6 +27,15 @@ typedef struct { SDL_Window *window; Window xwindow; + Visual *visual; + Colormap colormap; +#ifndef NO_SHARED_MEMORY + /* MIT shared memory extension information */ + SDL_bool use_mitshm; + XShmSegmentInfo shminfo; +#endif + XImage *ximage; + GC gc; XIC ic; SDL_bool created; struct SDL_VideoData *videodata; @@ -46,6 +54,8 @@ extern void X11_RaiseWindow(_THIS, SDL_Window * window); extern void X11_MaximizeWindow(_THIS, SDL_Window * window); extern void X11_MinimizeWindow(_THIS, SDL_Window * window); extern void X11_RestoreWindow(_THIS, SDL_Window * window); +extern void X11_SetWindowFullscreen(_THIS, SDL_Window * window, SDL_VideoDisplay * display, SDL_bool fullscreen); +extern int X11_SetWindowGammaRamp(_THIS, SDL_Window * window, const Uint16 * ramp); extern void X11_SetWindowGrab(_THIS, SDL_Window * window); extern void X11_DestroyWindow(_THIS, SDL_Window * window); extern SDL_bool X11_GetWindowWMInfo(_THIS, SDL_Window * window, diff --git a/project/jni/sdl-1.3/src/video/x11/imKStoUCS.c b/project/jni/sdl-1.3/src/video/x11/imKStoUCS.c index c17a1b304..5dd6b1ddd 100644 --- a/project/jni/sdl-1.3/src/video/x11/imKStoUCS.c +++ b/project/jni/sdl-1.3/src/video/x11/imKStoUCS.c @@ -22,6 +22,9 @@ be used in advertising or otherwise to promote the sale, use or other deal- ings in this Software without prior written authorization from the XFree86 Project. */ +#include "SDL_config.h" + +#if SDL_VIDEO_DRIVER_X11 /* $XFree86: xc/lib/X11/imKStoUCS.c,v 1.4 2003/04/29 11:29:18 pascal Exp $ */ @@ -343,3 +346,5 @@ X11_KeySymToUcs4(KeySym keysym) else return 0; } + +#endif /* SDL_VIDEO_DRIVER_X11 */