如何为Android SurfaceView找到最好的PixelFormat

the*_*osh 5 android surfaceview

我发现在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).

the*_*osh 5

我可以在办公时间与Google IO 2012上的Romain Guy交谈.遗憾的是,没有合理的方法来检测要使用的最佳像素格式.您必须在每台设备上运行基准测试才能找到最佳格式.