am d7af6eaa: am d51205fd: am 6afc5cf3: Merge "Prevent calling GL functions with an invalid surface"

* commit 'd7af6eaace4ffdd3635a1cdeff65e9dc1af39f67':
  Prevent calling GL functions with an invalid surface
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index ee629c0..940580c 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -60,6 +60,7 @@
 
 void CanvasContext::destroy() {
     stopDrawing();
+    setSurface(NULL);
     freePrefetechedLayers();
     destroyHardwareResources();
     mAnimationContext->destroy();
@@ -67,7 +68,6 @@
         delete mCanvas;
         mCanvas = 0;
     }
-    setSurface(NULL);
 }
 
 void CanvasContext::setSurface(ANativeWindow* window) {