diff options
author | Sven Gothel <[email protected]> | 2014-03-26 11:07:21 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2014-03-26 11:07:21 +0100 |
commit | 592bb0d90e08747e87aa7c9e23167d12e3de788c (patch) | |
tree | 3bd49a7180cc510b29f1f65fb05d6ab723127ec0 /src | |
parent | d7e710c7be9cfc26e2c35d5332f3dc5002538d75 (diff) |
MovieCube/Simple on Android/GLES: Cache FPS Region (updated only each second) to mitigate low-performance (update is CPU bound)
Diffstat (limited to 'src')
3 files changed, 39 insertions, 18 deletions
diff --git a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java index 1e4c2c72f..134f69319 100644 --- a/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java +++ b/src/test/com/jogamp/opengl/test/android/MovieCubeActivityLauncher1b.java @@ -34,7 +34,7 @@ import com.jogamp.opengl.test.android.LauncherUtil.OrderedProperties; public class MovieCubeActivityLauncher1b extends LauncherUtil.BaseActivityLauncher { - static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0a"; + static String demo = "com.jogamp.opengl.test.android.MovieCubeActivity0b"; static String[] sys_pkgs = new String[] { "com.jogamp.common", "javax.media.opengl" }; static String[] usr_pkgs = new String[] { "com.jogamp.opengl.test" }; diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java index dcdf26165..e5a55a845 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieCube.java @@ -170,14 +170,17 @@ public class MovieCube implements GLEventListener { private final GLRegion regionFPS; private float pixelSize, underlineSize; - InfoTextRendererGLELBase(final int rmode) { + InfoTextRendererGLELBase(final int rmode, final boolean lowPerfDevice) { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO super(rmode, MovieCube.this.textSampleCount); // NOTE_ALPHA_BLENDING: We go w/o alpha and blending! // this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); - regionFPS = GLRegion.create(usrRenderModes); - System.err.println("RegionFPS "+Region.getRenderModeString(usrRenderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); - + if( lowPerfDevice ) { + regionFPS = null; + } else { + regionFPS = GLRegion.create(usrRenderModes); + System.err.println("RegionFPS "+Region.getRenderModeString(usrRenderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); + } staticRGBAColor[0] = 0.1f; staticRGBAColor[1] = 0.1f; staticRGBAColor[2] = 0.1f; @@ -202,7 +205,9 @@ public class MovieCube implements GLEventListener { @Override public void dispose(GLAutoDrawable drawable) { - regionFPS.destroy(drawable.getGL().getGL2ES2(), renderer); + if( null != regionFPS ) { + regionFPS.destroy(drawable.getGL().getGL2ES2(), renderer); + } super.dispose(drawable); } @@ -234,7 +239,7 @@ public class MovieCube implements GLEventListener { "; yoff "+yoff1+", yoff2 "+yoff2); */ final GL gl = drawable.getGL(); - final String ptsPrec = gl.isGLES() ? "3.0" : "3.1"; + final String ptsPrec = null != regionFPS ? "3.1" : "3.0"; final String text1 = String.format("%0"+ptsPrec+"f/%0"+ptsPrec+"f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f, v-sync %d", pts, mPlayer.getDuration() / 1000f, mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(), @@ -246,7 +251,11 @@ public class MovieCube implements GLEventListener { final String text4 = mPlayer.getURI().getRawPath(); if( displayOSD && null != renderer ) { gl.glClearColor(1.0f, 1.0f, 1.0f, 0.0f); - renderString(drawable, font, pixelSize, text1, 1 /* col */, -1 /* row */, -1+z_diff, yoff1, 1f+z_diff, regionFPS); // no-cache + if( null != regionFPS ) { + renderString(drawable, font, pixelSize, text1, 1 /* col */, -1 /* row */, -1+z_diff, yoff1, 1f+z_diff, regionFPS); // no-cache + } else { + renderString(drawable, font, pixelSize, text1, 1 /* col */, -1 /* row */, -1+z_diff, yoff1, 1f+z_diff, true); + } renderString(drawable, font, pixelSize, text2, 1 /* col */, 0 /* row */, -1+z_diff, yoff2, 1f+z_diff, true); renderString(drawable, font, pixelSize, text3, 1 /* col */, 1 /* row */, -1+z_diff, yoff2, 1f+z_diff, true); renderString(drawable, font, pixelSize, text4, 1 /* col */, 2 /* row */, -1+z_diff, yoff2, 1f+z_diff, true); @@ -379,7 +388,9 @@ public class MovieCube implements GLEventListener { System.err.println("MC.init: kl-added "+added+", "+drawable.getClass().getName()); if( showText ) { - textRendererGLEL = new InfoTextRendererGLELBase(drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT); + final int rmode = drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT; + final boolean lowPerfDevice = gl.isGLES(); + textRendererGLEL = new InfoTextRendererGLELBase(rmode, lowPerfDevice); drawable.addGLEventListener(textRendererGLEL); } } diff --git a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java index c5160ffb1..c5dc66887 100644 --- a/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java +++ b/src/test/com/jogamp/opengl/test/junit/jogl/demos/es2/av/MovieSimple.java @@ -139,14 +139,17 @@ public class MovieSimple implements GLEventListener { private final float fontSize = 10f; private final GLRegion regionFPS; - InfoTextRendererGLELBase(int rmode) { + InfoTextRendererGLELBase(final int rmode, final boolean lowPerfDevice) { // FIXME: Graph TextRenderer does not AA well w/o MSAA and FBO super(rmode, textSampleCount); // NOTE_ALPHA_BLENDING: We go w/o alpha and blending! // this.setRendererCallbacks(RegionRenderer.defaultBlendEnable, RegionRenderer.defaultBlendDisable); - regionFPS = GLRegion.create(usrRenderModes); - System.err.println("RegionFPS "+Region.getRenderModeString(usrRenderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); - + if( lowPerfDevice ) { + regionFPS = null; + } else { + regionFPS = GLRegion.create(usrRenderModes); + System.err.println("RegionFPS "+Region.getRenderModeString(usrRenderModes)+", sampleCount "+textSampleCount[0]+", class "+regionFPS.getClass().getName()); + } staticRGBAColor[0] = 0.9f; staticRGBAColor[1] = 0.9f; staticRGBAColor[2] = 0.9f; @@ -160,7 +163,9 @@ public class MovieSimple implements GLEventListener { @Override public void dispose(GLAutoDrawable drawable) { - regionFPS.destroy(drawable.getGL().getGL2ES2(), renderer); + if( null != regionFPS ) { + regionFPS.destroy(drawable.getGL().getGL2ES2(), renderer); + } super.dispose(drawable); } @@ -178,8 +183,7 @@ public class MovieSimple implements GLEventListener { final float aspect = (float)mPlayer.getWidth() / (float)mPlayer.getHeight(); - final GL gl = drawable.getGL(); - final String ptsPrec = gl.isGLES() ? "3.0" : "3.1"; + final String ptsPrec = null != regionFPS ? "3.1" : "3.0"; final String text1 = String.format("%0"+ptsPrec+"f/%0"+ptsPrec+"f s, %s (%01.2fx, vol %01.2f), a %01.2f, fps %02.1f -> %02.1f / %02.1f, v-sync %d", pts, mPlayer.getDuration() / 1000f, mPlayer.getState().toString().toLowerCase(), mPlayer.getPlaySpeed(), mPlayer.getAudioVolume(), @@ -192,7 +196,11 @@ public class MovieSimple implements GLEventListener { if( displayOSD && null != renderer ) { // We share ClearColor w/ MovieSimple's init ! final float pixelSize = font.getPixelSize(fontSize, dpiH); - renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, regionFPS); // no-cache + if( null != regionFPS ) { + renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, regionFPS); // no-cache + } else { + renderString(drawable, font, pixelSize, text1, 1 /* col */, 1 /* row */, 0, 0, -1, true); + } renderString(drawable, font, pixelSize, text2, 1 /* col */, -4 /* row */, 0, height, -1, true); renderString(drawable, font, pixelSize, text3, 1 /* col */, -3 /* row */, 0, height, -1, true); renderString(drawable, font, pixelSize, text4, 1 /* col */, -2 /* row */, 0, height, -1, true); @@ -595,7 +603,9 @@ public class MovieSimple implements GLEventListener { winWidth = window.getWidth(); winHeight = window.getHeight(); } - textRendererGLEL = new InfoTextRendererGLELBase(drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT); + final int rmode = drawable.getChosenGLCapabilities().getSampleBuffers() ? 0 : Region.VBAA_RENDERING_BIT; + final boolean lowPerfDevice = gl.isGLES(); + textRendererGLEL = new InfoTextRendererGLELBase(rmode, lowPerfDevice); drawable.addGLEventListener(textRendererGLEL); } |