Add additional accessors to IonBuffer and BufferHubBuffer.
- Add accessor to underlying GraphicBuffer in IonBuffer.
- Add const accessors to underlying IonBuffer(s) in BufferHubBuffer.
Bug: 36401174
Test: bufferhub_tests; buffer_hub_queue-test
Change-Id: I24a6c19b141bb50ffa06e861a4533e10d55b5b20
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 aacc385..dfeed50 100644
--- a/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
+++ b/libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h
@@ -94,9 +94,12 @@
}
IonBuffer* buffer() { return &slices_[0]; }
+ const IonBuffer* buffer() const { return &slices_[0]; }
+
// If index is greater than or equal to slice_count(), the result is
// undefined.
IonBuffer* slice(size_t index) { return &slices_[index]; }
+ const IonBuffer* slice(size_t index) const { return &slices_[index]; }
int slice_count() const { return static_cast<int>(slices_.size()); }
int id() const { return id_; }
@@ -171,9 +174,8 @@
int Post(const LocalHandle& ready_fence) {
return Post(ready_fence, nullptr, 0);
}
- template <
- typename Meta,
- typename = typename std::enable_if<!std::is_void<Meta>::value>::type>
+ template <typename Meta, typename = typename std::enable_if<
+ !std::is_void<Meta>::value>::type>
int Post(const LocalHandle& ready_fence, const Meta& meta) {
return Post(ready_fence, &meta, sizeof(meta));
}
diff --git a/libs/vr/libbufferhub/include/private/dvr/ion_buffer.h b/libs/vr/libbufferhub/include/private/dvr/ion_buffer.h
index e449cbd..ffc42d6 100644
--- a/libs/vr/libbufferhub/include/private/dvr/ion_buffer.h
+++ b/libs/vr/libbufferhub/include/private/dvr/ion_buffer.h
@@ -60,21 +60,20 @@
int LockYUV(int usage, int x, int y, int width, int height,
struct android_ycbcr* yuv);
int Unlock();
- buffer_handle_t handle() const { if (buffer_.get()) return buffer_->handle;
- else return nullptr; }
- int width() const { if (buffer_.get()) return buffer_->getWidth();
- else return 0; }
- int height() const { if (buffer_.get()) return buffer_->getHeight();
- else return 0; }
- int layer_count() const { if (buffer_.get()) return buffer_->getLayerCount();
- else return 0; }
- int stride() const { if (buffer_.get()) return buffer_->getStride();
- else return 0; }
+
+ const sp<GraphicBuffer>& buffer() const { return buffer_; }
+ buffer_handle_t handle() const {
+ return buffer_.get() ? buffer_->handle : nullptr;
+ }
+ int width() const { return buffer_.get() ? buffer_->getWidth() : 0; }
+ int height() const { return buffer_.get() ? buffer_->getHeight() : 0; }
+ int layer_count() const {
+ return buffer_.get() ? buffer_->getLayerCount() : 0;
+ }
+ int stride() const { return buffer_.get() ? buffer_->getStride() : 0; }
int layer_stride() const { return 0; }
- int format() const { if (buffer_.get()) return buffer_->getPixelFormat();
- else return 0; }
- int usage() const { if (buffer_.get()) return buffer_->getUsage();
- else return 0; }
+ int format() const { return buffer_.get() ? buffer_->getPixelFormat() : 0; }
+ int usage() const { return buffer_.get() ? buffer_->getUsage() : 0; }
private:
sp<GraphicBuffer> buffer_;