From 26b7bd48940bd2cc808b72c46917edbd3debb99a Mon Sep 17 00:00:00 2001 From: Corey Tabaka Date: Wed, 10 May 2017 16:27:21 -0700 Subject: [PATCH] libbufferhub: Fix native buffer. This class was broken during a clean up. Fix the code in preparation for adding tools that will use it again. Bug: None Test: build; flash Change-Id: I8e60c7ba316080a24ff8914807972886e21ebce9 --- .../include/private/dvr/native_buffer.h | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libs/vr/libbufferhub/include/private/dvr/native_buffer.h b/libs/vr/libbufferhub/include/private/dvr/native_buffer.h index a54579f032..140ffc5a5a 100644 --- a/libs/vr/libbufferhub/include/private/dvr/native_buffer.h +++ b/libs/vr/libbufferhub/include/private/dvr/native_buffer.h @@ -52,8 +52,6 @@ class NativeBuffer void operator=(NativeBuffer&) = delete; }; -// NativeBufferProducer is an implementation of ANativeWindowBuffer backed by a -// BufferProducer. class NativeBufferProducer : public android::ANativeObjectBase< ANativeWindowBuffer, NativeBufferProducer, android::LightRefBase> { @@ -71,20 +69,25 @@ class NativeBufferProducer : public android::ANativeObjectBase< ANativeWindowBuffer::stride = buffer_->stride(); ANativeWindowBuffer::format = buffer_->format(); ANativeWindowBuffer::usage = buffer_->usage(); - handle = buffer_->native_handle(); + ANativeWindowBuffer::handle = buffer_->native_handle(); + if (display_) { + image_khr_ = + eglCreateImageKHR(display_, EGL_NO_CONTEXT, EGL_NATIVE_BUFFER_ANDROID, + static_cast(this), nullptr); + } else { + image_khr_ = EGL_NO_IMAGE_KHR; + } } explicit NativeBufferProducer(const std::shared_ptr& buffer) : NativeBufferProducer(buffer, nullptr, 0) {} virtual ~NativeBufferProducer() { - for (EGLImageKHR egl_image : egl_images_) { - if (egl_image != EGL_NO_IMAGE_KHR) - eglDestroyImageKHR(display_, egl_image); - } + if (image_khr_ != EGL_NO_IMAGE_KHR) + eglDestroyImageKHR(display_, image_khr_); } - EGLImageKHR image_khr(int index) const { return egl_images_[index]; } + EGLImageKHR image_khr() const { return image_khr_; } std::shared_ptr buffer() const { return buffer_; } int release_fence() const { return release_fence_.Get(); } uint32_t surface_buffer_index() const { return surface_buffer_index_; } @@ -112,7 +115,7 @@ class NativeBufferProducer : public android::ANativeObjectBase< std::shared_ptr buffer_; pdx::LocalHandle release_fence_; - std::vector egl_images_; + EGLImageKHR image_khr_; uint32_t surface_buffer_index_; EGLDisplay display_; -- 2.11.0