简体   繁体   English

Android Drawable绘图性能?

[英]Android Drawable Drawing Performance?

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). 在我看来,我有一个简单的ARGB可绘制对象,它大约需要2毫秒的绘制时间,但是我可以在0.5毫秒内绘制与位图相同的文件(只是一些快速代码,我真的不能认为它是一个选择)。 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. 对于较小的数字,请使用画布(确切的数字也取决于设备),我建议您使用画布,因为它是一种更好的高级绘制方法。

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. 如果您想处理很多图像(想想成百上千个),建议您创建一个GLSurfaceView并使用openGL使用针对您的应用程序定制的VBO渲染图像。 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. 如果您沿这条路线走,我也建议您使用纹理表,因为这样会以代码复杂性为代价极大地提高性能。

But this will also depend on that type of app. 但这也取决于该类型的应用程序。 My background is in game development so I use openGL exclusively for better performance. 我的背景是游戏开发,因此我专门使用openGL以获得更好的性能。 for a simple app (something along the lines of androidify) Canvas should be fine. 对于一个简单的应用程序(类似于androidify的东西),Canvas应该很好。 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). 如果您想要一个简单的openGL教程,建议您访问Bergman关于该主题的系列文章(Google应该为您提供一个链接)。 It is a nice intro to openGL. 这是openGL的不错的介绍。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM