summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/RenderThread.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2016-11-15 10:22:01 -0800
committerJohn Reck <jreck@google.com>2016-11-15 10:22:01 -0800
commit12efa55094b2fe38ef5ce232f3d8f02e78b71621 (patch)
treedfbe58808b0b9f5fd7d3491c97793c78c819b377 /libs/hwui/renderthread/RenderThread.cpp
parentceb9ec6dbfb5bd26aad1280e9aeb28ca17b8fcf8 (diff)
Avoid starving RT anims
Test: Manual, usleep(16000) in DrawFrameTask and tap on recents Change-Id: I88bb30a2503bc908ec45650c7d36b6fb3cc750d0
Diffstat (limited to 'libs/hwui/renderthread/RenderThread.cpp')
-rw-r--r--libs/hwui/renderthread/RenderThread.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp
index f3789c8d8cbb..b62c2188a666 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -21,6 +21,7 @@
#include "EglManager.h"
#include "RenderProxy.h"
#include "VulkanManager.h"
+#include "utils/FatVector.h"
#include <gui/DisplayEventReceiver.h>
#include <gui/ISurfaceComposer.h>
@@ -285,10 +286,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;