OSDN Git Service

auto import from //branches/cupcake/...@127101
authorThe Android Open Source Project <initial-contribution@android.com>
Tue, 20 Jan 2009 22:03:59 +0000 (14:03 -0800)
committerThe Android Open Source Project <initial-contribution@android.com>
Tue, 20 Jan 2009 22:03:59 +0000 (14:03 -0800)
include/hardware/overlay.h
modules/overlay/overlay.cpp

index 63230e3..a5cd263 100644 (file)
@@ -17,6 +17,8 @@
 #ifndef ANDROID_OVERLAY_INTERFACE_H
 #define ANDROID_OVERLAY_INTERFACE_H
 
+#include <cutils/native_handle.h>
+
 #include <hardware/hardware.h>
 
 #include <stdint.h>
@@ -102,12 +104,7 @@ enum {
 /*****************************************************************************/
 
 /* opaque reference to an Overlay kernel object */
-typedef struct {
-    int numFds;
-    int fds[4];
-    int numInts;
-    int data[0];
-} overlay_handle_t;
+typedef const native_handle* overlay_handle_t;
 
 typedef struct overlay_t {
     uint32_t            w;
@@ -118,7 +115,7 @@ typedef struct overlay_t {
     uint32_t            reserved[3];
     /* returns a reference to this overlay's handle (the caller doesn't
      * take ownership) */
-    overlay_handle_t const* (*getHandleRef)(struct overlay_t* overlay);
+    overlay_handle_t    (*getHandleRef)(struct overlay_t* overlay);
     uint32_t            reserved_procs[7];
 } overlay_t;
 
@@ -183,7 +180,7 @@ struct overlay_data_device_t {
     /* initialize the overlay from the given handle. this associates this
      * overlay data module to its control module */
     int (*initialize)(struct overlay_data_device_t *dev,
-            overlay_handle_t const* handle);
+            overlay_handle_t handle);
     
     /* blocks until an overlay buffer is available and return that buffer. */
     int (*dequeueBuffer)(struct overlay_data_device_t *dev,
index becaae3..0246b5b 100644 (file)
@@ -60,17 +60,14 @@ const struct overlay_module_t HAL_MODULE_INFO_SYM = {
 
 /*
  * This is the overlay_t object, it is returned to the user and represents
- * an overlay. here we use a subclass, where we can store our own state. 
- * Notice the use of "overlay_handle_t", which is an "opaque" marshallable 
- * handle, it can contains any number of ints and up to 4 filedescriptors.
- * In this example we store no fd and 2 ints.
+ * an overlay.
  * This handles will be passed across processes and possibly given to other
  * HAL modules (for instance video decode modules).
  */
 
 class overlay_object : public overlay_t {
     
-    struct handle_t : public overlay_handle_t {
+    struct handle_t : public native_handle {
         /* add the data fields we need here, for instance: */
         int width;
         int height;
@@ -78,7 +75,7 @@ class overlay_object : public overlay_t {
     
     handle_t mHandle;
     
-    static overlay_handle_t const* getHandleRef(struct overlay_t* overlay) {
+    static overlay_handle_t getHandleRef(struct overlay_t* overlay) {
         /* returns a reference to the handle, caller doesn't take ownership */
         return &(static_cast<overlay_object *>(overlay)->mHandle);
     }
@@ -86,6 +83,7 @@ class overlay_object : public overlay_t {
 public:
     overlay_object() {
         this->overlay_t::getHandleRef = getHandleRef;
+        mHandle.version = sizeof(native_handle);
         mHandle.numFds = 0;
         mHandle.numInts = 2; // extra ints we have in  our handle
     }
@@ -213,7 +211,7 @@ static int overlay_control_close(struct hw_device_t *dev)
 // ****************************************************************************
 
 int overlay_initialize(struct overlay_data_device_t *dev,
-        overlay_handle_t const* handle)
+        overlay_handle_t handle)
 {
     /* 
      * overlay_handle_t should contain all the information to "inflate" this
@@ -230,7 +228,7 @@ int overlay_initialize(struct overlay_data_device_t *dev,
 }
 
 int overlay_dequeueBuffer(struct overlay_data_device_t *dev,
-                         overlay_buffer_t buf) 
+                         overlay_buffer_t* buf) 
 {
     /* blocks until a buffer is available and return an opaque structure
      * representing this buffer.