9 comments

[ 26.8 ms ] story [ 219 ms ] thread
Any idea on the performance compared to HTML5 canvas? We've an application drawing about 10000 lines per frame for zooming / panning and depending on the device and browser is gets a little bit laggy.
Dropping down to WebGL should almost always give you more flexibility over how the lines are batched and rendered by the GPU, so performance should improve if you implement it mindfully.
Not really efficient. The junctions have way too many vertices and that should be way slower than the simple textured pattern approach. Also, for AA you would need subsampling that is times slower than the methods that allow to draw AA lines without it.
Please take this test ( this must be the result: http://www.amanithvg.com/screenshots/stroke_hot_case.png )

STROKE_LINE_WIDTH = 200 STROKE_CAP_STYLE = CAP_BUTT; STROKE_JOIN_STYLE = JOIN_ROUND; <identity transform matrix>

float xy[8]; int j = 0;

for (int i = 0; i < 4; ++i) { // x coordinate xy[j++] = 20.0f * (float)cos((i / 4.0f) * 1.7) + 128.0f; // y coordinate xy[j++] = 20.0f * (float)sin((i / 4.0f) * 1.7) + 128.0f; }

<draw stroked polygon whose points are the xy coordinates>