diff options
| -rw-r--r-- | libs/vr/libbufferhub/include/private/dvr/buffer_hub_client.h | 8 | ||||
| -rw-r--r-- | libs/vr/libbufferhub/include/private/dvr/ion_buffer.h | 27 |
2 files changed, 18 insertions, 17 deletions
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 aacc385fa0..dfeed50f3d 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 @@ class BufferHubBuffer : public pdx::Client { } 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 @@ class BufferProducer : public pdx::ClientBase<BufferProducer, BufferHubBuffer> { 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 e449cbdb02..ffc42d6123 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 @@ class IonBuffer { 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_; |