SurfaceView 与自定义视图(从视图扩展)。 SurfaceView 速度较慢,为什么?
我用两种方式编写了同一个程序。
一个使用 Surfaceview,另一个使用自定义视图。根据 android SDK 开发指南,使用表面视图更好,因为您可以生成一个单独的线程来处理图形。 SDK 开发指南声称,使用带有无效调用的自定义视图仅适用于较慢的动画、不太强烈的图形。
但是,在我的简单应用程序中,我可以清楚地看到,使用自定义视图并调用 invalidate 似乎渲染速度更快。
你们对此有何了解/想法?
我的touchEvent代码是一模一样的,我的绘图代码也是一模一样的。唯一的区别是,一个是全部在UI线程中,另一个是使用tread来处理绘图。
I wrote the same program two ways.
One using a Surfaceview, and the other using a custom view. According to the android SDK development guide, using a surface view is better because you can spawn a separate thread to handle graphics. Th SDK development guide claims that using a custom view with invalidate calls is only good for slower animations, less intense graphics.
However, in my simple app, I can clearly see that using a custom view with calls to invalidate seems to render faster.
What do you guys know/think about this?
My touchEvent code is exactly the same, and my drawing code is exactly the same. The only difference is that one is all in the UI thread, and the other is using a tread to handle the drawing.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
SurfaceView 可以在 2 个缓冲区上进行绘图,您的自定义视图怎么样?
另一件事:您提到文档说
invalidate
在较慢的动画/不太强烈的图形上工作得很快。您的“简单应用程序”有多强烈?您应该尝试进行压力测试,并考虑单线程如何处理触摸输入。我的游戏中有 3 个线程。一个用于游戏逻辑,一个用于绘图,然后是“正常”UI 线程......
SurfaceView enables to work on 2 buffer for drawing, how about your custom view?
Another thing: You mentioned that the doc says
invalidate
works fast on slower animations/less intense graphics. How intense is your "simple app"? You should try to do a stress test and also take in account, how the single thread handles your touch-input.I have 3 threads in my game. One for game logic, one for drawing and then the "normal" UI thread...