JRaymond JRaymond - 3 months ago 17x
Android Question

Android Paths for real time charting

I'm trying to create a real-time charting utility in android, and for the most part it works, except that when I get too many data points in one of my Paths it breaks openGL. I'm using paths because I'm transforming the entire dataset via matrix when a passed in value is outside the current bounds of the graph. Am I going about this the wrong way? is there a better/more appropriate API for this sort of thing? I'd be happy to trim the path to the current bounds if that were possible/I knew how to do it. Thanks!


protected void onDraw(Canvas canvas) {
scaleX = getWidth() / (maxX - minX);
scaleY = getHeight() / (maxY - minY);
// TODO: Use clips to draw x/y axis, allow color to be defined in attributes, etc.
for (DataLine line : mPathList.values()) {
canvas.drawPath(line, line.getPaint());

(DataLine is a subclass of Path that includes a Paint object)

Error in question is a warning from the OpenGLRenderer:
"Shape path too large to be rendered into a texture"


If you looked in your logs you will notice an error like so:

04-04 10:39:06.314: W/OpenGLRenderer(6092): Shape path too large to be rendered into a texture

Since turning on hardware acceleration everything gets rendered as a texture and there is a size limit for textures. If you break down the larger shapes into smaller ones, that will solve your problem. Or just turn off hardware acceleration: