summaryrefslogtreecommitdiff
path: root/libs/hwui/Layer.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2015-01-29 10:17:57 -0800
committerJohn Reck <jreck@google.com>2015-01-29 10:17:57 -0800
commit57998017ff137f7d4ec33df21b6596141f8c4547 (patch)
treeed9786692ee5727eacea084f12ea417b1d0f7915 /libs/hwui/Layer.cpp
parent8514766a0a388c3598eaa64709edc634f8edccb1 (diff)
Allow ~Layer() to happen after onGLContextDestroyed
Bug: 19146354 Change-Id: I9e885936168bd541bfbed4064ad67ab524f58e32
Diffstat (limited to 'libs/hwui/Layer.cpp')
-rw-r--r--libs/hwui/Layer.cpp14
1 files changed, 11 insertions, 3 deletions
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);
}