Choreographer源码

协调展示的基础类

  • 是ThreadLocal的,所有的run,都是在本Looper中
  • frame间隔是10ms不是16ms,避免掉帧
  • 使用DisplayEventReceiver同步vSync
  • 独立的final Object作为锁
  • 对于单次任务队列,最快的实现是用链表,使用时直接通过修改next将队列分割成两个
CallbackRecord callbacks = mHead;
            if (callbacks == null || callbacks.dueTime > now) {
                return null;
            }
            CallbackRecord last = callbacks;
            CallbackRecord next = last.next;
            while (next != null) {
                if (next.dueTime > now) {
                    last.next = null;
                    break;
                }
                last = next;
                next = next.next;
            }
            mHead = next;
            return callbacks;

你可能感兴趣的:(源码,android)