Deprecate producer/consumer usage: Step 1
Clean up producer/consumer usage from IonBuffer.
Bug: 37881101
Test: Build, flash, ran particles.apk
Change-Id: I66a8c4db2348b014a7b458b69157ed7c150112e1
diff --git a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
index c772ed3..dbd4110 100644
--- a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
+++ b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
@@ -113,8 +113,10 @@
uint32_t format() const { return slices_[0].format(); }
uint32_t usage() const { return slices_[0].usage(); }
uint32_t layer_count() const { return slices_[0].layer_count(); }
- uint64_t producer_usage() const { return slices_[0].producer_usage(); }
- uint64_t consumer_usage() const { return slices_[0].consumer_usage(); }
+
+ // TODO(b/37881101) Clean up producer/consumer usage.
+ uint64_t producer_usage() const { return slices_[0].usage(); }
+ uint64_t consumer_usage() const { return slices_[0].usage(); }
protected:
explicit BufferHubBuffer(LocalChannelHandle channel);
diff --git a/libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h b/libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h
index b6302f1..02e9f27 100644
--- a/libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h
+++ b/libs/vr/libbufferhub/include/private/dvr/bufferhub_rpc.h
@@ -24,8 +24,8 @@
width_(buffer.width()),
height_(buffer.height()),
format_(buffer.format()),
- producer_usage_(buffer.producer_usage()),
- consumer_usage_(buffer.consumer_usage()) {
+ producer_usage_(buffer.usage()),
+ consumer_usage_(buffer.usage()) {
// Populate the fd and int vectors: native_handle->data[] is an array of fds
// followed by an array of opaque ints.
const int fd_count = buffer.handle()->numFds;
@@ -48,10 +48,11 @@
for (const auto& fd : fds_)
fd_ints.push_back(fd.Get());
+ // TODO(b/37881101) Get rid of producer/consumer usage.
const int ret =
buffer->Import(fd_ints.data(), fd_ints.size(), opaque_ints_.data(),
opaque_ints_.size(), width_, height_, stride_, format_,
- producer_usage_, consumer_usage_);
+ (producer_usage_ | consumer_usage_));
if (ret < 0)
return ret;
diff --git a/libs/vr/libbufferhub/include/private/dvr/ion_buffer.h b/libs/vr/libbufferhub/include/private/dvr/ion_buffer.h
index e167a17..72c8d81 100644
--- a/libs/vr/libbufferhub/include/private/dvr/ion_buffer.h
+++ b/libs/vr/libbufferhub/include/private/dvr/ion_buffer.h
@@ -12,20 +12,12 @@
class IonBuffer {
public:
IonBuffer();
- IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
- IonBuffer(uint32_t width, uint32_t height, uint32_t format,
- uint64_t producer_usage, uint64_t consumer_usage);
+ IonBuffer(uint32_t width, uint32_t height, uint32_t format, uint64_t usage);
IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height,
- uint32_t stride, uint32_t format, uint32_t usage);
- IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height,
- uint32_t stride, uint32_t format, uint64_t producer_usage,
- uint64_t consumer_usage);
+ uint32_t stride, uint32_t format, uint64_t usage);
IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height,
uint32_t layer_count, uint32_t stride, uint32_t layer_stride,
- uint32_t format, uint32_t usage);
- IonBuffer(buffer_handle_t handle, uint32_t width, uint32_t height,
- uint32_t layer_count, uint32_t stride, uint32_t layer_stride,
- uint32_t format, uint64_t producer_usage, uint64_t consumer_usage);
+ uint32_t format, uint64_t usage);
~IonBuffer();
IonBuffer(IonBuffer&& other);
@@ -39,36 +31,25 @@
// previous native handle if necessary. Returns 0 on success or a negative
// errno code otherwise. If allocation fails the previous native handle is
// left intact.
- int Alloc(uint32_t width, uint32_t height, uint32_t format, uint32_t usage);
- int Alloc(uint32_t width, uint32_t height, uint32_t format,
- uint64_t producer_usage, uint64_t consumer_usage);
+ int Alloc(uint32_t width, uint32_t height, uint32_t format, uint64_t usage);
// Resets the underlying native handle and parameters, freeing the previous
// native handle if necessary.
void Reset(buffer_handle_t handle, uint32_t width, uint32_t height,
- uint32_t stride, uint32_t format, uint32_t usage);
- void Reset(buffer_handle_t handle, uint32_t width, uint32_t height,
- uint32_t stride, uint32_t format, uint64_t producer_usage,
- uint64_t consumer_usage);
+ uint32_t stride, uint32_t format, uint64_t usage);
// Like Reset but also registers the native handle, which is necessary for
// native handles received over IPC. Returns 0 on success or a negative errno
// code otherwise. If import fails the previous native handle is left intact.
int Import(buffer_handle_t handle, uint32_t width, uint32_t height,
- uint32_t stride, uint32_t format, uint32_t usage);
- int Import(buffer_handle_t handle, uint32_t width, uint32_t height,
- uint32_t stride, uint32_t format, uint64_t producer_usage,
- uint64_t consumer_usage);
+ uint32_t stride, uint32_t format, uint64_t usage);
// Like Reset but imports a native handle from raw fd and int arrays. Returns
// 0 on success or a negative errno code otherwise. If import fails the
// previous native handle is left intact.
int Import(const int* fd_array, int fd_count, const int* int_array,
int int_count, uint32_t width, uint32_t height, uint32_t stride,
- uint32_t format, uint32_t usage);
- int Import(const int* fd_array, int fd_count, const int* int_array,
- int int_count, uint32_t width, uint32_t height, uint32_t stride,
- uint32_t format, uint64_t producer_usage, uint64_t consumer_usage);
+ uint32_t format, uint64_t usage);
// Duplicates the native handle underlying |other| and then imports it. This
// is useful for creating multiple, independent views of the same Ion/Gralloc
@@ -95,19 +76,13 @@
uint32_t format() const {
return buffer_.get() ? buffer_->getPixelFormat() : 0;
}
- uint64_t producer_usage() const { return producer_usage_; }
- uint64_t consumer_usage() const { return consumer_usage_; }
- uint32_t usage() const { return buffer_.get() ? buffer_->getUsage() : 0; }
+ uint64_t usage() const {
+ return buffer_.get() ? static_cast<uint64_t>(buffer_->getUsage()) : 0;
+ }
private:
sp<GraphicBuffer> buffer_;
- // GraphicBuffer doesn't expose these separately. Keep these values cached for
- // BufferHub to check policy against. Clients that import these buffers won't
- // get the full picture, which is okay.
- uint64_t producer_usage_;
- uint64_t consumer_usage_;
-
IonBuffer(const IonBuffer&) = delete;
void operator=(const IonBuffer&) = delete;
};