diff options
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Layer.cpp | 2 | ||||
-rw-r--r-- | libs/hwui/RenderState.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/RenderState.h | 10 | ||||
-rw-r--r-- | libs/hwui/renderthread/EglManager.cpp | 1 |
4 files changed, 17 insertions, 0 deletions
diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index 8639ae1..e6bc4db 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -54,9 +54,11 @@ Layer::Layer(RenderState& renderState, const uint32_t layerWidth, const uint32_t convexMask = NULL; caches.resourceCache.incrementRefcount(this); rendererLightPosDirty = true; + renderState.registerLayer(this); } Layer::~Layer() { + renderState.unregisterLayer(this); SkSafeUnref(colorFilter); removeFbo(); deleteTexture(); diff --git a/libs/hwui/RenderState.cpp b/libs/hwui/RenderState.cpp index 97f379d..50b8f39 100644 --- a/libs/hwui/RenderState.cpp +++ b/libs/hwui/RenderState.cpp @@ -34,6 +34,10 @@ void RenderState::onGLContextCreated() { mCaches->init(); } +void RenderState::onGLContextDestroyed() { + LOG_ALWAYS_FATAL_IF(!mActiveLayers.empty(), "layers have survived gl context destruction"); +} + void RenderState::setViewport(GLsizei width, GLsizei height) { mViewportWidth = width; mViewportHeight = height; diff --git a/libs/hwui/RenderState.h b/libs/hwui/RenderState.h index f7116e2..cd71c73 100644 --- a/libs/hwui/RenderState.h +++ b/libs/hwui/RenderState.h @@ -16,6 +16,7 @@ #ifndef RENDERSTATE_H #define RENDERSTATE_H +#include <set> #include <GLES2/gl2.h> #include <GLES2/gl2ext.h> @@ -37,6 +38,7 @@ class RenderState { PREVENT_COPY_AND_ASSIGN(RenderState); public: void onGLContextCreated(); + void onGLContextDestroyed(); void setViewport(GLsizei width, GLsizei height); void getViewport(GLsizei* outWidth, GLsizei* outHeight); @@ -48,6 +50,13 @@ public: void debugOverdraw(bool enable, bool clear); + void registerLayer(const Layer* layer) { + mActiveLayers.insert(layer); + } + void unregisterLayer(const Layer* layer) { + mActiveLayers.erase(layer); + } + private: friend class renderthread::RenderThread; @@ -58,6 +67,7 @@ private: ~RenderState(); Caches* mCaches; + std::set<const Layer*> mActiveLayers; GLsizei mViewportWidth; GLsizei mViewportHeight; diff --git a/libs/hwui/renderthread/EglManager.cpp b/libs/hwui/renderthread/EglManager.cpp index 05ca34d..37f8e60 100644 --- a/libs/hwui/renderthread/EglManager.cpp +++ b/libs/hwui/renderthread/EglManager.cpp @@ -214,6 +214,7 @@ void EglManager::destroy() { Caches::getInstance().terminate(); } + mRenderThread.renderState().onGLContextDestroyed(); eglDestroyContext(mEglDisplay, mEglContext); eglDestroySurface(mEglDisplay, mPBufferSurface); eglMakeCurrent(mEglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); |