From 0cf8dfb0134c26751a65fc9e7623affdc7ecb618 Mon Sep 17 00:00:00 2001 From: pelya Date: Mon, 10 Nov 2014 00:29:50 +0200 Subject: [PATCH] SuperTux: switched to 16bpp videomode, because it's slow on some levels for totally no reason, it's just a 2D game without any fancy graphice, why does it lag even on Note 3? --- project/jni/application/hid-pc-keyboard/src | 2 +- .../supertux/AndroidAppSettings.cfg | 10 +- project/jni/application/supertux/android.diff | 179 ++++++++++++++---- 3 files changed, 149 insertions(+), 42 deletions(-) diff --git a/project/jni/application/hid-pc-keyboard/src b/project/jni/application/hid-pc-keyboard/src index 201a409e1..4fc1dfce2 160000 --- a/project/jni/application/hid-pc-keyboard/src +++ b/project/jni/application/hid-pc-keyboard/src @@ -1 +1 @@ -Subproject commit 201a409e15ba74f1f2810eb5ff6f5e745bce6799 +Subproject commit 4fc1dfce237f99b45d8cee261b7f629e667eb5c3 diff --git a/project/jni/application/supertux/AndroidAppSettings.cfg b/project/jni/application/supertux/AndroidAppSettings.cfg index e9cfef28d..b45f86771 100644 --- a/project/jni/application/supertux/AndroidAppSettings.cfg +++ b/project/jni/application/supertux/AndroidAppSettings.cfg @@ -7,7 +7,7 @@ AppName="SuperTux" AppFullName=org.lethargik.supertux2 # Application version code (integer) -AppVersionCode=03406 +AppVersionCode=3406 # Application user-visible version name (string) AppVersionName="0.3.4.06" @@ -17,8 +17,8 @@ AppVersionName="0.3.4.06" # If the URL in in the form ':dir/file.dat:http://URL/' it will be downloaded as binary BLOB to the application dir and not unzipped # If the URL does not contain 'http://' it is treated as file from 'project/jni/application/src/AndroidData' dir - # these files are put inside .apk package by build system -# Also please avoid 'https://' URLs, many Android devices do not have trust certificates and will fail to connect to SF.net over HTTPS -AppDataDownloadUrl="!Data files|:data.zip:http://sourceforge.net/projects/libsdl-android/files/SuperTux/data-3.zip" +# You can specify Google Play expansion files in the form 'obb:main.12345' or 'obb:patch.12345' where 12345 is the app version, first associated with the file +AppDataDownloadUrl="!Data files|:data.zip:obb:patch.3406|:data.zip:http://sourceforge.net/projects/libsdl-android/files/SuperTux/data-3.zip" # Reset SDL config when updating application to the new version (y) / (n) ResetSdlConfigForThisVersion=y @@ -38,7 +38,7 @@ ScreenOrientation=h # Video color depth - 16 BPP is the fastest and supported for all modes, 24 bpp is supported only # with SwVideoMode=y, SDL_OPENGL mode supports everything. (16)/(24)/(32) -VideoDepthBpp=24 +VideoDepthBpp=16 # Enable OpenGL depth buffer (needed only for 3-d applications, small speed decrease) (y) or (n) NeedDepthBuffer=n @@ -219,7 +219,7 @@ NDK_TOOLCHAIN_VERSION=4.8 # Specify architectures to compile, 'all' or 'y' to compile for all architectures. # Available architectures: armeabi armeabi-v7a armeabi-v7a-hard x86 mips -MultiABI='armeabi-v7a' # x86 mips +MultiABI='armeabi-v7a x86 mips' # Optional shared libraries to compile - removing some of them will save space # MP3 support by libMAD is encumbered by patents and libMAD is GPL-ed diff --git a/project/jni/application/supertux/android.diff b/project/jni/application/supertux/android.diff index 765bbb7be..83fe57e95 100644 --- a/project/jni/application/supertux/android.diff +++ b/project/jni/application/supertux/android.diff @@ -24,7 +24,7 @@ index b728243..75a4bb4 100755 - +make -j8 diff --git a/src/control/controller.cpp b/src/control/controller.cpp -index 49996e2..8b4d13c 100644 +index 49996e2..6ad4ed8 100644 --- a/src/control/controller.cpp +++ b/src/control/controller.cpp @@ -16,6 +16,9 @@ @@ -37,7 +37,16 @@ index 49996e2..8b4d13c 100644 const char* Controller::controlNames[] = { "left", "right", -@@ -84,4 +87,23 @@ Controller::update() +@@ -51,6 +54,8 @@ Controller::reset() + controls[i] = false; + oldControls[i] = false; + } ++ mousePressed = false; ++ mousePos = Vector(0,0); + } + + void +@@ -84,4 +89,23 @@ Controller::update() oldControls[i] = controls[i]; } @@ -533,10 +542,20 @@ index c7d7778..9949e92 100644 try_vsync(true), show_fps(false), diff --git a/src/supertux/main.cpp b/src/supertux/main.cpp -index 1cfba9c..76a0ed9 100644 +index 1cfba9c..f453266 100644 --- a/src/supertux/main.cpp +++ b/src/supertux/main.cpp -@@ -128,7 +128,7 @@ public: +@@ -20,6 +20,9 @@ + #include + + #include ++#include ++#include ++#include + #include + #include + #include +@@ -128,7 +131,7 @@ public: if (!PHYSFS_init(argv0)) { std::stringstream msg; @@ -545,7 +564,7 @@ index 1cfba9c..76a0ed9 100644 throw std::runtime_error(msg.str()); } else -@@ -143,36 +143,9 @@ public: +@@ -143,36 +146,9 @@ public: void find_datadir() { @@ -584,7 +603,7 @@ index 1cfba9c..76a0ed9 100644 } } -@@ -238,7 +211,7 @@ class SDLSubsystem +@@ -238,7 +214,7 @@ class SDLSubsystem public: SDLSubsystem() { @@ -593,7 +612,7 @@ index 1cfba9c..76a0ed9 100644 { std::stringstream msg; msg << "Couldn't initialize SDL: " << SDL_GetError(); -@@ -257,7 +230,7 @@ public: +@@ -257,7 +233,7 @@ public: void Main::init_video() { @@ -602,7 +621,7 @@ index 1cfba9c..76a0ed9 100644 const char* icon_fname = "images/engine/icons/supertux-256x256.png"; SDL_Surface* icon = IMG_Load_RW(get_physfs_SDLRWops(icon_fname), true); -@@ -267,7 +240,7 @@ Main::init_video() +@@ -267,7 +243,7 @@ Main::init_video() } else { @@ -611,6 +630,21 @@ index 1cfba9c..76a0ed9 100644 SDL_FreeSurface(icon); } SDL_ShowCursor(0); +@@ -383,6 +359,14 @@ Main::run(int argc, char** argv) + { + CommandLineArguments args; + ++ // Copy over old savegames ++ struct stat st; ++ if (stat(".supertux2/profile1", &st) != 0) ++ { ++ system("mkdir -p .supertux2/profile1"); ++ system("cp $SDCARD/app-data/org.lethargik.supertux2/.supertux2/profile1/* .supertux2/profile1/"); ++ } ++ + try + { + args.parse_args(argc, argv); diff --git a/src/supertux/menu/joystick_menu.cpp b/src/supertux/menu/joystick_menu.cpp index bd11c9a..a2970bf 100644 --- a/src/supertux/menu/joystick_menu.cpp @@ -884,7 +918,7 @@ index b5251e0..6248380 100644 GLLightmap::~GLLightmap() diff --git a/src/video/gl/gl_painter.cpp b/src/video/gl/gl_painter.cpp -index ecb3cb1..a6ec13e 100644 +index ecb3cb1..3493ee1 100644 --- a/src/video/gl/gl_painter.cpp +++ b/src/video/gl/gl_painter.cpp @@ -14,6 +14,9 @@ @@ -897,7 +931,41 @@ index ecb3cb1..a6ec13e 100644 #include "video/gl/gl_painter.hpp" #include "video/drawing_request.hpp" -@@ -125,8 +128,8 @@ GLPainter::draw_surface(const DrawingRequest& request) +@@ -21,6 +24,8 @@ + #include "video/gl/gl_texture.hpp" + + GLuint GLPainter::s_last_texture = static_cast(-1); ++GLenum GLPainter::s_blend_sfactor = -1; ++GLenum GLPainter::s_blend_dfactor = -1; + + namespace { + +@@ -38,7 +43,13 @@ inline void intern_draw(float left, float top, float right, float bottom, + if(effect & VERTICAL_FLIP) + std::swap(uv_top, uv_bottom); + +- glBlendFunc(blend.sfactor, blend.dfactor); ++ bool restoreBlendMode = false; ++ if (blend.sfactor != GL_SRC_ALPHA || blend.dfactor != GL_ONE_MINUS_SRC_ALPHA) { ++ glBlendFunc(blend.sfactor, blend.dfactor); ++ restoreBlendMode = true; ++ //s_blend_sfactor = blend.sfactor; ++ //s_blend_dfactor = blend.dfactor; ++ } + glColor4f(color.red, color.green, color.blue, color.alpha * alpha); + + // unrotated blit +@@ -95,7 +106,8 @@ inline void intern_draw(float left, float top, float right, float bottom, + + // FIXME: find a better way to restore the blend mode + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); +- glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); ++ if (restoreBlendMode) ++ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + } + + } // namespace +@@ -125,8 +137,8 @@ GLPainter::draw_surface(const DrawingRequest& request) glBindTexture(GL_TEXTURE_2D, th); } intern_draw(request.pos.x, request.pos.y, @@ -908,18 +976,20 @@ index ecb3cb1..a6ec13e 100644 surface_data->get_uv_left(), surface_data->get_uv_top(), surface_data->get_uv_right(), -@@ -371,4 +374,9 @@ GLPainter::draw_inverse_ellipse(const DrawingRequest& request) +@@ -371,4 +383,11 @@ GLPainter::draw_inverse_ellipse(const DrawingRequest& request) glColor4f(1, 1, 1, 1); } +void GLPainter::reset_last_texture() +{ -+ s_last_texture = 0; ++ s_last_texture = static_cast(-1); ++ s_blend_sfactor = -1; ++ s_blend_dfactor = -1; +} + /* EOF */ diff --git a/src/video/gl/gl_painter.hpp b/src/video/gl/gl_painter.hpp -index bb3dd75..54e2c41 100644 +index bb3dd75..6ac8add 100644 --- a/src/video/gl/gl_painter.hpp +++ b/src/video/gl/gl_painter.hpp @@ -17,13 +17,18 @@ @@ -942,7 +1012,16 @@ index bb3dd75..54e2c41 100644 #endif struct DrawingRequest; -@@ -41,6 +46,7 @@ public: +@@ -32,6 +37,8 @@ class GLPainter + { + private: + static GLuint s_last_texture; ++ static GLenum s_blend_sfactor; ++ static GLenum s_blend_dfactor; + + public: + GLPainter(); +@@ -41,6 +48,7 @@ public: static void draw_gradient(const DrawingRequest& request); static void draw_filled_rect(const DrawingRequest& request); static void draw_inverse_ellipse(const DrawingRequest& request); @@ -951,7 +1030,7 @@ index bb3dd75..54e2c41 100644 private: GLPainter(const GLPainter&) = delete; diff --git a/src/video/gl/gl_renderer.cpp b/src/video/gl/gl_renderer.cpp -index 8f4a18ee..072e99e 100644 +index 8f4a18ee..aa5670a 100644 --- a/src/video/gl/gl_renderer.cpp +++ b/src/video/gl/gl_renderer.cpp @@ -43,35 +43,13 @@ @@ -1172,11 +1251,11 @@ index 8f4a18ee..072e99e 100644 + //SCREEN_WIDTH = SDL_GetVideoInfo()->current_w; + //SCREEN_HEIGHT = SDL_GetVideoInfo()->current_h; +#ifdef ANDROID -+ SDL_SetVideoMode(m_desktop_size.width, m_desktop_size.height, 24, SDL_OPENGL | SDL_DOUBLEBUF | SDL_FULLSCREEN); ++ SDL_SetVideoMode(m_desktop_size.width, m_desktop_size.height, 16, SDL_OPENGL | SDL_DOUBLEBUF | SDL_FULLSCREEN); +#else + m_desktop_size.width = 1280; + m_desktop_size.height = 800; -+ SDL_SetVideoMode(m_desktop_size.width, m_desktop_size.height, 24, SDL_OPENGL | SDL_DOUBLEBUF); ++ SDL_SetVideoMode(m_desktop_size.width, m_desktop_size.height, 16, SDL_OPENGL | SDL_DOUBLEBUF); +#endif } @@ -1219,7 +1298,7 @@ index 5da04a8..b73eb9d 100644 private: void apply_video_mode(); diff --git a/src/video/gl/gl_texture.cpp b/src/video/gl/gl_texture.cpp -index 443fa01..20fede8 100644 +index 443fa01..89c9f5e 100644 --- a/src/video/gl/gl_texture.cpp +++ b/src/video/gl/gl_texture.cpp @@ -16,6 +16,8 @@ @@ -1273,21 +1352,38 @@ index 443fa01..20fede8 100644 { #ifdef GL_VERSION_ES_CM_1_0 m_texture_width = next_power_of_two(image->w); -@@ -109,11 +103,11 @@ GLTexture::GLTexture(SDL_Surface* image) : +@@ -107,80 +101,93 @@ GLTexture::GLTexture(SDL_Surface* image) : + m_image_width = image->w; + m_image_height = image->h; - #if SDL_BYTEORDER == SDL_BIG_ENDIAN - SDL_Surface* convert = SDL_CreateRGBSurface(0, +-#if SDL_BYTEORDER == SDL_BIG_ENDIAN +- SDL_Surface* convert = SDL_CreateRGBSurface(0, - m_texture_width, m_texture_height, 32, -+ m_image_width, m_image_height, 32, - 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); - #else - SDL_Surface* convert = SDL_CreateRGBSurface(0, +- 0xff000000, 0x00ff0000, 0x0000ff00, 0x000000ff); +-#else +- SDL_Surface* convert = SDL_CreateRGBSurface(0, - m_texture_width, m_texture_height, 32, -+ m_image_width, m_image_height, 32, - 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); - #endif +- 0x000000ff, 0x0000ff00, 0x00ff0000, 0xff000000); +-#endif ++ SDL_Surface* convert; ++ if (image->flags & SDL_SRCCOLORKEY) { ++ // Palette image with colorkey transparency - RGBA5551 ++ convert = SDL_CreateRGBSurface(0, ++ m_image_width, m_image_height, 16, ++ 0x0000f800, 0x000007c0, 0x0000003e, 0x00000001); ++ } else if (image->format->BitsPerPixel == 32) { ++ // 32-bit image with alpha channel - RGBA4444 ++ convert = SDL_CreateRGBSurface(0, ++ m_image_width, m_image_height, 16, ++ 0x0000f000, 0x00000f00, 0x000000f0, 0x0000000f); ++ } else { ++ // 24-bit image or palette without transparency - RGB565 ++ convert = SDL_CreateRGBSurface(0, ++ m_image_width, m_image_height, 16, ++ 0x0000f800, 0x000007e0, 0x0000001f, 0x00000000); ++ } -@@ -121,66 +115,60 @@ GLTexture::GLTexture(SDL_Surface* image) : + if(convert == 0) { throw std::runtime_error("Couldn't create texture: out of memory"); } @@ -1303,17 +1399,17 @@ index 443fa01..20fede8 100644 + + reupload(); + TextureManager::current()->register_texture(this); -+ + + assert_gl("creating texture"); +} - ++ +void GLTexture::reupload() +{ assert_gl("before creating texture"); glGenTextures(1, &m_handle); try { - GLenum sdl_format; +- GLenum sdl_format; - if(convert->format->BytesPerPixel == 3) - sdl_format = GL_RGB; - else if(convert->format->BytesPerPixel == 4) @@ -1321,8 +1417,19 @@ index 443fa01..20fede8 100644 - else { - sdl_format = GL_RGBA; - assert(false); -- } -+ sdl_format = GL_RGBA; ++ GLenum sdl_format = GL_RGBA; ++ GLenum pixel_packing = GL_UNSIGNED_BYTE; ++ ++ if (m_pixels) { ++ if (m_pixels->format->Amask == 0) ++ sdl_format = GL_RGB; ++ if (m_pixels->format->Gmask == 0x000007c0) ++ pixel_packing = GL_UNSIGNED_SHORT_5_5_5_1; ++ if (m_pixels->format->Gmask == 0x00000f00) ++ pixel_packing = GL_UNSIGNED_SHORT_4_4_4_4; ++ if (m_pixels->format->Gmask == 0x000007e0) ++ pixel_packing = GL_UNSIGNED_SHORT_5_6_5; + } glBindTexture(GL_TEXTURE_2D, m_handle); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); @@ -1356,12 +1463,12 @@ index 443fa01..20fede8 100644 - { - SDL_UnlockSurface(convert); - } -+ GL_UNSIGNED_BYTE, NULL); ++ pixel_packing, NULL); - assert_gl("creating texture"); + if (m_pixels) + glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, m_image_width, m_image_height, -+ sdl_format, GL_UNSIGNED_BYTE, m_pixels->pixels); ++ sdl_format, pixel_packing, m_pixels->pixels); set_texture_params(); } catch(...) {