Android的帆布路径实时性能 [英] Android canvas path real-time performance

查看:132
本文介绍了Android的帆布路径实时性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想提请(4或5)实时图表15分钟内可视化大量的数据(一个新值每30毫秒)。我使用的路径,但它似乎非常缓慢上班的时候我想显示20000的价值观和翻译画布,事情变得更糟糕每一秒。我使用的drawLine也尝试过,但它不流利在所有的工作。

I want to draw (4 or 5) real-time charts visualizing a lot of data (a new value every 30ms) within 15 minutes. I am using Path but it seems to work very slowly when I want to display over 20000 values and translate the canvas and it gets worse every second. I also tried using drawLine but it doesn't work fluently at all.

有没有人有关于比路径更好的解决方案的想法吗?或者,也许我做错了什么?我目前的搜索解决方案是:我初始化路径的开始,然后只需添加一个新的生产线将它每次我得到一个新的价值的时候,那么我翻译画布

Does anyone have any ideas about a better solution than Path? Or maybe I am doing something wrong? My current solutio is : I initialize the Path in the beginning and then just add a new line to it every time I get a new value, then I translate the canvas.

推荐答案

显示20 000值的路径可能会有所减缓无论你使用,即使在OpenGL,它只是一个大量数据发送到图形芯片绘制...

Displaying a path of 20 000 values will probably be slow whatever you use, even in OpenGL, it's just a lot of data to send to the graphics chip to draw...

正确的方式做到这一点(性能明智)可能是缓存尽可能多的东西越好,并绘制需要绘制唯一的东西。例如,你可以绘制为位图的第N个点,然后只用于下一M个点的路径(并绘制为previous那些位图)。绘制一个位图是pretty快。因此,在一段时间后,你可以只刷新您的位图(这将需要更多的时间),然后绘制剩余点。

The "correct" way to do it (performance-wise) is probably to cache as much stuff as possible, and draw only what needs to be drawn. You could for example draw to a bitmap the first N points, and then only use a path for the next M points (and draw the bitmaps for the previous ones). Drawing a bitmap is pretty fast. So once in a while, you could just refresh your bitmap (which will take a bit more time) and then plot the remaining points.

您也可以决定有一个较短的路径:你真的需要20 000价值?难道你十来分组由5或10分5(甚至更多)?目前,该屏幕是最多1280像素宽反正...

You could also decide to have a shorter path : do you really need 20 000 values ? Couldn't you be grouping points 5 by 5 or 10 by ten (or even more) ? Currently, the screens are at most 1280 pixels wide anyways...

这篇关于Android的帆布路径实时性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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