From a12b2405df5c12363e24cebc684f5f3a5c9a5b7b Mon Sep 17 00:00:00 2001 From: Sangkyu Lee Date: Fri, 21 Nov 2014 18:05:41 +0900 Subject: [PATCH] Prevent calling GL functions with an invalid surface Bug: 18518580 When destroying CanvasContext, the surface can be invalid state. So the surface should be updated to null prior to destroying GL resources to ensure that GL functions are not called with an invalid surface. Some GL implementation makes an error if GL functions are called with an invalid surface. (Adreno 3xx) Cherry picked from AOSP: f76d36f96bf221672e98e440c9df7cbf0e02e84e Change-Id: Ie6f6ea081ec931fc9df30b2c3ed066ec1ae9d294 --- libs/hwui/renderthread/CanvasContext.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp index 39528be830df3..aa32541139da6 100644 --- a/libs/hwui/renderthread/CanvasContext.cpp +++ b/libs/hwui/renderthread/CanvasContext.cpp @@ -60,6 +60,7 @@ CanvasContext::~CanvasContext() { void CanvasContext::destroy() { stopDrawing(); + setSurface(NULL); freePrefetechedLayers(); destroyHardwareResources(); mAnimationContext->destroy(); @@ -67,7 +68,6 @@ void CanvasContext::destroy() { delete mCanvas; mCanvas = 0; } - setSurface(NULL); } void CanvasContext::setSurface(ANativeWindow* window) {