title: Bitmap change will make View auto refresh before onDraw() and regardless invalidate invoke
body: <p>I had a strange issue about View.onDraw(), I had a Canvas that draw some text with a Bitmap, in onDraw method, I draw that Bitmap use the View hold Canvas. when user touch, I invoke <strong>startDragging</strong> then make some change of Bitmap, but I never perform <strong>View.invalidate()</strong>, I thought whatever change of Bitmap wouldn't affect the BoardView UI, because I didn't invalidate it to refresh, but it refresh with new change of Bitmap <strong>immediately</strong> without <em>onDraw()</em> invoke, I set a breakpoint at onDraw first line and Debugging, but onDraw not invoke. After that, I invoke invalidate() after startDragging(), I stop with onDraw invoking at first line but I saw BoardView already refresh.<br/>
  I don't know what they do before onDraw(), Does Canvas will know I change Bitmap and use it immediately? I think all the UI change will invoke onDraw method and it can control how to change or not, Is wrong with me?</p>
  
  <pre><code>import android.content.Context;
  import android.graphics.Bitmap;
  import android.graphics.Canvas;
  import android.graphics.Color;
  import android.graphics.Paint;
  import android.util.AttributeSet;
  import android.view.View;
  
  public class BoardView extends View {
      public BoardView(Context context, AttributeSet attrs) {
          super(context, attrs);
      }
  
      private Bitmap mMainPageBitmap;
      private Canvas mDrawableCanvas;
  
      @Override
      protected void onDraw(Canvas canvas) {
          if (mMainPageBitmap == null) initDrawing(canvas.getWidth(), canvas.getHeight());
          canvas.drawBitmap(mMainPageBitmap, 0, 0, null);
      }
  
      private void initDrawing(int width, int height) {
          mMainPageBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.RGB_565);
          mDrawableCanvas = new Canvas();
          drawCurrentPage();
      }
  
      private void drawCurrentPage() {
          mDrawableCanvas.setBitmap(mMainPageBitmap);
  
          mDrawableCanvas.save(Canvas.MATRIX_SAVE_FLAG);
          mDrawableCanvas.translate(10, 20);
  
          Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG);
          paint.setColor(Color.BLUE);
          paint.setTextSize(30);
  
          mDrawableCanvas.drawLine(0, 50, getWidth(), 50, paint);
          mDrawableCanvas.drawText("test", 0, 4, 0, 0, paint);
  
          mDrawableCanvas.restore();
      }
  
      public void startDragging() {
          drawCurrentPage();
          // invalidate();
      }
  }
  </code></pre>
  
  <p>I had another project did that same but it haven't this issue, I compare both carefully then I find a little difference in onDraw method about Canvas instance. The work well version is use <strong>android.view.Surface$CompatibleCanvas</strong>, and the work wrong version is use <strong>android.view.GLES20RecordingCanvas</strong>, I'm not have OpenGL invoke anymore, so I don't know why it used, Is that difference make me wrong?
  <img src="https://i.stack.imgur.com/gCGFx.png" alt="CompatibleCanvas"></p>
  
  <p><img src="https://i.stack.imgur.com/Yb4DZ.png" alt="RecordingCanvas"></p>
  
  <p>---------------<strong>update 1</strong>---------------<br/>
  I'm look at <a href="http://developer.android.com/reference/android/view/View.html#onDraw%28android.graphics.Canvas%29" rel="nofollow noreferrer">Android View Drawing</a>, they said "If you set a background drawable for a View, then the View will draw it for you before calling back to its onDraw() method", so I have confirm I didn't set background to View neither XML Define or programmatically.<br/></p>
  
  <p>The <a href="http://developer.android.com/guide/topics/graphics/2d-graphics.html" rel="nofollow noreferrer">Android 2d-graphics</a> said "The Android framework will only call onDraw() as necessary", Does framework consider change Bitmap is unnecessary to be calling onDraw()?</p>