OSDN Git Service

SurfaceView: Wait to gather transparent region.
authorRobert Carr <racarr@google.com>
Mon, 22 May 2017 21:57:48 +0000 (14:57 -0700)
committerandroid-build-team Robot <android-build-team-robot@google.com>
Tue, 23 May 2017 20:38:51 +0000 (20:38 +0000)
With the introduction of surfaceRedrawNeededAsync we may
be asked to gather the transparent region ahead of the SurfaceView
having been drawn.

Bug: 38324871
Test: Launch Chrome Canary a lot! No Flickers.
Change-Id: I35f09a1bb8316895fa704b10c912e64a8920bd90
(cherry picked from commit 3ca12be7963b0d018bade286bf4d14cf9938bd6a)

core/java/android/view/SurfaceView.java

index 2bb5f28..2c9b2e4 100644 (file)
@@ -138,6 +138,8 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
                 case DRAW_FINISHED_MSG: {
                     mDrawFinished = true;
                     if (mAttachedToWindow) {
+                        mParent.requestTransparentRegion(SurfaceView.this);
+
                         notifyDrawFinished();
                         invalidate();
                     }
@@ -247,7 +249,6 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
         getViewRootImpl().addWindowStoppedCallback(this);
         mWindowStopped = false;
 
-        mParent.requestTransparentRegion(this);
         mViewVisibility = getVisibility() == VISIBLE;
         updateRequestedVisibility();
 
@@ -352,7 +353,7 @@ public class SurfaceView extends View implements ViewRootImpl.WindowStoppedCallb
 
     @Override
     public boolean gatherTransparentRegion(Region region) {
-        if (isAboveParent()) {
+        if (isAboveParent() || !mDrawFinished) {
             return super.gatherTransparentRegion(region);
         }