summaryrefslogtreecommitdiff
path: root/libs/hwui/renderthread/RenderTask.h
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2014-01-03 18:09:17 -0800
committerJohn Reck <jreck@google.com>2014-01-27 16:40:39 -0800
commit4f02bf4eef6af47f35c70c4dda5b7b9523d89ca0 (patch)
tree59140e036199cbd7a12886e1a2500cb69c8bbdda /libs/hwui/renderthread/RenderTask.h
parent8435cf0d8b9e24715d5b310ed569fda918dcaa46 (diff)
Native-side proxy
Remove RemoteGLRenderer Remove reflection-based control Change-Id: If17c2bbb61c7141986d88c4763def77ed1074985
Diffstat (limited to 'libs/hwui/renderthread/RenderTask.h')
-rw-r--r--libs/hwui/renderthread/RenderTask.h64
1 files changed, 62 insertions, 2 deletions
diff --git a/libs/hwui/renderthread/RenderTask.h b/libs/hwui/renderthread/RenderTask.h
index 865b1e6fced1..9fe7573f71b7 100644
--- a/libs/hwui/renderthread/RenderTask.h
+++ b/libs/hwui/renderthread/RenderTask.h
@@ -18,19 +18,79 @@
#define RENDERTASK_H_
#include <cutils/compiler.h>
+#include <utils/Timers.h>
namespace android {
+class Mutex;
+class Condition;
namespace uirenderer {
namespace renderthread {
+#define METHOD_INVOKE_PAYLOAD_SIZE (8 * sizeof(void*))
+
+/*
+ * Notes about memory management
+ *
+ * RenderThread will only invoke RenderTask::run(). It is the responsibility
+ * of the RenderTask to know if it needs to suicide at the end of run() or
+ * if some other lifecycle is being used. As such, it is not valid to reference
+ * anything on RenderTask after the first call to run().
+ *
+ * For example SignalingRenderTask
+ * is expected to be stack allocated by the calling thread, so it does not
+ * suicide in run() but instead relies on the caller to destroy it.
+ *
+ * MethodInvokeRenderTask however is currently allocated with new, so it will
+ * suicide at the end of run(). TODO: Replace this with a small pool to avoid
+ * malloc/free churn of small objects?
+ */
+
class ANDROID_API RenderTask {
public:
- ANDROID_API RenderTask();
- ANDROID_API virtual ~RenderTask();
+ ANDROID_API RenderTask() : mNext(0), mRunAt(0) {}
+ ANDROID_API virtual ~RenderTask() {}
ANDROID_API virtual void run() = 0;
RenderTask* mNext;
+ nsecs_t mRunAt;
+};
+
+class SignalingRenderTask : public RenderTask {
+public:
+ // Takes ownership of task, caller owns lock and signal
+ SignalingRenderTask(RenderTask* task, Mutex* lock, Condition* signal)
+ : mTask(task), mLock(lock), mSignal(signal) {}
+ virtual void run();
+
+private:
+ RenderTask* mTask;
+ Mutex* mLock;
+ Condition* mSignal;
+};
+
+typedef void* (*RunnableMethod)(void* data);
+
+class MethodInvokeRenderTask : public RenderTask {
+public:
+ MethodInvokeRenderTask(RunnableMethod method)
+ : mMethod(method), mReturnPtr(0) {}
+
+ void* payload() { return mData; }
+ void setReturnPtr(void** retptr) { mReturnPtr = retptr; }
+
+ virtual void run() {
+ void* retval = mMethod(mData);
+ if (mReturnPtr) {
+ *mReturnPtr = retval;
+ }
+ // Commit suicide
+ delete this;
+ }
+private:
+ RunnableMethod mMethod;
+ char mData[METHOD_INVOKE_PAYLOAD_SIZE];
+ void** mReturnPtr;
};
} /* namespace renderthread */