Merge "Fix NPE in layer destruction"

This commit is contained in:
John Reck
2014-02-20 21:24:29 +00:00
committed by Android (Google) Code Review

View 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);
}