Bag of scheduling tweaks
Bug: 15118640 * Prevent over-stuffing the queue by dropping frames * Prevent double-drawing in one pulse by RT by deferring vsync registration until post-draw so that it catches the next vsync pulse instead of the current one * Bias vsync race condition towards the UI thread * Fix queueDelay to actually work Change-Id: Ibf584258bd93ebcbba058bd976dc8b307f1c6155
This commit is contained in:
@@ -87,7 +87,13 @@ void DrawFrameTask::postAndWait() {
|
||||
void DrawFrameTask::run() {
|
||||
ATRACE_NAME("DrawFrame");
|
||||
|
||||
bool canUnblockUiThread = syncFrameState();
|
||||
bool canUnblockUiThread;
|
||||
bool canDrawThisFrame;
|
||||
{
|
||||
TreeInfo info;
|
||||
canUnblockUiThread = syncFrameState(info);
|
||||
canDrawThisFrame = info.out.canDrawThisFrame;
|
||||
}
|
||||
|
||||
// Grab a copy of everything we need
|
||||
Rect dirty(mDirty);
|
||||
@@ -98,7 +104,9 @@ void DrawFrameTask::run() {
|
||||
unblockUiThread();
|
||||
}
|
||||
|
||||
context->draw(&dirty);
|
||||
if (CC_LIKELY(canDrawThisFrame)) {
|
||||
context->draw(&dirty);
|
||||
}
|
||||
|
||||
if (!canUnblockUiThread) {
|
||||
unblockUiThread();
|
||||
@@ -111,12 +119,11 @@ static void initTreeInfo(TreeInfo& info) {
|
||||
info.evaluateAnimations = true;
|
||||
}
|
||||
|
||||
bool DrawFrameTask::syncFrameState() {
|
||||
bool DrawFrameTask::syncFrameState(TreeInfo& info) {
|
||||
ATRACE_CALL();
|
||||
mRenderThread->timeLord().vsyncReceived(mFrameTimeNanos);
|
||||
mContext->makeCurrent();
|
||||
Caches::getInstance().textureCache.resetMarkInUse();
|
||||
TreeInfo info;
|
||||
initTreeInfo(info);
|
||||
mContext->prepareDraw(&mLayers, info);
|
||||
if (info.out.hasAnimations) {
|
||||
|
||||
Reference in New Issue
Block a user