Merge "Handle offscreen animations correctly" into jb-mr1-dev
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index fa79b07..cd63f07 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -859,7 +859,7 @@
         if (dirty == null) {
             invalidate();
             return null;
-        } else if (dirty.isEmpty()) {
+        } else if (dirty.isEmpty() && !mIsAnimating) {
             return null;
         }
 
@@ -888,14 +888,14 @@
         // Intersect with the bounds of the window to skip
         // updates that lie outside of the visible region
         final float appScale = mAttachInfo.mApplicationScale;
-        if (localDirty.intersect(0, 0,
-                (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f))) {
-            if (!mWillDrawSoon) {
-                scheduleTraversals();
-            }
-        } else {
+        final boolean intersected = localDirty.intersect(0, 0,
+                (int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f));
+        if (!intersected) {
             localDirty.setEmpty();
         }
+        if (!mWillDrawSoon && (intersected || mIsAnimating)) {
+            scheduleTraversals();
+        }
 
         return null;
     }
diff --git a/libs/hwui/DisplayListRenderer.cpp b/libs/hwui/DisplayListRenderer.cpp
index 81e68bd..7a38b40 100644
--- a/libs/hwui/DisplayListRenderer.cpp
+++ b/libs/hwui/DisplayListRenderer.cpp
@@ -763,16 +763,17 @@
         }
     }
     if (mAlpha < 1 && !mCaching) {
-        // TODO: should be able to store the size of a DL at record time and not
-        // have to pass it into this call. In fact, this information might be in the
-        // location/size info that we store with the new native transform data.
-        int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
-        if (mClipChildren) {
-            flags |= SkCanvas::kClipToLayer_SaveFlag;
+        if (!mHasOverlappingRendering) {
+            ALOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
+        } else {
+            int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
+            if (mClipChildren) {
+                flags |= SkCanvas::kClipToLayer_SaveFlag;
+            }
+            ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
+                    (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
+                    mMultipliedAlpha, flags);
         }
-        ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
-                (float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
-                mMultipliedAlpha, flags);
     }
     if (mClipChildren) {
         ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,