diff options
author | Romain Guy <romainguy@google.com> | 2013-06-17 13:14:51 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2013-06-17 13:35:03 -0700 |
commit | e93482f5eac3df581d57e64c2a771a96aa868585 (patch) | |
tree | 009afbdf49655b35ee29f857aa554a42c4e96048 /libs | |
parent | 6410c0aaf13c9aec606b90ee942f2ac2d98b1609 (diff) | |
download | frameworks_base-e93482f5eac3df581d57e64c2a771a96aa868585.zip frameworks_base-e93482f5eac3df581d57e64c2a771a96aa868585.tar.gz frameworks_base-e93482f5eac3df581d57e64c2a771a96aa868585.tar.bz2 |
Cancel layer update when a layer is about to be destroyed
Bug #9310706
Change-Id: I73eea6314c326f15a979617e3a05b525935f0d3f
Diffstat (limited to 'libs')
-rw-r--r-- | libs/hwui/Layer.cpp | 10 | ||||
-rw-r--r-- | libs/hwui/Layer.h | 1 | ||||
-rw-r--r-- | libs/hwui/LayerCache.cpp | 4 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 12 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 1 |
5 files changed, 25 insertions, 3 deletions
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(); |