Revert "drm_hwcomposer: remove GLCompositor and the GLWorker thread"

This reverts commit abebc7a78fe8a4df6495c8e5064719dc92b04004.

For now until we figure out a more stable solution for SF/hwc

Change-Id: I7a505fc67873f943704e8b48db4167b9beca7691
diff --git a/glworker.h b/glworker.h
index 8252b62..9550cbe 100644
--- a/glworker.h
+++ b/glworker.h
@@ -17,6 +17,8 @@
 #ifndef ANDROID_GL_WORKER_H_
 #define ANDROID_GL_WORKER_H_
 
+#include <pthread.h>
+
 #include <memory>
 #include <vector>
 
@@ -96,6 +98,44 @@
   std::vector<AutoGLProgram> blend_programs_;
   AutoGLBuffer vertex_buffer_;
 };
+
+class GLWorker {
+ public:
+  struct Work {
+    hwc_layer_1 *layers;
+    size_t num_layers;
+    int timeline_fd;
+    sp<GraphicBuffer> framebuffer;
+
+    Work() = default;
+    Work(const Work &rhs) = delete;
+  };
+
+  GLWorker();
+  ~GLWorker();
+
+  int Init();
+
+  int DoWork(Work *work);
+
+ private:
+  bool initialized_;
+  pthread_t thread_;
+  pthread_mutex_t lock_;
+  pthread_cond_t work_ready_cond_;
+  pthread_cond_t work_done_cond_;
+  Work *worker_work_;
+  bool work_ready_;
+  bool worker_exit_;
+  int worker_ret_;
+
+  void WorkerRoutine();
+  int DoComposition(GLWorkerCompositor &compositor, Work *work);
+
+  int SignalWorker(Work *work, bool worker_exit);
+
+  static void *StartRoutine(void *arg);
+};
 }
 
 #endif