Add allocator-v2 extended options to BufferQueue
Bug: 268382490
Test: libgui_test
Change-Id: If43b31eede87cddfcbfe4b24b53c1bafb453ebf2
diff --git a/libs/gui/IGraphicBufferProducer.cpp b/libs/gui/IGraphicBufferProducer.cpp
index e81c098..0914480 100644
--- a/libs/gui/IGraphicBufferProducer.cpp
+++ b/libs/gui/IGraphicBufferProducer.cpp
@@ -80,6 +80,7 @@
QUERY_MULTIPLE,
GET_LAST_QUEUED_BUFFER2,
SET_FRAME_RATE,
+ SET_ADDITIONAL_OPTIONS,
};
class BpGraphicBufferProducer : public BpInterface<IGraphicBufferProducer>
@@ -778,6 +779,25 @@
return result;
}
#endif
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE)
+ virtual status_t setAdditionalOptions(const std::vector<gui::AdditionalOptions>& options) {
+ Parcel data, reply;
+ data.writeInterfaceToken(IGraphicBufferProducer::getInterfaceDescriptor());
+ if (options.size() > 100) {
+ return BAD_VALUE;
+ }
+ data.writeInt32(options.size());
+ for (const auto& it : options) {
+ data.writeCString(it.name.c_str());
+ data.writeInt64(it.value);
+ }
+ status_t result = remote()->transact(SET_ADDITIONAL_OPTIONS, data, &reply);
+ if (result == NO_ERROR) {
+ result = reply.readInt32();
+ }
+ return result;
+ }
+#endif
};
// Out-of-line virtual method definition to trigger vtable emission in this
@@ -981,6 +1001,13 @@
}
#endif
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE)
+status_t IGraphicBufferProducer::setAdditionalOptions(const std::vector<gui::AdditionalOptions>&) {
+ // No-op for IGBP other than BufferQueue.
+ return INVALID_OPERATION;
+}
+#endif
+
status_t IGraphicBufferProducer::exportToParcel(Parcel* parcel) {
status_t res = OK;
res = parcel->writeUint32(USE_BUFFER_QUEUE);
@@ -1533,6 +1560,28 @@
return NO_ERROR;
}
#endif
+#if COM_ANDROID_GRAPHICS_LIBGUI_FLAGS(BQ_EXTENDEDALLOCATE)
+ case SET_ADDITIONAL_OPTIONS: {
+ CHECK_INTERFACE(IGraphicBuffer, data, reply);
+ int optionCount = data.readInt32();
+ if (optionCount < 0 || optionCount > 100) {
+ return BAD_VALUE;
+ }
+ std::vector<gui::AdditionalOptions> opts;
+ opts.reserve(optionCount);
+ for (int i = 0; i < optionCount; i++) {
+ const char* name = data.readCString();
+ int64_t value = 0;
+ if (name == nullptr || data.readInt64(&value) != NO_ERROR) {
+ return BAD_VALUE;
+ }
+ opts.emplace_back(name, value);
+ }
+ status_t result = setAdditionalOptions(opts);
+ reply->writeInt32(result);
+ return NO_ERROR;
+ }
+#endif
}
return BBinder::onTransact(code, data, reply, flags);
}