summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/RenderThread.cpp
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2016-11-18 00:14:05 +0000
committerandroid-build-merger <android-build-merger@google.com>2016-11-18 00:14:05 +0000
commit7269372d5f6a972e1878c37a07deca1e47c6f5fa (patch)
treed5a75b6470d07474bed35c2dffd16e7b9a9d5f3e /libs/hwui/renderthread/RenderThread.cpp
parent90b6e786572d037148e3987c5bd9dd741c2dec4d (diff)
parentf77c220aa9233f7bb8418d01f7c512bcca7d3f74 (diff)
Merge "Avoid starving RT anims"
am: f77c220aa9 Change-Id: I3d4ba24ae0e6de4683d47163fd8f3bf65b98bd17
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 968834056ae1..9c10c4fdbad1 100644
--- a/libs/hwui/renderthread/RenderThread.cpp
+++ b/libs/hwui/renderthread/RenderThread.cpp
@@ -20,6 +20,7 @@
#include "CanvasContext.h"
#include "EglManager.h"
#include "RenderProxy.h"
+#include "utils/FatVector.h"
#include <gui/DisplayEventReceiver.h>
#include <gui/ISurfaceComposer.h>
@@ -282,10 +283,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;