From 57998017ff137f7d4ec33df21b6596141f8c4547 Mon Sep 17 00:00:00 2001 From: John Reck Date: Thu, 29 Jan 2015 10:17:57 -0800 Subject: Allow ~Layer() to happen after onGLContextDestroyed Bug: 19146354 Change-Id: I9e885936168bd541bfbed4064ad67ab524f58e32 --- libs/hwui/Layer.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'libs/hwui/Layer.cpp') diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index 9aa29ca184d0..05259ff4f4b6 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -69,17 +69,25 @@ Layer::Layer(Type layerType, RenderState& renderState, const uint32_t layerWidth } Layer::~Layer() { - renderState.requireGLContext(); renderState.unregisterLayer(this); SkSafeUnref(colorFilter); - removeFbo(); - deleteTexture(); + + if (stencil || fbo || texture.id) { + renderState.requireGLContext(); + removeFbo(); + deleteTexture(); + } delete[] mesh; delete deferredList; delete renderer; } +void Layer::onGlContextLost() { + removeFbo(); + deleteTexture(); +} + uint32_t Layer::computeIdealWidth(uint32_t layerWidth) { return uint32_t(ceilf(layerWidth / float(LAYER_SIZE)) * LAYER_SIZE); } -- cgit v1.2.3-59-g8ed1b