title: SurfaceView has two buffer?
body: <p>the android offical said:"On each pass you retrieve the Canvas from the <code>SurfaceHolder</code>, the previous state of the Canvas will be retained. In order to properly animate your graphics, you must re-paint the entire surface. For example, you can clear the previous state of the Canvas by filling in a color with <code>drawColor()</code> or setting a background image with <code>drawBitmap()</code>. Otherwise, you will see traces of the drawings you previously performed."</p>
  
  <p>Then I write some code to verify the two buffer.The code is as follow:</p>
  
  <pre class="lang-java prettyprint-override"><code> public class MainActivity extends Activity {
  
      private SurfaceView iv;
      private int flag=0;
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          iv=(SurfaceView) findViewById(R.id.sv);
  
      }
      public void draw(View view){
  
          new Thread(new Runnable() {
  
              @Override
              public void run() {
                  // TODO Auto-generated method stub
  
  
  
                  Paint paint=new Paint();
  
                  SurfaceHolder holder1 = iv.getHolder();
  
                  RectF r=new RectF(300,300,600,600);
                  switch(flag){
                  case 0: {Canvas canvas=holder1.lockCanvas();
                          canvas.drawColor(Color.RED);
                          holder1.unlockCanvasAndPost(canvas);
                          Log.d("ddd",flag+"");
                          flag++;}
                          break;
                  case 1:
                      {Canvas canvas=holder1.lockCanvas();
                      canvas.drawColor(Color.BLUE);
                      holder1.unlockCanvasAndPost(canvas);
                      Log.d("ddd",flag+"");
                      flag++;}
                      break;
                  case 2:
                  {
                      Canvas canvas=holder1.lockCanvas();
                      holder1.unlockCanvasAndPost(canvas);
                      Log.d("ddd",flag+"");
                  }
                      break;
                  }
              }
          }).start();
      }
      }
  </code></pre>
  
  <p>the xml file is as follow:
  </p>
  
  <pre><code>&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:orientation="vertical"&gt;
  
      &lt;Button android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:text="划线"
          android:onClick="draw"/&gt;
      &lt;SurfaceView android:layout_width="match_parent"
          android:layout_height="match_parent"
          android:id="@+id/sv"/&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>If the <code>SurfaceView</code> has two buffer,then when the <code>flag==2</code> ,the front buffer is blue and the behind buffer is red.So when I click the button the <code>SurfaceView</code> will change its color between red and blue.But the fact is that <code>SurfaceView</code> change its color among red,blue and black(the <code>SurfaceView's</code> background color is black by default).Does <code>SurfaceView</code> has three buffers?</p>