OSDN Git Service

Fix NPE in layer destruction
authorJohn Reck <jreck@google.com>
Thu, 20 Feb 2014 21:18:42 +0000 (13:18 -0800)
committerJohn Reck <jreck@google.com>
Thu, 20 Feb 2014 21:18:42 +0000 (13:18 -0800)
 Bug: 13111945
 Fixes an issue where a layer is destroyed after the GLRenderer
 lost its Surface. Instead just check that the context we want is
 current regardless of the active surface

Change-Id: I6537e6232b5c667b218b896ed5ef390fbe956344

core/java/android/view/GLRenderer.java

index abb59e3..d61c4b1 100644 (file)
@@ -499,12 +499,17 @@ public class GLRenderer extends HardwareRenderer {
         mAttachedLayers.add(hardwareLayer);
     }
 
+    boolean hasContext() {
+        return sEgl != null && mEglContext != null
+                && mEglContext.equals(sEgl.eglGetCurrentContext());
+    }
+
     @Override
     void onLayerDestroyed(HardwareLayer layer) {
         if (mGlCanvas != null) {
             mGlCanvas.cancelLayerUpdate(layer);
         }
-        if (Looper.myLooper() == Looper.getMainLooper() && validate()) {
+        if (hasContext()) {
             long backingLayer = layer.detachBackingLayer();
             nDestroyLayer(backingLayer);
         }