OSDN Git Service

merge in klp-release history after reset to klp-dev
[android-x86/frameworks-native.git] / include / ui / Fence.h
index b516a22..20466b6 100644 (file)
@@ -25,6 +25,7 @@
 #include <ui/Rect.h>
 #include <utils/Flattenable.h>
 #include <utils/String8.h>
+#include <utils/Timers.h>
 
 struct ANativeWindowBuffer;
 
@@ -35,11 +36,15 @@ namespace android {
 // ===========================================================================
 
 class Fence
-    : public LightRefBase<Fence>, public Flattenable
+    : public LightRefBase<Fence>, public Flattenable<Fence>
 {
 public:
     static const sp<Fence> NO_FENCE;
 
+    // TIMEOUT_NEVER may be passed to the wait method to indicate that it
+    // should wait indefinitely for the fence to signal.
+    enum { TIMEOUT_NEVER = -1 };
+
     // Construct a new Fence object with an invalid file descriptor.  This
     // should be done when the Fence object will be set up by unflattening
     // serialized data.
@@ -60,11 +65,15 @@ public:
     // before the fence signals then -ETIME is returned.  A timeout of
     // TIMEOUT_NEVER may be used to indicate that the call should wait
     // indefinitely for the fence to signal.
-    int wait(unsigned int timeout);
+    status_t wait(unsigned int timeout);
 
-    // TIMEOUT_NEVER may be passed to the wait method to indicate that it
-    // should wait indefinitely for the fence to signal.
-    enum { TIMEOUT_NEVER = -1 };
+    // waitForever is a convenience function for waiting forever for a fence to
+    // signal (just like wait(TIMEOUT_NEVER)), but issuing an error to the
+    // system log and fence state to the kernel log if the wait lasts longer
+    // than a warning timeout.
+    // The logname argument should be a string identifying
+    // the caller and will be included in the log message.
+    status_t waitForever(const char* logname);
 
     // merge combines two Fence objects, creating a new Fence object that
     // becomes signaled when both f1 and f2 are signaled (even if f1 or f2 is
@@ -78,18 +87,22 @@ public:
     // be returned and errno will indicate the problem.
     int dup() const;
 
+    // getSignalTime returns the system monotonic clock time at which the
+    // fence transitioned to the signaled state.  If the fence is not signaled
+    // then INT64_MAX is returned.  If the fence is invalid or if an error
+    // occurs then -1 is returned.
+    nsecs_t getSignalTime() const;
+
     // Flattenable interface
     size_t getFlattenedSize() const;
     size_t getFdCount() const;
-    status_t flatten(void* buffer, size_t size,
-            int fds[], size_t count) const;
-    status_t unflatten(void const* buffer, size_t size,
-            int fds[], size_t count);
+    status_t flatten(void*& buffer, size_t& size, int*& fds, size_t& count) const;
+    status_t unflatten(void const*& buffer, size_t& size, int const*& fds, size_t& count);
 
 private:
     // Only allow instantiation using ref counting.
     friend class LightRefBase<Fence>;
-    virtual ~Fence();
+    ~Fence();
 
     // Disallow copying
     Fence(const Fence& rhs);