Android的绘制对象绘图性能?对象、性能、Android

2023-09-07 09:59:55 作者:酒自斟

在我看来,我有一个简单的ARGB绘制大约需要2ms的画,但我可​​以得出相同的文件在0.5ms的下一个位图(只是一些快速code,我真的不能把它作为一个选项)。什么是优化绘制的图纸速度的最佳方法是什么?

In my view I have a simple ARGB drawable that takes about 2ms to draw but I can draw the same file as a bitmap in under 0.5ms (just some quick code, I can't really consider it an option). What are the best ways to optimize the drawing speed of a drawable?

推荐答案

这将取决于在可绘区域的数量多少次,每次被绘制。对于一个小数目,用帆布(一个确切的数字还取决于设备上),我会使用的画布的,因为它是一个不错的更高层次的方法来绘制。

It will depend on the number of drawables and how many times each gets drawn. For a small number, use canvas (an exact number will also depend on the device) I would suggest using Canvas as it's a nice higher level approach to drawing.

如果您想炮制出大量的图像(想想几百个),我会建议创建的 GLSurfaceView 并用openGL渲染使用为您量身定制的应用程序维也纳各组织的图像。我也建议使用一个纹理纸,如果你沿着这条路走下去,因为你会得到在code复杂性为代价的巨大的性能提升。

If you want to crank out a lot of images (think hundreds), I would suggest creating a GLSurfaceView and using openGL to render your images using VBOs tailored to your app. I would also recommend using a texture sheet if you go down this route since you'll get a huge increase in performance at the cost of code complexity.

但是,这也将取决于类型的应用程序。我的背景是在游戏开发中,所以我使用OpenGL专为更好的性能。一个简单的应用程序(沿androidify东西线)帆布应该罚款。如果你想要一个简单的教程对OpenGL,我建议您访问伯格曼的一系列帖子的题目(谷歌应该给你一个链接,这一点)。这是一个很好的介绍OpenGL的。

But this will also depend on that type of app. My background is in game development so I use openGL exclusively for better performance. for a simple app (something along the lines of androidify) Canvas should be fine. If you want a simple tutorial for openGL, I suggest visiting Bergman's series of posts on the topic (google should give you a link for that). It is a nice intro to openGL.