diff options
author | John Reck <jreck@google.com> | 2016-11-17 22:03:15 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2016-11-17 22:03:18 +0000 |
commit | 769ccdbc1e4f1acbc73a7c595fc5dbacf53a1702 (patch) | |
tree | 5dcdce781d72f22a526ffd5d463821a1974e3474 /libs/hwui/renderthread/RenderThread.cpp | |
parent | 29993074b0708d71b9d752f562ed6aee2a360fa1 (diff) | |
parent | 12efa55094b2fe38ef5ce232f3d8f02e78b71621 (diff) |
Merge "Avoid starving RT anims"
Diffstat (limited to 'libs/hwui/renderthread/RenderThread.cpp')
-rw-r--r-- | libs/hwui/renderthread/RenderThread.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 223958a3c319..e13d0ce6d688 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -23,6 +23,7 @@ #include "OpenGLReadback.h" #include "RenderProxy.h" #include "VulkanManager.h" +#include "utils/FatVector.h" #include <gui/DisplayEventReceiver.h> #include <gui/ISurfaceComposer.h> @@ -311,10 +312,18 @@ bool RenderThread::threadLoop() { "RenderThread Looper POLL_ERROR!"); nsecs_t nextWakeup; - // Process our queue, if we have anything - while (RenderTask* task = nextTask(&nextWakeup)) { - task->run(); - // task may have deleted itself, do not reference it again + { + FatVector<RenderTask*, 10> workQueue; + // Process our queue, if we have anything. By first acquiring + // all the pending events then processing them we avoid vsync + // starvation if more tasks are queued while we are processing tasks. + while (RenderTask* task = nextTask(&nextWakeup)) { + workQueue.push_back(task); + } + for (auto task : workQueue) { + task->run(); + // task may have deleted itself, do not reference it again + } } if (nextWakeup == LLONG_MAX) { timeoutMillis = -1; |