私はこれらのメソッドを呼び出すたびに、処理に14-20msかかるでしょう。SurfaceHolder.lockCanvas()が高すぎる
Canvas canvas = holder.lockCanvas();
holder.unlockCanvasAndPost(canvas);
これは正常な動作ですか? 別のアプローチをとるべきですか?
01-05:15:49:20.322:I /のSystem.out(4892):フレーム時間:ここ全体コード
public class Render extends SurfaceView { Context c = null; SurfaceHolder holder; volatile boolean running = true; public Render(Context c) { super(c); this.c = c; this.holder = getHolder(); } public void run() { if(running) { if(!holder.getSurface().isValid()){ System.out.println("not valid"); return; } Canvas canvas = holder.lockCanvas(); holder.unlockCanvasAndPost(canvas); } } }
トレースである0秒frame291
を使用するときに16ミリframe301
01- 05/15:49:20.322:I/System.out(4892):無効
01-05 15:49:20.322:I/System.out(4892):フレーム時間:0 msフレーム292
01-05 15 :49:20.332:I/System.out(4892):フレーム時間:2msフレーム293
01-05 15:49:20.357: I/System.out(4892):フレーム時間:22ms frame294
01-05 15:49:20.357:I/System.out(4892):フレーム時間:1msフレーム295
01-05 15:49: 20.362:I/System.out(4892):フレーム時間:1msフレーム296
01-05 15:49:20.367:D/CLIPBOARD(4892):開始入力時にクリップボードのダイアログを非表示にする。
01-05 15:49:20.367:I/System.out(4892):フレーム時間:8msフレーム297
01-05 15:49:20.377:I/System.out(4892):フレーム時間:10 ms /秒frame298
01-05 15:49:20.397:I/System.out(4892):フレーム時間:16ms frame299
01-05 15:49:20.412:I/System.out(4892):フレーム時間:16ミリframe300
01-05 15:49:20.427:I /をSystem.out(4892):フレーム時間:私は、OpenGL
UPDATE
同じことがhapens
package android.apps.td;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import android.content.Context;
import android.opengl.GLSurfaceView;
import android.opengl.GLSurfaceView.Renderer;
public class Render extends GLSurfaceView implements Renderer {
private final int MILLION = 1000000;
private long frame;
public Render(Context context) {
super(context);
setRenderer(this);
// TODO Auto-generated constructor stub
}
public void onDrawFrame(GL10 arg0) {
System.out.println("Frame "+(System.nanoTime()-frame)/MILLION+" ms");
frame = System.nanoTime();
}
public void onSurfaceChanged(GL10 gl, int width, int height) {
System.out.println("Surface changed w:"+width+" h:"+height);
}
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
System.out.println("Surface created");
}
}
あなたはそれらの間で何をしていますか? – dbryson
これらの2つのメソッドを呼び出すだけで遅延が発生します。 – jellyfication