Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9efa222b authored by Chris Craik's avatar Chris Craik
Browse files

Defer process mode upon draw

Process mode functor execution can be expensive, and cause dropped frames if it
runs between two expensive frames (when there isn't cpu time to spare). Avoid
this by delaying the process mode by an additional 4 ms every time we hit a draw

bug:7670326
Change-Id: I27f42458d4a815183a4b24c7748e05bc361fb943
parent f0afad00
Loading
Loading
Loading
Loading
+8 −12
Original line number Diff line number Diff line
@@ -1304,17 +1304,11 @@ public abstract class HardwareRenderer {
                }
            }

            if ((status & DisplayList.STATUS_INVOKE) != 0) {
                scheduleFunctors(attachInfo, true);
            }
        }

        private void scheduleFunctors(View.AttachInfo attachInfo, boolean delayed) {
            if ((status & DisplayList.STATUS_INVOKE) != 0 ||
                    attachInfo.mHandler.hasCallbacks(mFunctorsRunnable)) {
                attachInfo.mHandler.removeCallbacks(mFunctorsRunnable);
                mFunctorsRunnable.attachInfo = attachInfo;
            if (!attachInfo.mHandler.hasCallbacks(mFunctorsRunnable)) {
                // delay the functor callback by a few ms so it isn't polled constantly
                attachInfo.mHandler.postDelayed(mFunctorsRunnable,
                                                delayed ? FUNCTOR_PROCESS_DELAY : 0);
                attachInfo.mHandler.postDelayed(mFunctorsRunnable, FUNCTOR_PROCESS_DELAY);
            }
        }

@@ -1329,7 +1323,9 @@ public abstract class HardwareRenderer {
        boolean attachFunctor(View.AttachInfo attachInfo, int functor) {
            if (mCanvas != null) {
                mCanvas.attachFunctor(functor);
                scheduleFunctors(attachInfo, false);
                mFunctorsRunnable.attachInfo = attachInfo;
                attachInfo.mHandler.removeCallbacks(mFunctorsRunnable);
                attachInfo.mHandler.postDelayed(mFunctorsRunnable,  0);
                return true;
            }
            return false;