@Override public void onDrawFrame(javax.microedition.khronos.opengles.GL10 gl) { // Gdx.app.log("AndroidGraphics", "onDrawFrame"); // Log.i( "opt" , "opt onDrawFrame" ); boolean logTime = false; if (!app.hasFocus) { if (app.justResume) { app.justResume = false; logTime = true; // Log.i("opt", "return:onDrawFrame,draw after resume"); } else { // Log.i( "opt" , "opt onDrawFrame,return" ); AndroidApplication.swapSurface = false; return; } } long time = System.nanoTime(); deltaTime = (time - lastFrameTime) / 1000000000.0f; lastFrameTime = time; mean.addValue(deltaTime); boolean lrunning = false; boolean lpause = false; boolean ldestroy = false; boolean lresume = false; boolean lforceRender = false; synchronized (synch) { lrunning = running; lpause = pause; ldestroy = destroy; lresume = resume; lforceRender = forceRender > 0; if (resume) { resume = false; } if (pause) { pause = false; synch.notifyAll(); } if (destroy) { destroy = false; synch.notifyAll(); } if (forceRender > 0) { forceRender--; if (forceRender < 0) forceRender = 0; this.requestRendering(); } } if (lresume) { app.listener.resume(); Gdx.app.log("AndroidGraphics", "resumed"); } // if(logTime)Log.i("opt", "return:onDrawFrame,time1:"+(System.nanoTime()-time)/1000000); time = System.nanoTime(); synchronized (app.urgentRunnables) { app.executedUrgentRunnables.clear(); app.executedUrgentRunnables.addAll(app.urgentRunnables); app.urgentRunnables.clear(); } for (int i = 0; i < app.executedUrgentRunnables.size; i++) { try { app.executedUrgentRunnables.get(i).run(); } catch (Throwable t) { throw new RuntimeException(t); } } if (lrunning || lforceRender) { synchronized (app.runnables) { app.executedRunnables.clear(); app.executedRunnables.addAll(app.runnables); app.runnables.clear(); } for (int i = 0; i < app.executedRunnables.size; i++) { try { app.executedRunnables.get(i).run(); } catch (Throwable t) { throw new RuntimeException(t); } } // } // if(logTime)Log.i("opt", "return:onDrawFrame,time2:"+(System.nanoTime()-time)/1000000); time = System.nanoTime(); app.input.processEvents(); app.listener.render(); // if(logTime)Log.i("opt", "return:onDrawFrame,time3:"+(System.nanoTime()-time)/1000000); time = System.nanoTime(); } else { Gdx.app.log("AndroidGraphics", "not render"); } if (lpause) { app.listener.pause(); ((AndroidApplication) app).audio.pause(); Gdx.app.log("AndroidGraphics", "paused"); } if (ldestroy) { app.listener.dispose(); ((AndroidApplication) app).audio.dispose(); ((AndroidApplication) app).audio = null; Gdx.app.log("AndroidGraphics", "destroyed"); } if (enable_showFPS) { if (time - frameStart > 1000000000) { fps = frames; frames = 0; frameStart = time; framesEverySecond.add(fps); // Gdx.app.log( "xiatian - framesEverySecond" , "====start" ); // for( int i = 0 ; i < framesEverySecond.size() - 1 ; i++ ) // { // Gdx.app.log( "xiatian - framesEverySecond" , "--" + ( i + 1 ) + "--:" + // framesEverySecond.get( i ) ); // } // Gdx.app.log( "xiatian - framesEverySecond" , "====end" ); FpsAverageValue = calculateFpsAverageValue(); FpsCrestValue = calculateFpsCrestValue(); FpsVarianceValue = calculateFpsVarianceValue(); } frames++; } // if(logTime)Log.i("opt", "return:onDrawFrame,time4:"+(System.nanoTime()-time)/1000000); }