Switch to a fancy new queue

Test: unit tests & benchmarks pass/faster

Change-Id: I9521432172d6dd6039c5280b1265479a36a86247
diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h
index 30884b5..e1d61c5 100644
--- a/libs/hwui/renderthread/RenderThread.h
+++ b/libs/hwui/renderthread/RenderThread.h
@@ -22,6 +22,7 @@
 #include "../JankTracker.h"
 #include "CacheManager.h"
 #include "TimeLord.h"
+#include "thread/ThreadBase.h"
 
 #include <GrContext.h>
 #include <cutils/compiler.h>
@@ -31,7 +32,9 @@
 #include <utils/Thread.h>
 
 #include <memory>
+#include <mutex>
 #include <set>
+#include <thread/ThreadBase.h>
 
 namespace android {
 
@@ -47,26 +50,10 @@
 namespace renderthread {
 
 class CanvasContext;
-class DispatchFrameCallbacks;
 class EglManager;
 class RenderProxy;
 class VulkanManager;
 
-class TaskQueue {
-public:
-    TaskQueue();
-
-    RenderTask* next();
-    void queue(RenderTask* task);
-    void queueAtFront(RenderTask* task);
-    RenderTask* peek();
-    void remove(RenderTask* task);
-
-private:
-    RenderTask* mHead;
-    RenderTask* mTail;
-};
-
 // Mimics android.view.Choreographer.FrameCallback
 class IFrameCallback {
 public:
@@ -76,16 +63,11 @@
     ~IFrameCallback() {}
 };
 
-class ANDROID_API RenderThread : public Thread {
+class RenderThread : private ThreadBase {
     PREVENT_COPY_AND_ASSIGN(RenderThread);
 public:
-    // RenderThread takes complete ownership of tasks that are queued
-    // and will delete them after they are run
-    ANDROID_API void queue(RenderTask* task);
-    ANDROID_API void queueAndWait(RenderTask* task);
-    ANDROID_API void queueAtFront(RenderTask* task);
-    void queueAt(RenderTask* task, nsecs_t runAtNs);
-    void remove(RenderTask* task);
+
+    WorkQueue& queue() { return ThreadBase::queue(); }
 
     // Mimics android.view.Choreographer
     void postFrameCallback(IFrameCallback* callback);
@@ -140,17 +122,6 @@
     void dispatchFrameCallbacks();
     void requestVsync();
 
-    // Returns the next task to be run. If this returns NULL nextWakeup is set
-    // to the time to requery for the nextTask to run. mNextWakeup is also
-    // set to this time
-    RenderTask* nextTask(nsecs_t* nextWakeup);
-
-    sp<Looper> mLooper;
-    Mutex mLock;
-
-    nsecs_t mNextWakeup;
-    TaskQueue mQueue;
-
     DisplayInfo mDisplayInfo;
 
     DisplayEventReceiver* mDisplayEventReceiver;
@@ -162,7 +133,6 @@
     // the previous one
     std::set<IFrameCallback*> mPendingRegistrationFrameCallbacks;
     bool mFrameCallbackTaskPending;
-    DispatchFrameCallbacks* mFrameCallbackTask;
 
     TimeLord mTimeLord;
     RenderState* mRenderState;