diff options
author | Romain Guy <romainguy@google.com> | 2012-04-23 18:22:09 -0700 |
---|---|---|
committer | Romain Guy <romainguy@google.com> | 2012-04-23 20:29:31 -0700 |
commit | ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47 (patch) | |
tree | 04f9b4d5589333970c91e51af6280a5859b78460 /libs/hwui | |
parent | 88fffb7a34313d5e94b3974d444d07bd6a4879a4 (diff) | |
download | frameworks_base-ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47.zip frameworks_base-ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47.tar.gz frameworks_base-ba6be8a62dcdb3ffd210cd36b9af4e3a658eac47.tar.bz2 |
Prevent WebView from crashing when detached from the window
Bug #6365056
WebView enqueues a functor in the hardware renderer to handle
animations and this functor is called at a later time by the
hardware renderer. However, the functor was not removed from
the queue when WebView was removed from the window. This could
cause the hardware renderer to attempt to execute an invalid
functor and lead to a crash.
Change-Id: I9d38e80f3fdc5e29d4d0cdfa1e893c251a954508
Diffstat (limited to 'libs/hwui')
-rw-r--r-- | libs/hwui/OpenGLRenderer.cpp | 52 | ||||
-rw-r--r-- | libs/hwui/OpenGLRenderer.h | 5 |
2 files changed, 35 insertions, 22 deletions
diff --git a/libs/hwui/OpenGLRenderer.cpp b/libs/hwui/OpenGLRenderer.cpp index 5edaa46..9f337ff 100644 --- a/libs/hwui/OpenGLRenderer.cpp +++ b/libs/hwui/OpenGLRenderer.cpp @@ -237,33 +237,43 @@ void OpenGLRenderer::resume() { glBlendEquation(GL_FUNC_ADD); } +void OpenGLRenderer::detachFunctor(Functor* functor) { + mFunctors.remove(functor); +} + +void OpenGLRenderer::attachFunctor(Functor* functor) { + mFunctors.add(functor); +} + status_t OpenGLRenderer::invokeFunctors(Rect& dirty) { status_t result = DrawGlInfo::kStatusDone; + size_t count = functors.size(); - Vector<Functor*> functors(mFunctors); - mFunctors.clear(); + if (count > 0) { + SortedVector<Functor*> functors(mFunctors); + mFunctors.clear(); - DrawGlInfo info; - info.clipLeft = 0; - info.clipTop = 0; - info.clipRight = 0; - info.clipBottom = 0; - info.isLayer = false; - info.width = 0; - info.height = 0; - memset(info.transform, 0, sizeof(float) * 16); + DrawGlInfo info; + info.clipLeft = 0; + info.clipTop = 0; + info.clipRight = 0; + info.clipBottom = 0; + info.isLayer = false; + info.width = 0; + info.height = 0; + memset(info.transform, 0, sizeof(float) * 16); - size_t count = functors.size(); - for (size_t i = 0; i < count; i++) { - Functor* f = functors.itemAt(i); - result |= (*f)(DrawGlInfo::kModeProcess, &info); + for (size_t i = 0; i < count; i++) { + Functor* f = functors.itemAt(i); + result |= (*f)(DrawGlInfo::kModeProcess, &info); - if (result != DrawGlInfo::kStatusDone) { - Rect localDirty(info.dirtyLeft, info.dirtyTop, info.dirtyRight, info.dirtyBottom); - dirty.unionWith(localDirty); + if (result != DrawGlInfo::kStatusDone) { + Rect localDirty(info.dirtyLeft, info.dirtyTop, info.dirtyRight, info.dirtyBottom); + dirty.unionWith(localDirty); - if (result & DrawGlInfo::kStatusInvoke) { - mFunctors.push(f); + if (result & DrawGlInfo::kStatusInvoke) { + mFunctors.add(f); + } } } } @@ -305,7 +315,7 @@ status_t OpenGLRenderer::callDrawGLFunction(Functor* functor, Rect& dirty) { dirty.unionWith(localDirty); if (result & DrawGlInfo::kStatusInvoke) { - mFunctors.push(functor); + mFunctors.add(functor); } } diff --git a/libs/hwui/OpenGLRenderer.h b/libs/hwui/OpenGLRenderer.h index 141e22b..18a6923 100644 --- a/libs/hwui/OpenGLRenderer.h +++ b/libs/hwui/OpenGLRenderer.h @@ -29,6 +29,7 @@ #include <utils/Functor.h> #include <utils/RefBase.h> +#include <utils/SortedVector.h> #include <utils/Vector.h> #include <cutils/compiler.h> @@ -73,6 +74,8 @@ public: virtual void resume(); ANDROID_API status_t invokeFunctors(Rect& dirty); + ANDROID_API void detachFunctor(Functor* functor); + ANDROID_API void attachFunctor(Functor* functor); virtual status_t callDrawGLFunction(Functor* functor, Rect& dirty); ANDROID_API int getSaveCount() const; @@ -612,7 +615,7 @@ private: // List of rectangles to clear after saveLayer() is invoked Vector<Rect*> mLayers; // List of functors to invoke after a frame is drawn - Vector<Functor*> mFunctors; + SortedVector<Functor*> mFunctors; // Indentity matrix const mat4 mIdentity; |