Improve performance of Canvas.drawBitmap() on android

早过忘川 提交于 2019-12-24 06:34:02

问题


Going with the time I try to implement view pager in my tile based game - and swiping is janky. I performed necessary performance measures like suggested by @romangui , and found out that redrawing my gaem field takes about 48 msec (way too long) - and I already flattened layout, eliminated overdraw have my custom layout managers etc.

I discovered that drawing one tile on GN takes about 0.600 msec - way too long for all 81 tiles. Time is actually spend on Canvas.drawBitmap(...)

Any ideas how to improve performance? I have only 6 different bitmaps, they are loaded once and reused. ARGB_8888. Of course they to not necessarilly match actual displayed size.

Would I get better performance if I pre render them for actual display size after my layout was measured?

Or shall I bite the bullet and pre render one big bitmap with my game state just for scrolling?


回答1:


You should be sure that you do not make Android to use scaling of the images while drawing.

Try to use previously scaled images, as in Draw a scaled bitmap to the canvas?



来源:https://stackoverflow.com/questions/13911587/improve-performance-of-canvas-drawbitmap-on-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!