Option to use SDL_UpdateRects optimization, updated XServer

This commit is contained in:
Sergii Pylypenko
2013-11-07 21:10:27 +02:00
parent bbb31b47e7
commit 185def5931
11 changed files with 69 additions and 21 deletions

View File

@@ -839,6 +839,10 @@ echo >> AndroidAppSettings.cfg
echo "# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL" >> AndroidAppSettings.cfg
echo CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# Application uses SDL_UpdateRects() properly, and does not draw in any region outside those rects." >> AndroidAppSettings.cfg
echo "# This improves drawing speed, but I know only one application that does that, and it's written by me (y)/(n)" >> AndroidAppSettings.cfg
echo CompatibilityHacksProperUsageOfSDL_UpdateRects=$CompatibilityHacksProperUsageOfSDL_UpdateRects >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
echo "# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user" >> AndroidAppSettings.cfg
echo AppUsesMouse=$AppUsesMouse >> AndroidAppSettings.cfg
echo >> AndroidAppSettings.cfg
@@ -1101,6 +1105,12 @@ else
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
fi
if [ "$CompatibilityHacksProperUsageOfSDL_UpdateRects" = "y" ]; then
CompatibilityHacksProperUsageOfSDL_UpdateRects=-DSDL_COMPATIBILITY_HACKS_PROPER_USADE_OF_SDL_UPDATERECTS=1
else
CompatibilityHacksProperUsageOfSDL_UpdateRects=
fi
if [ "$AppUsesMouse" = "y" ] ; then
AppUsesMouse=true
else
@@ -1378,7 +1388,15 @@ cat project/jni/SettingsTemplate.mk | \
sed "s^APPLICATION_ADDITIONAL_CFLAGS :=.*^APPLICATION_ADDITIONAL_CFLAGS := $AppCflags^" | \
sed "s^APPLICATION_ADDITIONAL_LDFLAGS :=.*^APPLICATION_ADDITIONAL_LDFLAGS := $AppLdflags^" | \
sed "s^APPLICATION_OVERLAPS_SYSTEM_HEADERS :=.*^APPLICATION_OVERLAPS_SYSTEM_HEADERS := $AppOverlapsSystemHeaders^" | \
sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := $RedefinedKeycodes $RedefinedKeycodesScreenKb $RedefinedKeycodesGamepad $CompatibilityHacksPreventAudioChopping $CompatibilityHacksAppIgnoresAudioBufferSize $CompatibilityHacksSlowCompatibleEventQueue $CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState^" | \
sed "s^SDL_ADDITIONAL_CFLAGS :=.*^SDL_ADDITIONAL_CFLAGS := \
$RedefinedKeycodes \
$RedefinedKeycodesScreenKb \
$RedefinedKeycodesGamepad \
$CompatibilityHacksPreventAudioChopping \
$CompatibilityHacksAppIgnoresAudioBufferSize \
$CompatibilityHacksSlowCompatibleEventQueue \
$CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState \
$CompatibilityHacksProperUsageOfSDL_UpdateRects^" | \
sed "s^APPLICATION_SUBDIRS_BUILD :=.*^APPLICATION_SUBDIRS_BUILD := $AppSubdirsBuild^" | \
sed "s^APPLICATION_BUILD_EXCLUDE :=.*^APPLICATION_BUILD_EXCLUDE := $AppBuildExclude^" | \
sed "s^APPLICATION_CUSTOM_BUILD_SCRIPT :=.*^APPLICATION_CUSTOM_BUILD_SCRIPT := $CustomBuildScript^" | \

View File

@@ -75,6 +75,8 @@ CompatibilityHacksSlowCompatibleEventQueue=n
# Save and restore OpenGL state when drawing on-screen keyboard for apps that use SDL_OPENGL
CompatibilityHacksTouchscreenKeyboardSaveRestoreOpenGLState=
CompatibilityHacksProperUsageOfSDL_UpdateRects=y
# Application uses mouse (y) or (n), this will show mouse emulation dialog to the user
AppUsesMouse=y

View File

@@ -247,7 +247,7 @@ void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, i
*displayH = *displayH * (dpiScale / fontsVal[dpi]);
}
void XSDL_generateHelp(const char * port)
void XSDL_generateBackground(const char * port, int showHelp)
{
int sd, addr, ifc_num, i;
struct ifconf ifc;
@@ -255,10 +255,19 @@ void XSDL_generateHelp(const char * port)
SDL_Surface * surf;
int y = 40;
surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VID_X, VID_Y, 24, 0x0000ff, 0x00ff00, 0xff0000, 0);
SDL_FillRect(surf, NULL, 0xffffff);
if( !showHelp )
{
surf = SDL_CreateRGBSurface(SDL_SWSURFACE, 16, 16, 24, 0x0000ff, 0x00ff00, 0xff0000, 0);
SDL_FillRect(surf, NULL, 0x00003f);
SDL_SaveBMP(surf, "background.bmp");
SDL_FreeSurface(surf);
return;
}
renderStringColor("Launch these commands on your Linux PC:", VID_X/2, 15, 0, 0, 0, surf);
surf = SDL_CreateRGBSurface(SDL_SWSURFACE, VID_X, VID_Y, 24, 0x0000ff, 0x00ff00, 0xff0000, 0);
SDL_FillRect(surf, NULL, 0x00003f);
renderStringColor("Launch these commands on your Linux PC:", VID_X/2, 15, 255, 255, 255, surf);
sd = socket(PF_INET, SOCK_DGRAM, 0);
if (sd > 0)
@@ -288,10 +297,10 @@ void XSDL_generateHelp(const char * port)
if (strcmp(saddr, "127.0.0.1") == 0)
continue;
sprintf (msg, "env DISPLAY=%s%s metacity &", saddr, port);
renderStringColor(msg, VID_X/2, y, 0, 0, 0, surf);
renderStringColor(msg, VID_X/2, y, 255, 255, 255, surf);
y += 15;
sprintf (msg, "env DISPLAY=%s%s gimp", saddr, port);
renderStringColor(msg, VID_X/2, y, 0, 0, 0, surf);
renderStringColor(msg, VID_X/2, y, 255, 255, 255, surf);
y += 20;
}
}
@@ -299,7 +308,7 @@ void XSDL_generateHelp(const char * port)
close(sd);
}
SDL_SaveBMP(surf, "help.bmp");
SDL_SaveBMP(surf, "background.bmp");
SDL_FreeSurface(surf);
}

View File

@@ -7,6 +7,6 @@ void XSDL_initSDL();
void XSDL_deinitSDL();
void XSDL_unpackFiles();
void XSDL_showConfigMenu(int * resolutionW, int * displayW, int * resolutionH, int * displayH);
void XSDL_generateHelp(const char * port);
void XSDL_generateBackground(const char * port, int showHelp);
#endif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 68 KiB

View File

@@ -29,6 +29,7 @@ int main( int argc, char* argv[] )
clientcmd
};
char * envp[] = { NULL };
int printHelp = 1;
int resolutionW = atoi(getenv("DISPLAY_RESOLUTION_WIDTH"));
int resolutionH = atoi(getenv("DISPLAY_RESOLUTION_HEIGHT"));
@@ -61,16 +62,26 @@ int main( int argc, char* argv[] )
close(s);
}
XSDL_generateHelp(port);
if( argc > 1 && strcmp(argv[1], "-nohelp") == 0 )
{
printHelp = 0;
argc--;
argv++;
}
XSDL_generateBackground(port, printHelp);
XSDL_deinitSDL();
sprintf( screenres, "%d/%dx%d/%dx%d", resolutionW, displayW, resolutionH, displayH, 24 );
if( argc >= 2 )
cmd = argv[2];
sprintf( clientcmd, "%s/usr/bin/xhost + ; %s/usr/bin/xli -onroot -fullscreen help.bmp ; %s",
getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR"), cmd );
sprintf( clientcmd, "%s/usr/bin/xhost + ; %s/usr/bin/xli -onroot -fullscreen background.bmp ;",
getenv("SECURE_STORAGE_DIR"), getenv("SECURE_STORAGE_DIR") );
for( ; argc > 1; argc--, argv++ )
{
strcat(clientcmd, " ");
strcat(clientcmd, argv[1]);
}
__android_log_print(ANDROID_LOG_INFO, "XSDL", "XSDL video resolution %s", screenres);

View File

@@ -964,9 +964,14 @@ static void ANDROID_FlipHWSurfaceInternal(int numrects, SDL_Rect *rects)
SDL_UpdateTexture((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rect, SDL_CurrentVideoSurface->pixels, SDL_CurrentVideoSurface->pitch);
else
{
int i = 0;
int i;
for(i = 0; i < numrects; i++)
SDL_UpdateTexture((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rects[i], SDL_CurrentVideoSurface->pixels, SDL_CurrentVideoSurface->pitch);
{
//printf("SDL_UpdateTexture: rect %d: %04d:%04d:%04d:%04d", i, rects[i].x, rects[i].y, rects[i].w, rects[i].h);
SDL_UpdateTexture((struct SDL_Texture *)SDL_CurrentVideoSurface->hwdata, &rects[i],
SDL_CurrentVideoSurface->pixels + rects[i].y * SDL_CurrentVideoSurface->pitch + rects[i].x,
SDL_CurrentVideoSurface->pitch);
}
}
if( SDL_ANDROID_ShowScreenUnderFinger == ZOOM_NONE || SDL_ANDROID_ShowScreenUnderFinger == ZOOM_MAGNIFIER )
{
@@ -1125,8 +1130,11 @@ static void ANDROID_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
return;
}
// ANDROID_FlipHWSurfaceInternal(numrects, rects); // Fails for fheroes2, I'll add a compatibility option later.
#ifdef SDL_COMPATIBILITY_HACKS_PROPER_USADE_OF_SDL_UPDATERECTS
ANDROID_FlipHWSurfaceInternal(numrects, rects); // Fails for fheroes2, I'll add a compatibility option later.
#else
ANDROID_FlipHWSurfaceInternal(0, NULL);
#endif
SDL_ANDROID_CallJavaSwapBuffers();
}