Implement converters for bufferqueue@2.0
Test: make cts -j123 && cts-tradefed run cts-dev -m \
CtsMediaTestCases --compatibility:module-arg \
CtsMediaTestCases:include-annotation:\
android.platform.test.annotations.RequiresDevice
Bug: 112508112
Change-Id: I60f2068788136b01c45e03fc4d846d4e37edc7f2
diff --git a/libs/ui/Android.bp b/libs/ui/Android.bp
index 4ca1781..e521b61 100644
--- a/libs/ui/Android.bp
+++ b/libs/ui/Android.bp
@@ -124,7 +124,6 @@
exclude_header_libs: [
"libbufferhub_headers",
"libdvr_headers",
- "libnativewindow_headers",
],
exclude_shared_libs: [
"android.frameworks.bufferhub@1.0",
@@ -152,6 +151,7 @@
export_header_lib_headers: [
"libbase_headers",
"libnativebase_headers",
+ "libnativewindow_headers",
"libhardware_headers",
"libui_headers",
],
diff --git a/libs/ui/GraphicBuffer.cpp b/libs/ui/GraphicBuffer.cpp
index 79958ec..f800627 100644
--- a/libs/ui/GraphicBuffer.cpp
+++ b/libs/ui/GraphicBuffer.cpp
@@ -49,6 +49,22 @@
return static_cast<GraphicBuffer *>(anwb);
}
+GraphicBuffer* GraphicBuffer::fromAHardwareBuffer(AHardwareBuffer* buffer) {
+ return reinterpret_cast<GraphicBuffer*>(buffer);
+}
+
+GraphicBuffer const* GraphicBuffer::fromAHardwareBuffer(AHardwareBuffer const* buffer) {
+ return reinterpret_cast<GraphicBuffer const*>(buffer);
+}
+
+AHardwareBuffer* GraphicBuffer::toAHardwareBuffer() {
+ return reinterpret_cast<AHardwareBuffer*>(this);
+}
+
+AHardwareBuffer const* GraphicBuffer::toAHardwareBuffer() const {
+ return reinterpret_cast<AHardwareBuffer const*>(this);
+}
+
GraphicBuffer::GraphicBuffer()
: BASE(), mOwner(ownData), mBufferMapper(GraphicBufferMapper::get()),
mInitCheck(NO_ERROR), mId(getUniqueId()), mGenerationNumber(0)
diff --git a/libs/ui/include/ui/Fence.h b/libs/ui/include/ui/Fence.h
index ec67fa9..6efecd3 100644
--- a/libs/ui/include/ui/Fence.h
+++ b/libs/ui/include/ui/Fence.h
@@ -99,6 +99,12 @@
// be returned and errno will indicate the problem.
int dup() const;
+ // Return the underlying file descriptor without giving up ownership. The
+ // returned file descriptor is only valid for as long as the owning Fence
+ // object lives. (If the situation is unclear, dup() is always a safer
+ // option.)
+ int get() const { return mFenceFd.get(); }
+
// getSignalTime returns the system monotonic clock time at which the
// fence transitioned to the signaled state. If the fence is not signaled
// then SIGNAL_TIME_PENDING is returned. If the fence is invalid or if an
diff --git a/libs/ui/include/ui/GraphicBuffer.h b/libs/ui/include/ui/GraphicBuffer.h
index 4d4ee68..e0c6558 100644
--- a/libs/ui/include/ui/GraphicBuffer.h
+++ b/libs/ui/include/ui/GraphicBuffer.h
@@ -22,6 +22,7 @@
#include <string>
+#include <android/hardware_buffer.h>
#include <ui/ANativeObjectBase.h>
#include <ui/PixelFormat.h>
#include <ui/Rect.h>
@@ -78,6 +79,10 @@
static sp<GraphicBuffer> from(ANativeWindowBuffer *);
+ static GraphicBuffer* fromAHardwareBuffer(AHardwareBuffer*);
+ static GraphicBuffer const* fromAHardwareBuffer(AHardwareBuffer const*);
+ AHardwareBuffer* toAHardwareBuffer();
+ AHardwareBuffer const* toAHardwareBuffer() const;
// Create a GraphicBuffer to be unflatten'ed into or be reallocated.
GraphicBuffer();