summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/RenderThread.h
diff options
context:
space:
mode:
Diffstat (limited to 'libs/hwui/renderthread/RenderThread.h')
-rw-r--r--libs/hwui/renderthread/RenderThread.h57
1 files changed, 19 insertions, 38 deletions
diff --git a/libs/hwui/renderthread/RenderThread.h b/libs/hwui/renderthread/RenderThread.h
index bef47b3e27c5..3aa548773b3b 100644
--- a/libs/hwui/renderthread/RenderThread.h
+++ b/libs/hwui/renderthread/RenderThread.h
@@ -22,15 +22,18 @@
#include "../JankTracker.h"
#include "CacheManager.h"
#include "TimeLord.h"
+#include "thread/ThreadBase.h"
#include <GrContext.h>
-#include <cutils/compiler.h>
#include <SkBitmap.h>
+#include <cutils/compiler.h>
#include <ui/DisplayInfo.h>
#include <utils/Looper.h>
#include <utils/Thread.h>
+#include <thread/ThreadBase.h>
#include <memory>
+#include <mutex>
#include <set>
namespace android {
@@ -47,26 +50,10 @@ class TestUtils;
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,14 @@ protected:
~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);
+ // Sets a callback that fires before any RenderThread setup has occured.
+ ANDROID_API static void setOnStartHook(void (*onStartHook)());
+
+ WorkQueue& queue() { return ThreadBase::queue(); }
// Mimics android.view.Choreographer
void postFrameCallback(IFrameCallback* callback);
@@ -103,7 +88,7 @@ public:
const DisplayInfo& mainDisplayInfo() { return mDisplayInfo; }
GrContext* getGrContext() const { return mGrContext.get(); }
- void setGrContext(GrContext* cxt);
+ void setGrContext(sk_sp<GrContext> cxt);
CacheManager& cacheManager() { return *mCacheManager; }
VulkanManager& vulkanManager() { return *mVkManager; }
@@ -111,6 +96,14 @@ public:
sk_sp<Bitmap> allocateHardwareBitmap(SkBitmap& skBitmap);
void dumpGraphicsMemory(int fd);
+ /**
+ * isCurrent provides a way to query, if the caller is running on
+ * the render thread.
+ *
+ * @return true only if isCurrent is invoked from the render thread.
+ */
+ static bool isCurrent();
+
protected:
virtual bool threadLoop() override;
@@ -132,17 +125,6 @@ private:
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;
@@ -154,7 +136,6 @@ private:
// the previous one
std::set<IFrameCallback*> mPendingRegistrationFrameCallbacks;
bool mFrameCallbackTaskPending;
- DispatchFrameCallbacks* mFrameCallbackTask;
TimeLord mTimeLord;
RenderState* mRenderState;