Skip to content

Commit 3561d06

Browse files
committed
Handle offscreen animations correctly
A bug in software rendering caused animations on views that are offscreen to not get drawn, therefore the animation doesn't continue (since old-style animations depend on the logic in the drawing code to keep running). Fix is to special case the isAnimating case in ViewRoot to go ahead and schedule a traversal even if the dirty rect does not intersect with the visible region. Issue #7396035 Animations starting offscreen don't draw run/end/draw properly (sw rendering only) Change-Id: Iae25b3a424ddc5a16ba431ecd68cf42d5500db3f
1 parent 7443753 commit 3561d06

File tree

2 files changed

+17
-16
lines changed

2 files changed

+17
-16
lines changed

core/java/android/view/ViewRootImpl.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -861,7 +861,7 @@ public ViewParent invalidateChildInParent(int[] location, Rect dirty) {
861861
if (dirty == null) {
862862
invalidate();
863863
return null;
864-
} else if (dirty.isEmpty()) {
864+
} else if (dirty.isEmpty() && !mIsAnimating) {
865865
return null;
866866
}
867867

@@ -890,14 +890,14 @@ public ViewParent invalidateChildInParent(int[] location, Rect dirty) {
890890
// Intersect with the bounds of the window to skip
891891
// updates that lie outside of the visible region
892892
final float appScale = mAttachInfo.mApplicationScale;
893-
if (localDirty.intersect(0, 0,
894-
(int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f))) {
895-
if (!mWillDrawSoon) {
896-
scheduleTraversals();
897-
}
898-
} else {
893+
final boolean intersected = localDirty.intersect(0, 0,
894+
(int) (mWidth * appScale + 0.5f), (int) (mHeight * appScale + 0.5f));
895+
if (!intersected) {
899896
localDirty.setEmpty();
900897
}
898+
if (!mWillDrawSoon && (intersected || mIsAnimating)) {
899+
scheduleTraversals();
900+
}
901901

902902
return null;
903903
}

libs/hwui/DisplayListRenderer.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -763,16 +763,17 @@ void DisplayList::outputViewProperties(OpenGLRenderer& renderer, char* indent) {
763763
}
764764
}
765765
if (mAlpha < 1 && !mCaching) {
766-
// TODO: should be able to store the size of a DL at record time and not
767-
// have to pass it into this call. In fact, this information might be in the
768-
// location/size info that we store with the new native transform data.
769-
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
770-
if (mClipChildren) {
771-
flags |= SkCanvas::kClipToLayer_SaveFlag;
766+
if (!mHasOverlappingRendering) {
767+
ALOGD("%s%s %.2f", indent, "SetAlpha", mAlpha);
768+
} else {
769+
int flags = SkCanvas::kHasAlphaLayer_SaveFlag;
770+
if (mClipChildren) {
771+
flags |= SkCanvas::kClipToLayer_SaveFlag;
772+
}
773+
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
774+
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
775+
mMultipliedAlpha, flags);
772776
}
773-
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f, %d, 0x%x", indent, "SaveLayerAlpha",
774-
(float) 0, (float) 0, (float) mRight - mLeft, (float) mBottom - mTop,
775-
mMultipliedAlpha, flags);
776777
}
777778
if (mClipChildren) {
778779
ALOGD("%s%s %.2f, %.2f, %.2f, %.2f", indent, "ClipRect", 0.0f, 0.0f,

0 commit comments

Comments
 (0)