BQ: Make QueueBufferOutput implement Flattenable
It will need to support file descriptors soon.
Also:
* Make it's members public and clean up
inflate/deflate usage.
* Send Fence::NO_FENCE over Binder from dequeue
to indicate lack of fence.
Test: adb shell /data/nativetest/libgui_test/libgui_test
--gtest_filter=*GetFrameTimestamps*
Change-Id: Ia9e4600424a89ce026ba27e8aaed27a6bab860a4
diff --git a/include/gui/IGraphicBufferProducer.h b/include/gui/IGraphicBufferProducer.h
index 982cc9d..20cffe0 100644
--- a/include/gui/IGraphicBufferProducer.h
+++ b/include/gui/IGraphicBufferProducer.h
@@ -295,6 +295,7 @@
struct QueueBufferInput : public Flattenable<QueueBufferInput> {
friend class Flattenable<QueueBufferInput>;
explicit inline QueueBufferInput(const Parcel& parcel);
+
// timestamp - a monotonically increasing value in nanoseconds
// isAutoTimestamp - if the timestamp was synthesized at queue time
// dataSpace - description of the contents, interpretation depends on format
@@ -313,11 +314,12 @@
dataSpace(_dataSpace), crop(_crop), scalingMode(_scalingMode),
transform(_transform), stickyTransform(_sticky), fence(_fence),
surfaceDamage() { }
+
inline void deflate(int64_t* outTimestamp, bool* outIsAutoTimestamp,
android_dataspace* outDataSpace,
Rect* outCrop, int* outScalingMode,
uint32_t* outTransform, sp<Fence>* outFence,
- uint32_t* outStickyTransform = NULL) const {
+ uint32_t* outStickyTransform = nullptr) const {
*outTimestamp = timestamp;
*outIsAutoTimestamp = bool(isAutoTimestamp);
*outDataSpace = dataSpace;
@@ -351,8 +353,7 @@
Region surfaceDamage;
};
- // QueueBufferOutput must be a POD structure
- struct QueueBufferOutput {
+ struct QueueBufferOutput : public Flattenable<QueueBufferOutput> {
// outWidth - filled with default width applied to the buffer
// outHeight - filled with default height applied to the buffer
// outTransformHint - filled with default transform applied to the buffer
@@ -369,6 +370,7 @@
*outNumPendingBuffers = numPendingBuffers;
*outNextFrameNumber = nextFrameNumber;
}
+
inline void inflate(uint32_t inWidth, uint32_t inHeight,
uint32_t inTransformHint, uint32_t inNumPendingBuffers,
uint64_t inNextFrameNumber) {
@@ -378,7 +380,13 @@
numPendingBuffers = inNumPendingBuffers;
nextFrameNumber = inNextFrameNumber;
}
- private:
+
+ // Flattenable protocol
+ 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 const*& fds, size_t& count);
+
uint32_t width{0};
uint32_t height{0};
uint32_t transformHint{0};