【发布时间】:2016-06-26 22:53:06
【问题描述】:
我发现更改 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);
}
这导致我的游戏在 Galaxy Nexus (ICS 4.0) 上运行得更快,但在摩托罗拉 Xoom (3.2.1) 上运行缓慢。
如果我更改为 PixelFormat.OPAQUE,情况就会逆转。 Nexus 很慢,而 Xoom 现在很快。所以我需要能够确定每个设备的最佳格式。我尝试过使用 getWindow().getAttributes().format 但这总是返回 -1 (OPAQUE)。
【问题讨论】:
标签: android surfaceview