Added GLES2 support, and support for 24bpp and 32bpp - NOT TESTED,

it's only for OpenGL and for pure SW mode, HW SDL surfaces won't work
This commit is contained in:
pelya
2011-07-29 17:23:47 +03:00
parent 25632f41bc
commit 69de188e16
11 changed files with 222 additions and 88 deletions

View File

@@ -280,7 +280,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
"setRenderer has already been called for this instance.");
}
if (mEGLConfigChooser == null) {
mEGLConfigChooser = new SimpleEGLConfigChooser(true);
mEGLConfigChooser = getEglConfigChooser(16, false, false, false);
}
mGLThread = new GLThread(renderer);
mGLThread.start();
@@ -319,8 +319,8 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
*
* @param needDepth
*/
public void setEGLConfigChooser(boolean needDepth) {
setEGLConfigChooser(new SimpleEGLConfigChooser(needDepth));
public void setEGLConfigChooser(int bpp, boolean needDepth, boolean stencil, boolean gles2) {
setEGLConfigChooser(getEglConfigChooser(bpp, needDepth, stencil, gles2));
}
/**
@@ -337,9 +337,9 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
*
*/
public void setEGLConfigChooser(int redSize, int greenSize, int blueSize,
int alphaSize, int depthSize, int stencilSize) {
int alphaSize, int depthSize, int stencilSize, boolean gles2) {
setEGLConfigChooser(new ComponentSizeChooser(redSize, greenSize,
blueSize, alphaSize, depthSize, stencilSize));
blueSize, alphaSize, depthSize, stencilSize, gles2));
}
/**
* Set the rendering mode. When renderMode is
@@ -619,6 +619,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* @return the chosen configuration.
*/
EGLConfig chooseConfig(EGL10 egl, EGLDisplay display);
public boolean isGles2Required();
}
private static abstract class BaseConfigChooser
@@ -655,7 +656,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
private static class ComponentSizeChooser extends BaseConfigChooser {
public ComponentSizeChooser(int redSize, int greenSize, int blueSize,
int alphaSize, int depthSize, int stencilSize) {
int alphaSize, int depthSize, int stencilSize, boolean isGles2) {
super(new int[] {
EGL10.EGL_RED_SIZE, redSize,
EGL10.EGL_GREEN_SIZE, greenSize,
@@ -663,6 +664,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
EGL10.EGL_ALPHA_SIZE, alphaSize,
EGL10.EGL_DEPTH_SIZE, depthSize,
EGL10.EGL_STENCIL_SIZE, stencilSize,
EGL10.EGL_RENDERABLE_TYPE, isGles2 ? EGL_OPENGL_ES2_BIT : 0,
EGL10.EGL_NONE});
mValue = new int[1];
mRedSize = redSize;
@@ -671,6 +673,7 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
mAlphaSize = alphaSize;
mDepthSize = depthSize;
mStencilSize = stencilSize;
this.isGles2 = isGles2;
}
@Override
@@ -691,10 +694,13 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
EGL10.EGL_DEPTH_SIZE, 0);
int s = findConfigAttrib(egl, display, config,
EGL10.EGL_STENCIL_SIZE, 0);
boolean gles2 = (findConfigAttrib(egl, display, config,
EGL10.EGL_RENDERABLE_TYPE, 0) & EGL_OPENGL_ES2_BIT) != 0;
int distance = Math.abs(r - mRedSize)
+ Math.abs(g - mGreenSize)
+ Math.abs(b - mBlueSize) + Math.abs(a - mAlphaSize)
+ Math.abs(d - mDepthSize) + Math.abs(s - mStencilSize);
+ Math.abs(d - mDepthSize) + Math.abs(s - mStencilSize)
+ (gles2 == isGles2 ? 0 : 17);
if (distance < closestDistance) {
closestDistance = distance;
closestConfig = config;
@@ -712,6 +718,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
return defaultValue;
}
public boolean isGles2Required()
{
return isGles2;
}
private int[] mValue;
// Subclasses can adjust these values:
protected int mRedSize;
@@ -720,6 +731,9 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
protected int mAlphaSize;
protected int mDepthSize;
protected int mStencilSize;
public boolean isGles2 = false;
public static final int EGL_OPENGL_ES2_BIT = 4;
}
/**
@@ -727,9 +741,9 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* RGB565 as possible, with or without a depth buffer.
*
*/
private static class SimpleEGLConfigChooser extends ComponentSizeChooser {
public SimpleEGLConfigChooser(boolean withDepthBuffer) {
super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, 0);
private static class SimpleEGLConfigChooser16 extends ComponentSizeChooser {
public SimpleEGLConfigChooser16(boolean withDepthBuffer, boolean stencil, boolean gles2) {
super(4, 4, 4, 0, withDepthBuffer ? 16 : 0, stencil ? 8 : 0, gles2);
// Adjust target values. This way we'll accept a 4444 or
// 555 buffer if there's no 565 buffer available.
mRedSize = 5;
@@ -738,6 +752,34 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
}
}
private static class SimpleEGLConfigChooser24 extends ComponentSizeChooser {
public SimpleEGLConfigChooser24(boolean withDepthBuffer, boolean stencil, boolean gles2) {
super(8, 8, 8, 0, withDepthBuffer ? 16 : 0, stencil ? 8 : 0, gles2);
mRedSize = 8;
mGreenSize = 8;
mBlueSize = 8;
}
}
private static class SimpleEGLConfigChooser32 extends ComponentSizeChooser {
public SimpleEGLConfigChooser32(boolean withDepthBuffer, boolean stencil, boolean gles2) {
super(8, 8, 8, 8, withDepthBuffer ? 16 : 0, stencil ? 8 : 0, gles2);
mRedSize = 8;
mGreenSize = 8;
mBlueSize = 8;
mAlphaSize = 8;
}
}
private static ComponentSizeChooser getEglConfigChooser(int videoDepthBpp, boolean withDepthBuffer, boolean stencil, boolean gles2) {
if(videoDepthBpp == 16)
return new SimpleEGLConfigChooser16(withDepthBuffer, stencil, gles2);
if(videoDepthBpp == 24)
return new SimpleEGLConfigChooser24(withDepthBuffer, stencil, gles2);
if(videoDepthBpp == 32)
return new SimpleEGLConfigChooser32(withDepthBuffer, stencil, gles2);
return null;
};
/**
* An EGL helper class.
*/
@@ -775,8 +817,11 @@ public class GLSurfaceView_SDL extends SurfaceView implements SurfaceHolder.Call
* Create an OpenGL ES context. This must be done only once, an
* OpenGL context is a somewhat heavy object.
*/
final int EGL_CONTEXT_CLIENT_VERSION = 0x3098;
final int[] gles2_attrib_list = {EGL_CONTEXT_CLIENT_VERSION, 2, EGL10.EGL_NONE };
mEglContext = mEgl.eglCreateContext(mEglDisplay, mEglConfig,
EGL10.EGL_NO_CONTEXT, null);
EGL10.EGL_NO_CONTEXT, mEGLConfigChooser.isGles2Required() ? gles2_attrib_list : null );
mEglSurface = null;
}

View File

@@ -32,8 +32,11 @@ class Globals {
public static String AppLibraries[] = { "sdl-1.2", };
public static final boolean Using_SDL_1_3 = false;
public static String DataDownloadUrl = "Data files are 2 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-data.zip/download^High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp.zip/download";
public static boolean NeedDepthBuffer = false;
public static int VideoDepthBpp = 16;
public static boolean SwVideoMode = false;
public static boolean NeedDepthBuffer = false;
public static boolean NeedStencilBuffer = false;
public static boolean NeedGles2 = false;
public static boolean CompatibilityHacks = false;
public static boolean HorizontalOrientation = true;
public static boolean InhibitSuspend = false;

View File

@@ -2356,6 +2356,7 @@ class Settings
static void Apply(Activity p)
{
nativeSetVideoDepth(Globals.VideoDepthBpp);
if(Globals.SmoothVideo)
nativeSetSmoothVideo();
if( Globals.CompatibilityHacks )
@@ -2488,6 +2489,7 @@ class Settings
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();
private static native void nativeSetSmoothVideo();
private static native void nativeSetVideoDepth(int bpp);
private static native void nativeSetCompatibilityHacks();
private static native void nativeSetVideoMultithreaded();
private static native void nativeSetupScreenKeyboard(int size, int drawsize, int theme, int nbuttonsAutoFire, int transparency);

View File

@@ -444,7 +444,7 @@ class DemoGLSurfaceView extends GLSurfaceView_SDL {
super(context);
mParent = context;
touchInput = DifferentTouchInput.getInstance();
setEGLConfigChooser(Globals.NeedDepthBuffer);
setEGLConfigChooser(Globals.VideoDepthBpp, Globals.NeedDepthBuffer, Globals.NeedStencilBuffer, Globals.NeedGles2);
mRenderer = new DemoRenderer(context);
setRenderer(mRenderer);
}

View File

@@ -6,10 +6,13 @@ AppFullName=net.sourceforge.clonekeenplus
ScreenOrientation=h
InhibitSuspend=n
AppDataDownloadUrl="!Data files|data.zip^High-quality GFX and music - 40 Mb|https://sourceforge.net/projects/libsdl-android/files/CommanderGenius/commandergenius-hqp-1.8.zip/download"
VideoDepthBpp=16
NeedDepthBuffer=n
NeedStencilBuffer=n
NeedGles2=n
SwVideoMode=y
SdlVideoResize=y
SdlVideoResizeKeepAspect=n
NeedDepthBuffer=n
SwVideoMode=y
CompatibilityHacks=n
AppUsesMouse=n
AppNeedsTwoButtonMouse=n

View File

@@ -77,6 +77,9 @@ static void ANDROID_VideoQuitMT(_THIS);
static void ANDROID_UpdateRectsMT(_THIS, int numrects, SDL_Rect *rects);
static int ANDROID_FlipHWSurfaceMT(_THIS, SDL_Surface *surface);
static int ANDROID_ToggleFullScreen(_THIS, int fullscreen);
static Uint32 PixelFormatEnum = SDL_PIXELFORMAT_RGB565;
static Uint32 PixelFormatEnumAlpha = SDL_PIXELFORMAT_RGBA4444;
static Uint32 PixelFormatEnumColorkey = SDL_PIXELFORMAT_RGBA5551;
// Stubs to get rid of crashing in OpenGL mode
@@ -117,7 +120,6 @@ static SDL_Rect *SDL_modelist[SDL_NUMMODES+1];
//#define SDL_modelist (this->hidden->SDL_modelist)
enum { ANDROID_BYTESPERPIXEL = 2, ANDROID_BITSPERPIXEL = 16 };
typedef struct SDL_Texture private_hwdata;
// Pointer to in-memory video surface
@@ -212,21 +214,32 @@ int ANDROID_VideoInit(_THIS, SDL_PixelFormat *vformat)
{
int i;
static SDL_PixelFormat alphaFormat;
int bpp;
/* Determine the screen depth (use default 16-bit depth) */
/* we change this during the SDL_SetVideoMode implementation... */
if( vformat ) {
vformat->BitsPerPixel = ANDROID_BITSPERPIXEL;
vformat->BytesPerPixel = ANDROID_BYTESPERPIXEL;
vformat->BitsPerPixel = SDL_ANDROID_BITSPERPIXEL;
vformat->BytesPerPixel = SDL_ANDROID_BYTESPERPIXEL;
}
if( SDL_ANDROID_BITSPERPIXEL == 24 )
PixelFormatEnum = SDL_PIXELFORMAT_RGB24;
if( SDL_ANDROID_BITSPERPIXEL == 32 )
PixelFormatEnum = SDL_PIXELFORMAT_RGBA8888;
if( SDL_ANDROID_BITSPERPIXEL >= 24 )
{
PixelFormatEnumAlpha = SDL_PIXELFORMAT_RGBA8888;
PixelFormatEnumColorkey = SDL_PIXELFORMAT_RGBA8888;
}
int bpp;
SDL_memset(&alphaFormat, 0, sizeof(alphaFormat));
SDL_PixelFormatEnumToMasks( SDL_PIXELFORMAT_RGBA4444, &bpp,
SDL_PixelFormatEnumToMasks( PixelFormatEnumAlpha, &bpp,
&alphaFormat.Rmask, &alphaFormat.Gmask,
&alphaFormat.Bmask, &alphaFormat.Amask );
alphaFormat.BitsPerPixel = ANDROID_BITSPERPIXEL;
alphaFormat.BytesPerPixel = ANDROID_BYTESPERPIXEL;
alphaFormat.BitsPerPixel = SDL_ANDROID_BITSPERPIXEL;
alphaFormat.BytesPerPixel = SDL_ANDROID_BYTESPERPIXEL;
this->displayformatalphapixel = &alphaFormat;
this->info.hw_available = 1;
@@ -269,7 +282,7 @@ int ANDROID_VideoInit(_THIS, SDL_PixelFormat *vformat)
SDL_Rect **ANDROID_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
{
if(format->BitsPerPixel != ANDROID_BITSPERPIXEL)
if(format->BitsPerPixel != SDL_ANDROID_BITSPERPIXEL)
return NULL;
return SDL_modelist;
}
@@ -280,7 +293,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
SDL_PixelFormat format;
int bpp1;
__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): application requested mode %dx%d OpenGL %d HW %d", width, height, flags & SDL_OPENGL, flags & SDL_HWSURFACE);
__android_log_print(ANDROID_LOG_INFO, "libSDL", "SDL_SetVideoMode(): application requested mode %dx%d OpenGL %d HW %d BPP %d", width, height, flags & SDL_OPENGL, flags & SDL_HWSURFACE, SDL_ANDROID_BITSPERPIXEL);
if( ! SDL_ANDROID_InsideVideoThread() )
{
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Error: calling %s not from the main thread!", __PRETTY_FUNCTION__);
@@ -295,7 +308,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
current->flags = (flags & SDL_FULLSCREEN) | (flags & SDL_OPENGL) | SDL_DOUBLEBUF | ( flags & SDL_HWSURFACE );
current->w = width;
current->h = height;
current->pitch = SDL_ANDROID_sFakeWindowWidth * ANDROID_BYTESPERPIXEL;
current->pitch = SDL_ANDROID_sFakeWindowWidth * SDL_ANDROID_BYTESPERPIXEL;
current->pixels = NULL;
current->hwdata = NULL;
@@ -312,7 +325,7 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
SDL_VideoWindow = SDL_CreateWindow("", 0, 0, width, height, SDL_WINDOW_SHOWN | SDL_WINDOW_BORDERLESS | SDL_WINDOW_OPENGL);
SDL_memset(&mode, 0, sizeof(mode));
mode.format = SDL_PIXELFORMAT_RGB565;
mode.format = PixelFormatEnum;
SDL_SetWindowDisplayMode(SDL_VideoWindow, &mode);
if (SDL_CreateRenderer(SDL_VideoWindow, -1, 0) < 0) {
@@ -324,14 +337,14 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
current->hwdata = NULL;
if( ! (flags & SDL_HWSURFACE) )
{
current->pixels = SDL_malloc(width * height * ANDROID_BYTESPERPIXEL);
current->pixels = SDL_malloc(width * height * SDL_ANDROID_BYTESPERPIXEL);
if ( ! current->pixels ) {
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate buffer for requested mode");
SDL_SetError("Couldn't allocate buffer for requested mode");
return(NULL);
}
SDL_memset(current->pixels, 0, width * height * ANDROID_BYTESPERPIXEL);
current->hwdata = (struct private_hwdata *)SDL_CreateTexture(SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STATIC, width, height);
SDL_memset(current->pixels, 0, width * height * SDL_ANDROID_BYTESPERPIXEL);
current->hwdata = (struct private_hwdata *)SDL_CreateTexture(PixelFormatEnum, SDL_TEXTUREACCESS_STATIC, width, height);
if( !current->hwdata ) {
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate texture for SDL_CurrentVideoSurface");
SDL_free(current->pixels);
@@ -354,13 +367,13 @@ SDL_Surface *ANDROID_SetVideoMode(_THIS, SDL_Surface *current,
/* Allocate the new pixel format for the screen */
SDL_memset(&format, 0, sizeof(format));
SDL_PixelFormatEnumToMasks( SDL_PIXELFORMAT_RGB565, &bpp1,
SDL_PixelFormatEnumToMasks( PixelFormatEnum, &bpp1,
&format.Rmask, &format.Gmask,
&format.Bmask, &format.Amask );
format.BitsPerPixel = bpp1;
format.BytesPerPixel = ANDROID_BYTESPERPIXEL;
format.BytesPerPixel = SDL_ANDROID_BYTESPERPIXEL;
if ( ! SDL_ReallocFormat(current, ANDROID_BITSPERPIXEL, format.Rmask, format.Gmask, format.Bmask, format.Amask) ) {
if ( ! SDL_ReallocFormat(current, SDL_ANDROID_BITSPERPIXEL, format.Rmask, format.Gmask, format.Bmask, format.Amask) ) {
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate new pixel format for requested mode");
SDL_SetError("Couldn't allocate new pixel format for requested mode");
return(NULL);
@@ -437,14 +450,13 @@ static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface)
return(-1);
DEBUGOUT("ANDROID_AllocHWSurface() surface %p w %d h %d", surface, surface->w, surface->h);
Uint32 format = SDL_PIXELFORMAT_RGBA5551; // 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
if( surface->format->Amask )
{
SDL_PixelFormat format1;
int bpp;
format = SDL_PIXELFORMAT_RGBA4444;
DEBUGOUT("ANDROID_AllocHWSurface() SDL_PIXELFORMAT_RGBA4444");
SDL_memset(&format1, 0, sizeof(format1));
format = PixelFormatEnumAlpha;
SDL_memset(&format1, 0, sizeof(format1));
SDL_PixelFormatEnumToMasks( format, &bpp,
&format1.Rmask, &format1.Gmask,
&format1.Bmask, &format1.Amask );
@@ -457,7 +469,6 @@ static int ANDROID_AllocHWSurface(_THIS, SDL_Surface *surface)
}
else
{
DEBUGOUT("ANDROID_AllocHWSurface() SDL_PIXELFORMAT_RGBA5551");
// HW-accel surface should be RGB565
if( !( SDL_CurrentVideoSurface->format->BitsPerPixel == surface->format->BitsPerPixel &&
SDL_CurrentVideoSurface->format->Rmask == surface->format->Rmask &&
@@ -557,7 +568,7 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
if( ! SDL_CurrentVideoSurface->pixels )
{
glPixelStorei(GL_PACK_ALIGNMENT, 1);
SDL_CurrentVideoSurface->pixels = SDL_malloc(SDL_ANDROID_sFakeWindowWidth * SDL_ANDROID_sFakeWindowHeight * ANDROID_BYTESPERPIXEL);
SDL_CurrentVideoSurface->pixels = SDL_malloc(SDL_ANDROID_sFakeWindowWidth * SDL_ANDROID_sFakeWindowHeight * SDL_ANDROID_BYTESPERPIXEL);
if ( ! SDL_CurrentVideoSurface->pixels ) {
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate buffer for SDL_CurrentVideoSurface");
SDL_SetError("Couldn't allocate buffer for SDL_CurrentVideoSurface");
@@ -566,7 +577,7 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
}
if( ! SDL_CurrentVideoSurface->hwdata )
{
SDL_CurrentVideoSurface->hwdata = (struct private_hwdata *)SDL_CreateTexture(SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STATIC, SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight);
SDL_CurrentVideoSurface->hwdata = (struct private_hwdata *)SDL_CreateTexture(PixelFormatEnum, SDL_TEXTUREACCESS_STATIC, SDL_ANDROID_sFakeWindowWidth, SDL_ANDROID_sFakeWindowHeight);
if( !SDL_CurrentVideoSurface->hwdata ) {
__android_log_print(ANDROID_LOG_INFO, "libSDL", "Couldn't allocate texture for SDL_CurrentVideoSurface");
SDL_OutOfMemory();
@@ -585,6 +596,7 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
for(y=0; y<fakeH; y++)
{
// TODO: support 24bpp and 32bpp
glReadPixels(0, realH - 1 - (realH * y / fakeH),
realW, 1, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, row);
for(x=0; x<fakeW; x++)
@@ -621,7 +633,7 @@ static int ANDROID_LockHWSurface(_THIS, SDL_Surface *surface)
static void ANDROID_UnlockHWSurface(_THIS, SDL_Surface *surface)
{
SDL_PixelFormat format;
Uint32 hwformat = SDL_PIXELFORMAT_RGBA5551;
Uint32 hwformat = PixelFormatEnumColorkey;
int bpp;
SDL_Surface * converted = NULL;
@@ -635,26 +647,26 @@ static void ANDROID_UnlockHWSurface(_THIS, SDL_Surface *surface)
return;
if( surface->format->Amask )
hwformat = SDL_PIXELFORMAT_RGBA4444;
hwformat = PixelFormatEnumAlpha;
if( surface == SDL_CurrentVideoSurface ) // Special case
hwformat = SDL_PIXELFORMAT_RGB565;
hwformat = PixelFormatEnum;
/* Allocate the new pixel format for the screen */
SDL_memset(&format, 0, sizeof(format));
SDL_PixelFormatEnumToMasks( hwformat, &bpp,
&format.Rmask, &format.Gmask,
&format.Bmask, &format.Amask );
format.BytesPerPixel = ANDROID_BYTESPERPIXEL;
format.BytesPerPixel = SDL_ANDROID_BYTESPERPIXEL;
format.BitsPerPixel = bpp;
// TODO: support 24bpp and 32bpp
if( format.BitsPerPixel == surface->format->BitsPerPixel &&
format.Rmask == surface->format->Rmask &&
format.Gmask == surface->format->Gmask &&
format.Bmask == surface->format->Bmask &&
format.Amask == surface->format->Amask )
{
DEBUGOUT("ANDROID_UnlockHWSurface() no conversion");
converted = surface; // No need for conversion
}
else
@@ -963,11 +975,11 @@ void SDL_ANDROID_VideoContextRecreated()
for( i = 0; i < HwSurfaceCount; i++ )
{
// Allocate HW texture
Uint32 format = SDL_PIXELFORMAT_RGBA5551; // 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
if( HwSurfaceList[i]->format->Amask )
format = SDL_PIXELFORMAT_RGBA4444;
format = PixelFormatEnumAlpha;
if( HwSurfaceList[i] == SDL_CurrentVideoSurface )
format = SDL_PIXELFORMAT_RGB565;
format = PixelFormatEnum;
HwSurfaceList[i]->hwdata = (struct private_hwdata *)SDL_CreateTexture(format, SDL_TEXTUREACCESS_STATIC, HwSurfaceList[i]->w, HwSurfaceList[i]->h);
if( !HwSurfaceList[i]->hwdata )
{

View File

@@ -133,8 +133,7 @@ SDL_RenderDriver GL_ES_RenderDriver = {
SDL_PIXELFORMAT_RGBA5551,
SDL_PIXELFORMAT_RGB565,
SDL_PIXELFORMAT_RGB24,
SDL_PIXELFORMAT_BGR888,
SDL_PIXELFORMAT_ABGR8888},
SDL_PIXELFORMAT_RGBA8888},
0,
0}
};

View File

@@ -68,6 +68,9 @@ static int showScreenKeyboardSendBackspace = 0;
int SDL_ANDROID_SmoothVideo = 0;
int SDL_ANDROID_VideoMultithreaded = 0;
int SDL_ANDROID_CompatibilityHacks = 0;
int SDL_ANDROID_BYTESPERPIXEL = 2;
int SDL_ANDROID_BITSPERPIXEL = 16;
static void appPutToBackgroundCallbackDefault(void)
{
@@ -306,3 +309,10 @@ JAVA_EXPORT_NAME(Settings_nativeSetCompatibilityHacks) (JNIEnv* env, jobject thi
{
SDL_ANDROID_CompatibilityHacks = 1;
}
JNIEXPORT void JNICALL
JAVA_EXPORT_NAME(Settings_nativeSetVideoDepth) (JNIEnv* env, jobject thiz, jint bpp)
{
SDL_ANDROID_BITSPERPIXEL = bpp;
SDL_ANDROID_BYTESPERPIXEL = SDL_ANDROID_BITSPERPIXEL / 8;
}

View File

@@ -41,6 +41,8 @@ extern int SDL_ANDROID_TouchscreenCalibrationY;
extern int SDL_ANDROID_SmoothVideo;
extern int SDL_ANDROID_VideoMultithreaded;
extern int SDL_ANDROID_CompatibilityHacks;
extern int SDL_ANDROID_BYTESPERPIXEL;
extern int SDL_ANDROID_BITSPERPIXEL;
extern void SDL_ANDROID_TextInputInit(char * buffer, int len);
extern void SDL_ANDROID_TextInputFinished();
extern SDL_Surface *SDL_CurrentVideoSurface;