我发现在SurfaceView中更改像素格式会对帧速率产生很大影响.但是我似乎找不到基于每个设备选择最佳格式的方法.
例:
@Override
public void surfaceCreated(final SurfaceHolder holder) {
//This line seems to fix speed issue with his res devices
holder.setFormat(PixelFormat.RGBA_8888);
androidGame.setSurfaceHolder(holder);
}
Run Code Online (Sandbox Code Playgroud)
这使我的游戏在Galaxy Nexus(ICS 4.0)上运行得更快,但在摩托罗拉Xoom(3.2.1)上运行速度慢.
如果我改为PixelFormat.OPAQUE,情况就会逆转.Nexus很慢,而Xoom现在很快.所以我需要能够确定每台设备的最佳格式.我尝试过使用getWindow().getAttributes().format但这总是返回-1(OPAQUE).