title: Bad performance when drawing continuously in CustomView
body: <p><strong>Use case:</strong></p>
  
  <p>I need to draw hundred lines and a few pieces of text on my view. I need to give a scrolling effect, for which I capture the <code>ACTION_MOVE</code> event and redraw all the lines with the updated points. To get the desire result I tried with different approaches but none works as intended. </p>
  
  <p><strong>Approach 1</strong></p>
  
  <p>I made a custom class which extends <code>View</code>. All the drawing and calculation is done directly in my <code>onDraw()</code> method. Since there is so much of operation done in <code>onDraw()</code> method, the performance of the app is very poor. I even checked the performance using <strong>Profile GPU rendering</strong> and I can see the lines are very tall. </p>
  
  <p><strong>Approach 2</strong></p>
  
  <p>I created a Bitmap and after drawing all the lines onto my bitmap in another thread, I used <code>postInvalidate()</code> to draw the bitmap in <code>onDraw()</code> method:</p>
  
  <pre><code>mBufferedBitmap = Bitmap.createBitmap(getWidth(), getHeight(), Bitmap.Config.ARGB_8888);   
  mBufferedBitmap.eraseColor(Color.TRANSPARENT);    
  Canvas mBufferedCanvas = new Canvas(mBufferedBitmap);               
  drawLines(mBufferedCanvas)    
  postInvalidate();
  </code></pre>
  
  <p>Since I erase all the previous drawing on the bitmap and draw new lines with updated points, there is a flickering on the screen.</p>
  
  <p><strong>Approach 3</strong></p>
  
  <p>I tried extending my custom class to <code>SurfaceView</code> and performing all the operations on canvas object in another thread. But since <code>SurfaceView</code> uses CPU for drawing operations, the performance will be poor in low configuration mobiles.</p>
  
  <p>Can anyone guide me how to achieve this task with better performance? </p>