OSDN Git Service

am 79f2e1af: am e31564d8: Fix a crasher is surfaceflinger.
authorMathias Agopian <mathias@google.com>
Wed, 30 May 2012 04:09:04 +0000 (21:09 -0700)
committerAndroid Git Automerger <android-git-automerger@android.com>
Wed, 30 May 2012 04:09:04 +0000 (21:09 -0700)
* commit '79f2e1afbc08cd0cbcddc70cde5e3b7f1f0afea4':
  Fix a crasher is surfaceflinger.

services/surfaceflinger/Layer.cpp

index d07a4b6..5e17d07 100644 (file)
@@ -617,20 +617,20 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
             return;
         }
 
-
         // update the active buffer
         mActiveBuffer = mSurfaceTexture->getCurrentBuffer();
+        if (mActiveBuffer == NULL) {
+            // this can only happen if the very first buffer was rejected.
+            return;
+        }
 
         mFrameLatencyNeeded = true;
-        if (oldActiveBuffer == NULL && mActiveBuffer != NULL) {
+        if (oldActiveBuffer == NULL) {
              // the first time we receive a buffer, we need to trigger a
              // geometry invalidation.
              mFlinger->invalidateHwcGeometry();
          }
 
-        uint32_t bufWidth  = mActiveBuffer->getWidth();
-        uint32_t bufHeight = mActiveBuffer->getHeight();
-
         Rect crop(mSurfaceTexture->getCurrentCrop());
         const uint32_t transform(mSurfaceTexture->getCurrentTransform());
         const uint32_t scalingMode(mSurfaceTexture->getCurrentScalingMode());
@@ -645,6 +645,8 @@ void Layer::lockPageFlip(bool& recomputeVisibleRegions)
         }
 
         if (oldActiveBuffer != NULL) {
+            uint32_t bufWidth  = mActiveBuffer->getWidth();
+            uint32_t bufHeight = mActiveBuffer->getHeight();
             if (bufWidth != uint32_t(oldActiveBuffer->width) ||
                 bufHeight != uint32_t(oldActiveBuffer->height)) {
                 mFlinger->invalidateHwcGeometry();