From e93482f5eac3df581d57e64c2a771a96aa868585 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 17 Jun 2013 13:14:51 -0700 Subject: Cancel layer update when a layer is about to be destroyed Bug #9310706 Change-Id: I73eea6314c326f15a979617e3a05b525935f0d3f --- libs/hwui/Layer.cpp | 10 ++++++++++ libs/hwui/Layer.h | 1 + libs/hwui/LayerCache.cpp | 4 +--- libs/hwui/OpenGLRenderer.cpp | 12 ++++++++++++ libs/hwui/OpenGLRenderer.h | 1 + 5 files changed, 25 insertions(+), 3 deletions(-) (limited to 'libs') diff --git a/libs/hwui/Layer.cpp b/libs/hwui/Layer.cpp index 7c22bbb..f409d3e 100644 --- a/libs/hwui/Layer.cpp +++ b/libs/hwui/Layer.cpp @@ -213,6 +213,16 @@ void Layer::defer() { deferredUpdateScheduled = false; } +void Layer::cancelDefer() { + renderer = NULL; + displayList = NULL; + deferredUpdateScheduled = false; + if (deferredList) { + delete deferredList; + deferredList = NULL; + } +} + void Layer::flush() { if (deferredList) { renderer->setViewport(layer.getWidth(), layer.getHeight()); diff --git a/libs/hwui/Layer.h b/libs/hwui/Layer.h index 326b25a..ebd5543 100644 --- a/libs/hwui/Layer.h +++ b/libs/hwui/Layer.h @@ -245,6 +245,7 @@ struct Layer { } void defer(); + void cancelDefer(); void flush(); void render(); diff --git a/libs/hwui/LayerCache.cpp b/libs/hwui/LayerCache.cpp index a0709af..6be0146 100644 --- a/libs/hwui/LayerCache.cpp +++ b/libs/hwui/LayerCache.cpp @@ -155,9 +155,7 @@ bool LayerCache::put(Layer* layer) { victim->layer.getHeight()); } - layer->deferredUpdateScheduled = false; - layer->renderer = NULL; - layer->displayList = NULL; + layer->cancelDefer(); LayerEntry entry(layer); diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 05f43a9..a704b3d 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -655,6 +655,18 @@ void OpenGLRenderer::pushLayerUpdate(Layer* layer) { } } +void OpenGLRenderer::cancelLayerUpdate(Layer* layer) { + if (layer) { + for (int i = mLayerUpdates.size() - 1; i >= 0; i--) { + if (mLayerUpdates.itemAt(i) == layer) { + mLayerUpdates.removeAt(i); + mCaches.resourceCache.decrementRefcount(layer); + break; + } + } + } +} + void OpenGLRenderer::clearLayerUpdates() { size_t count = mLayerUpdates.size(); if (count > 0) { diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 5b7f90d..18d39ef 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -217,6 +217,7 @@ public: virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty); ANDROID_API void pushLayerUpdate(Layer* layer); + ANDROID_API void cancelLayerUpdate(Layer* layer); ANDROID_API void clearLayerUpdates(); ANDROID_API void flushLayerUpdates(); -- cgit v1.1