Optiuon to run video rendering in separate thread - available only for SW mode

This commit is contained in:
pelya
2011-02-15 15:40:40 +00:00
parent adc6777fe7
commit 090ab8154c
15 changed files with 271 additions and 37 deletions

View File

@@ -17,6 +17,8 @@ class Globals {
// Set this value to true if you're planning to render 3D using OpenGL - it eats some GFX resources, so disabled for 2D
public static boolean NeedDepthBuffer = false;
public static boolean SwVideoMode = false;
public static boolean HorizontalOrientation = true;
// prevent device from going to suspend mode
@@ -101,6 +103,7 @@ class Globals {
public static int TouchscreenCalibration[] = new int[4];
public static String DataDir = new String("");
public static boolean SmoothVideo = false;
public static boolean MultiThreadedVideo = false;
}
class LoadLibrary {

View File

@@ -45,7 +45,7 @@ class Settings
static boolean settingsLoaded = false;
static boolean settingsChanged = false;
static final int SETTINGS_FILE_VERSION = 3;
static final int SETTINGS_FILE_VERSION = 4;
static void Save(final MainActivity p)
{
@@ -116,6 +116,7 @@ class Settings
out.writeBoolean(Globals.RelativeMouseMovement);
out.writeInt(Globals.RelativeMouseMovementSpeed);
out.writeInt(Globals.RelativeMouseMovementAccel);
out.writeBoolean(Globals.MultiThreadedVideo);
out.writeInt(Globals.OptionalDataDownload.length);
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
@@ -249,6 +250,7 @@ class Settings
Globals.RelativeMouseMovement = settingsFile.readBoolean();
Globals.RelativeMouseMovementSpeed = settingsFile.readInt();
Globals.RelativeMouseMovementAccel = settingsFile.readInt();
Globals.MultiThreadedVideo = settingsFile.readBoolean();
Globals.OptionalDataDownload = new boolean[settingsFile.readInt()];
for(int i = 0; i < Globals.OptionalDataDownload.length; i++)
@@ -1982,6 +1984,24 @@ class Settings
Globals.SmoothVideo
};
if(Globals.SwVideoMode)
{
CharSequence[] items2 = {
p.getResources().getString(R.string.pointandclick_keepaspectratio),
p.getResources().getString(R.string.pointandclick_showcreenunderfinger2),
p.getResources().getString(R.string.video_smooth),
p.getResources().getString(R.string.video_separatethread),
};
boolean defaults2[] = {
Globals.KeepAspectRatio,
Globals.ShowScreenUnderFinger,
Globals.SmoothVideo,
Globals.MultiThreadedVideo
};
items = items2;
defaults = defaults2;
}
if(Globals.Using_SDL_1_3)
{
CharSequence[] items2 = {
@@ -2008,6 +2028,8 @@ class Settings
Globals.ShowScreenUnderFinger = isChecked;
if( item == 2 )
Globals.SmoothVideo = isChecked;
if( item == 3 )
Globals.MultiThreadedVideo = isChecked;
}
});
builder.setPositiveButton(p.getResources().getString(R.string.ok), new DialogInterface.OnClickListener()
@@ -2036,6 +2058,8 @@ class Settings
{
if(Globals.SmoothVideo)
nativeSetSmoothVideo();
if( Globals.SwVideoMode && Globals.MultiThreadedVideo )
nativeSetVideoMultithreaded();
if( Globals.PhoneHasTrackball )
nativeSetTrackballUsed();
if( Globals.AppUsesMouse )
@@ -2157,6 +2181,7 @@ class Settings
private static native void nativeSetMultitouchUsed();
private static native void nativeSetTouchscreenKeyboardUsed();
private static native void nativeSetSmoothVideo();
private static native void nativeSetVideoMultithreaded();
private static native void nativeSetupScreenKeyboard(int size, int theme, int nbuttonsAutoFire, int transparency);
private static native void nativeSetupScreenKeyboardButtons(byte[] img);
private static native void nativeInitKeymap();

View File

@@ -213,7 +213,8 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
if(Globals.AudioBufferConfig >= 2)
Thread.currentThread().setPriority( (Thread.NORM_PRIORITY + Thread.MIN_PRIORITY) / 2 ); // Lower than normal
nativeInit( Globals.DataDir,
Globals.CommandLine); // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
Globals.CommandLine,
( Globals.SwVideoMode && Globals.MultiThreadedVideo ) ? 1 : 0 ); // Calls main() and never returns, hehe - we'll call eglSwapBuffers() from native code
System.exit(0); // The main() returns here - I don't bother with deinit stuff, just terminate process
}
@@ -252,7 +253,7 @@ class DemoRenderer extends GLSurfaceView_SDL.Renderer {
};
private native void nativeInitJavaCallbacks();
private native void nativeInit(String CurrentPath, String CommandLine);
private native void nativeInit(String CurrentPath, String CommandLine, int multiThreadedVideo);
private native void nativeResize(int w, int h, int keepAspectRatio);
private native void nativeDone();
private native void nativeGlContextLost();

View File

@@ -141,5 +141,6 @@
<string name="video">Video settings</string>
<string name="video_smooth">Smooth the video</string>
<string name="video_separatethread">Separate thread for video, will increase FPS on some devices</string>
</resources>