Force SW video mode in SDL_SetVideoMode() if enabled in AndroidAppSettings.cfg

This commit is contained in:
pelya
2012-08-06 17:05:40 +03:00
parent e8634e343b
commit 5c720fb3d9
11 changed files with 35 additions and 51 deletions

View File

@@ -870,7 +870,7 @@ mv -f project/src/Globals.java.1 project/src/Globals.java
echo Patching project/jni/Settings.mk echo Patching project/jni/Settings.mk
echo '# DO NOT EDIT THIS FILE - it is automatically generated, edit file SettingsTemplate.mk' > project/jni/Settings.mk echo '# DO NOT EDIT THIS FILE - it is automatically generated, edit file SettingsTemplate.mk' > project/jni/Settings.mk
cat project/jni/SettingsTemplate.mk | \ cat project/jni/SettingsTemplate.mk | \
sed "s/APP_MODULES := .*/APP_MODULES := application sdl-$LibSdlVersion sdl_main stlport jpeg png ogg flac vorbis freetype stdout-test $CompiledLibraries/" | \ sed "s/APP_MODULES := .*/APP_MODULES := application sdl-$LibSdlVersion sdl_main stlport jpeg png ogg flac vorbis freetype $CompiledLibraries/" | \
sed "s/APP_ABI := .*/APP_ABI := $MultiABI/" | \ sed "s/APP_ABI := .*/APP_ABI := $MultiABI/" | \
sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \ sed "s/SDL_JAVA_PACKAGE_PATH := .*/SDL_JAVA_PACKAGE_PATH := $AppFullNameUnderscored/" | \
sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \ sed "s^SDL_CURDIR_PATH := .*^SDL_CURDIR_PATH := $DataPath^" | \
@@ -905,7 +905,6 @@ rm -rf project/$OUT/local/*/libsdl_*.so
rm -rf project/$OUT/local/*/objs*/sdl-*/src/*/android rm -rf project/$OUT/local/*/objs*/sdl-*/src/*/android
rm -rf project/$OUT/local/*/objs*/sdl-*/src/video/SDL_video.o rm -rf project/$OUT/local/*/objs*/sdl-*/src/video/SDL_video.o
rm -rf project/$OUT/local/*/objs*/sdl-*/SDL_renderer_gles.o rm -rf project/$OUT/local/*/objs*/sdl-*/SDL_renderer_gles.o
rm -rf project/$OUT/local/*/libsdl_fake_stdout.a project/$OUT/local/*/objs*/sdl_fake_stdout/*
rm -rf project/$OUT/local/*/objs*/sdl_* rm -rf project/$OUT/local/*/objs*/sdl_*
# Do not rebuild several huge libraries that do not depend on SDL version # Do not rebuild several huge libraries that do not depend on SDL version
for LIB in freetype intl jpeg png lua mad stlport tremor xerces xml2; do for LIB in freetype intl jpeg png lua mad stlport tremor xerces xml2; do
@@ -924,7 +923,6 @@ rm -f project/assets/*
if [ -d "project/jni/application/src/AndroidData" ] ; then if [ -d "project/jni/application/src/AndroidData" ] ; then
echo Copying asset files echo Copying asset files
cp project/jni/application/src/AndroidData/* project/assets/ cp project/jni/application/src/AndroidData/* project/assets/
ln -s ../libs/armeabi/stdout-test project/assets/
for F in project/assets/*; do for F in project/assets/*; do
if [ `cat $F | wc -c` -gt 1000000 ] ; then if [ `cat $F | wc -c` -gt 1000000 ] ; then
echo "The file $F is bigger than 1 megabyte - splitting it into smaller chunks" echo "The file $F is bigger than 1 megabyte - splitting it into smaller chunks"

View File

@@ -2417,6 +2417,8 @@ class Settings
Globals.SwVideoMode = true; Globals.SwVideoMode = true;
nativeSetCompatibilityHacks(); nativeSetCompatibilityHacks();
} }
if( Globals.SwVideoMode )
nativeSetVideoForceSoftwareMode();
if( Globals.SwVideoMode && Globals.MultiThreadedVideo ) if( Globals.SwVideoMode && Globals.MultiThreadedVideo )
nativeSetVideoMultithreaded(); nativeSetVideoMultithreaded();
if( Globals.PhoneHasTrackball ) if( Globals.PhoneHasTrackball )
@@ -2557,6 +2559,7 @@ class Settings
private static native void nativeSetVideoDepth(int bpp, int gles2); private static native void nativeSetVideoDepth(int bpp, int gles2);
private static native void nativeSetCompatibilityHacks(); private static native void nativeSetCompatibilityHacks();
private static native void nativeSetVideoMultithreaded(); private static native void nativeSetVideoMultithreaded();
private static native void nativeSetVideoForceSoftwareMode();
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency); private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);
private static native void nativeSetupScreenKeyboardButtons(byte[] img); private static native void nativeSetupScreenKeyboardButtons(byte[] img);
private static native void nativeInitKeymap(); private static native void nativeInitKeymap();

View File

@@ -3,7 +3,7 @@
APP_MODULES := application sdl-1.2 sdl_main stlport jpeg png ogg flac vorbis freetype tremor ogg APP_MODULES := application sdl-1.2 sdl_main stlport jpeg png ogg flac vorbis freetype tremor ogg
# To filter out static libs from all libs in makefile # To filter out static libs from all libs in makefile
APP_AVAILABLE_STATIC_LIBS := jpeg png tremor freetype xerces ogg tremor vorbis flac sdl_fake_stdout boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread APP_AVAILABLE_STATIC_LIBS := jpeg png tremor freetype xerces ogg tremor vorbis flac boost_date_time boost_filesystem boost_iostreams boost_program_options boost_regex boost_signals boost_system boost_thread
APP_ABI := armeabi APP_ABI := armeabi

View File

@@ -9,8 +9,6 @@
* software, or work derived from it, under other terms. * software, or work derived from it, under other terms.
*/ */
#include <sstream>
#include <iostream>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <math.h> #include <math.h>
@@ -25,7 +23,7 @@
----------------------------------------------------------*/ ----------------------------------------------------------*/
#define SCREEN_W 320 #define SCREEN_W 320
#define SCREEN_H 240 #define SCREEN_H 200
#define BALLS 300 #define BALLS 300
@@ -411,12 +409,6 @@ void tiled_back(SDL_Surface *back, SDL_Surface *screen, int xo, int yo)
main() main()
----------------------------------------------------------*/ ----------------------------------------------------------*/
extern "C" void unaligned_test(unsigned * data, unsigned * target);
extern "C" unsigned val0, val1, val2, val3, val4;
unsigned val0 = 0x01234567, val1, val2, val3;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
ballfield_t *balls; ballfield_t *balls;
@@ -425,7 +417,7 @@ int main(int argc, char* argv[])
SDL_Surface *back, *logo, *font, *font_hex; SDL_Surface *back, *logo, *font, *font_hex;
SDL_Event event; SDL_Event event;
int bpp = 16, int bpp = 16,
flags = 0, flags = SDL_HWSURFACE,
alpha = 1; alpha = 1;
int x_offs = 0, y_offs = 0; int x_offs = 0, y_offs = 0;
long tick, long tick,
@@ -677,8 +669,5 @@ int main(int argc, char* argv[])
SDL_FreeSurface(back); SDL_FreeSurface(back);
SDL_FreeSurface(logo); SDL_FreeSurface(logo);
SDL_FreeSurface(font); SDL_FreeSurface(font);
std::ostringstream os; return 0;
os << "lalala" << std::endl << "more text" << std::endl;
std::cout << os.str() << std::endl << "text text" << std::endl;
exit(0);
} }

View File

@@ -307,6 +307,15 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
return NULL; return NULL;
} }
if( SDL_ANDROID_VideoForceSoftwareMode )
{
if( flags & SDL_HWSURFACE )
__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): application requested hardware video mode - forcing software video mode");
if( flags & SDL_OPENGL )
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: application requested OpenGL context - SDL will ignore this. Set SwVideoMode=n inside AndroidAppSettings.cfg to enable OpenGL inside SDL.");
flags = (flags & SDL_FULLSCREEN) | (flags & SDL_DOUBLEBUF);
}
sdl_opengl = (flags & SDL_OPENGL) ? 1 : 0; sdl_opengl = (flags & SDL_OPENGL) ? 1 : 0;
SDL_ANDROID_sFakeWindowWidth = width; SDL_ANDROID_sFakeWindowWidth = width;
@@ -456,7 +465,13 @@ static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface)
} }
if ( ! (surface->w && surface->h) ) if ( ! (surface->w && surface->h) )
return(-1); return -1;
if( SDL_ANDROID_VideoForceSoftwareMode )
{
//__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): ignoring application attempt to allocate HW surface");
return -1;
}
DEBUGOUT("ANDROID_AllocHWSurface() surface %p w %d h %d", surface, surface->w, surface->h); DEBUGOUT("ANDROID_AllocHWSurface() surface %p w %d h %d", surface, surface->w, surface->h);
Uint32 format = PixelFormatEnumColorkey; // 1-bit alpha for color key, every surface will have colorkey so it's easier for us Uint32 format = PixelFormatEnumColorkey; // 1-bit alpha for color key, every surface will have colorkey so it's easier for us
@@ -514,7 +529,6 @@ static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface)
surface->flags |= SDL_HWSURFACE | SDL_HWACCEL; surface->flags |= SDL_HWSURFACE | SDL_HWACCEL;
HwSurfaceCount++; HwSurfaceCount++;
DEBUGOUT("ANDROID_AllocHWSurface() in HwSurfaceCount %d HwSurfaceList %p", HwSurfaceCount, HwSurfaceList); DEBUGOUT("ANDROID_AllocHWSurface() in HwSurfaceCount %d HwSurfaceList %p", HwSurfaceCount, HwSurfaceList);
HwSurfaceList = SDL_realloc( HwSurfaceList, HwSurfaceCount * sizeof(SDL_Surface *) ); HwSurfaceList = SDL_realloc( HwSurfaceList, HwSurfaceCount * sizeof(SDL_Surface *) );
@@ -554,10 +568,8 @@ static void ANDROID_FreeHWSurface(_THIS, SDL_Surface *surface)
} }
} }
if( i != -1 ) if( i != -1 )
{
SDL_SetError("ANDROID_FreeHWSurface: cannot find freed HW surface in HwSurfaceList array"); SDL_SetError("ANDROID_FreeHWSurface: cannot find freed HW surface in HwSurfaceList array");
} }
}
static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface) static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
{ {

View File

@@ -67,6 +67,7 @@ static const char * showScreenKeyboardOldText = "";
static int showScreenKeyboardSendBackspace = 0; static int showScreenKeyboardSendBackspace = 0;
int SDL_ANDROID_SmoothVideo = 0; int SDL_ANDROID_SmoothVideo = 0;
int SDL_ANDROID_VideoMultithreaded = 0; int SDL_ANDROID_VideoMultithreaded = 0;
int SDL_ANDROID_VideoForceSoftwareMode = 0;
int SDL_ANDROID_CompatibilityHacks = 0; int SDL_ANDROID_CompatibilityHacks = 0;
int SDL_ANDROID_BYTESPERPIXEL = 2; int SDL_ANDROID_BYTESPERPIXEL = 2;
int SDL_ANDROID_BITSPERPIXEL = 16; int SDL_ANDROID_BITSPERPIXEL = 16;
@@ -324,6 +325,12 @@ JAVA_EXPORT_NAME(Settings_nativeSetVideoMultithreaded) (JNIEnv* env, jobject thi
SDL_ANDROID_VideoMultithreaded = 1; SDL_ANDROID_VideoMultithreaded = 1;
} }
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetVideoForceSoftwareMode) (JNIEnv* env, jobject thiz)
{
SDL_ANDROID_VideoForceSoftwareMode = 1;
}
JNIEXPORT void JNICALL JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetCompatibilityHacks) (JNIEnv* env, jobject thiz) JAVA_EXPORT_NAME(Settings_nativeSetCompatibilityHacks) (JNIEnv* env, jobject thiz)
{ {

View File

@@ -42,6 +42,7 @@ extern int SDL_ANDROID_TouchscreenCalibrationX;
extern int SDL_ANDROID_TouchscreenCalibrationY; extern int SDL_ANDROID_TouchscreenCalibrationY;
extern int SDL_ANDROID_SmoothVideo; extern int SDL_ANDROID_SmoothVideo;
extern int SDL_ANDROID_VideoMultithreaded; extern int SDL_ANDROID_VideoMultithreaded;
extern int SDL_ANDROID_VideoForceSoftwareMode;
extern int SDL_ANDROID_CompatibilityHacks; extern int SDL_ANDROID_CompatibilityHacks;
extern int SDL_ANDROID_ShowMouseCursor; extern int SDL_ANDROID_ShowMouseCursor;
extern int SDL_ANDROID_UseGles2; extern int SDL_ANDROID_UseGles2;

View File

@@ -1,8 +0,0 @@
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := stdout-test
LOCAL_SRC_FILES = stdout-test.c
include $(BUILD_EXECUTABLE)

View File

@@ -1,18 +0,0 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
extern int main(int argc, char *argv[]);
int main(int argc, char *argv[])
{
// Numerous Telechips devices will crash this simple Posix-compatibility test
printf("printf()\n");
fprintf(stdout, "fprintf(stdout)\n");
fflush(stdout);
fprintf(stderr, "fprintf(stderr)\n");
fflush(stderr);
write(STDOUT_FILENO, "write(1)\n", strlen("write(1)\n"));
write(STDERR_FILENO, "write(2)\n", strlen("write(2)\n"));
return 42;
}