/** Draws the header of a task used for the window animation into a bitmap. */
 Bitmap drawThumbnailTransitionBitmap(Task toTask, TaskViewTransform toTransform) {
   if (toTransform != null && toTask.key != null) {
     Bitmap thumbnail;
     synchronized (mHeaderBarLock) {
       int toHeaderWidth = (int) (mHeaderBar.getMeasuredWidth() * toTransform.scale);
       int toHeaderHeight = (int) (mHeaderBar.getMeasuredHeight() * toTransform.scale);
       thumbnail = Bitmap.createBitmap(toHeaderWidth, toHeaderHeight, Bitmap.Config.ARGB_8888);
       if (Constants.DebugFlags.App.EnableTransitionThumbnailDebugMode) {
         thumbnail.eraseColor(0xFFff0000);
       } else {
         Canvas c = new Canvas(thumbnail);
         c.scale(toTransform.scale, toTransform.scale);
         mHeaderBar.rebindToTask(toTask);
         mHeaderBar.draw(c);
         c.setBitmap(null);
       }
     }
     return thumbnail.createAshmemBitmap();
   }
   return null;
 }