android - 如何为 Android SurfaceView 找到最佳的 PixelFormat

标签 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);
}

这会导致我的游戏在 Galaxy Nexus (ICS 4.0) 上运行得更快,但在 Motorola Xoom (3.2.1) 上运行缓慢。

如果我更改为 PixelFormat.OPAQUE,情况就会相反。 Nexus 很慢,而 Xoom 现在很快。所以我需要能够确定每个设备的最佳格式。我尝试使用 getWindow().getAttributes().format 但这总是返回 -1(不透明)。

最佳答案

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

关于android - 如何为 Android SurfaceView 找到最佳的 PixelFormat,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8829943/

相关文章:

android - 我如何创建一个类和我需要的方法?

Android 屏幕方向行为

Android 渲染和物理在不同的线程上?

java - 安卓 IllegalArgumentException lockCanvas()

android - 在哪里可以找到 `Warnings found during shrinking` 的警告?

android测试访问json文件

java - 在透明 SurfaceView 上绘制

android - 在透明 SurfaceView 之上添加 View ?

android - 在退出应用程序时结束 SurfaceView 和 GameThread

android - 更改 ViewPager 的动画样式