OSDN Git Service

Save/restore display lists' canvas properly
authorRomain Guy <romainguy@google.com>
Thu, 8 Sep 2011 22:03:39 +0000 (15:03 -0700)
committerRomain Guy <romainguy@google.com>
Thu, 8 Sep 2011 22:05:26 +0000 (15:05 -0700)
Change-Id: Ic016f0215f9fe5c67af98f059ecce4ed94994810

core/java/android/view/View.java

index fd60813..4a9c5bd 100644 (file)
@@ -9995,6 +9995,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
             }
 
             final HardwareCanvas canvas = mDisplayList.start();
+            int restoreCount = 0;
             try {
                 int width = mRight - mLeft;
                 int height = mBottom - mTop;
@@ -10004,6 +10005,8 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
                 canvas.onPreDraw(null);
 
                 computeScroll();
+
+                restoreCount = canvas.save();
                 canvas.translate(-mScrollX, -mScrollY);
                 mPrivateFlags |= DRAWN | DRAWING_CACHE_VALID;
                 mPrivateFlags &= ~DIRTY_MASK;
@@ -10015,6 +10018,7 @@ public class View implements Drawable.Callback, Drawable.Callback2, KeyEvent.Cal
                     draw(canvas);
                 }
             } finally {
+                canvas.restoreToCount(restoreCount);
                 canvas.onPostDraw();
 
                 mDisplayList.end();