如何找到一个Android SurfaceView最好的PixelFormat [英] How to find the best PixelFormat for an Android SurfaceView

查看:961
本文介绍了如何找到一个Android SurfaceView最好的PixelFormat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已发现,改变像素格式中一个SurfaceView对帧速率有很大的影响。不过,我似乎无法找到一个方法来选择在每个设备的基础上最好的格式。

I have found that changing the pixel format in a SurfaceView has a large impact on frame rates. However I can't seem to find a way to select the best format on a per device basis.

例如:

@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)运行速度要快得多。

This causes my game to run much faster on a Galaxy Nexus (ICS 4.0) but Slow on a Motorola Xoom (3.2.1).

如果我改变PixelFormat.OPAQUE形势逆转。 Nexus的是缓慢的,Xoom的,现在快。所以,我需要能够确定每个设备的最佳格式。我已经使用getWindow尝试()的getAttributes()的格式,但这个总是返回-1(不透明)。

If I change to PixelFormat.OPAQUE the situation reverses. The Nexus is slow and the Xoom is now fast. So I need to be able to determine the best format per device. I have tried using getWindow().getAttributes().format but this always returns -1 (OPAQUE).

推荐答案

我能在上班时间谈罗曼盖伊在谷歌IO 2012。不幸的是,没有合理的方法来检测最佳的像素格式使用。你将不得不在每个设备上运行基准测试来发现它是最好的格式。

I was able to talk to Romain Guy at Google IO 2012 during office hours. Unfortunately there is no reasonable way to detect the best pixel format to use. You would have to run a benchmark test on each device to find it's best format.

这篇关于如何找到一个Android SurfaceView最好的PixelFormat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆