Commit c732a44b authored by Alexandre Courbot's avatar Alexandre Courbot Committed by Commit Bot

media/gpu/v4l2(s)vda: remove (e)gl_image_device member

This member is only used in one method, and its initialization is very
simple: image processor if present, otherwise decoder. So perform this
choice in the method where it is actually used instead of carrying this
member for the whole life of the decoder and making sure it is updated
properly, at the risk of introducing bugs.

BUG=None
TEST=Video playback working on Hana.

Change-Id: I52e23fae9edb057ed618c2da0834f60ae88fccf4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2002249
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: default avatarHirokazu Honda <hiroh@chromium.org>
Reviewed-by: default avatarDavid Staessens <dstaessens@chromium.org>
Cr-Commit-Position: refs/heads/master@{#732242}
parent 3ea8139a
......@@ -390,7 +390,6 @@ void V4L2SliceVideoDecodeAccelerator::Destroy() {
// executes after all the tasks potentially posted by the IP.
base::BindOnce(
[](V4L2SliceVideoDecodeAccelerator* vda) {
vda->gl_image_device_ = nullptr;
// The image processor's thread was the user of the image
// processor device, so let it keep the last reference and destroy
// it in its own thread.
......@@ -534,11 +533,9 @@ bool V4L2SliceVideoDecodeAccelerator::SetupFormats() {
}
gl_image_planes_count_ = V4L2Device::GetNumPlanesOfV4L2PixFmt(
gl_image_format_fourcc_->ToV4L2PixFmt());
gl_image_device_ = image_processor_device_;
} else {
gl_image_format_fourcc_ = output_format_fourcc_;
gl_image_planes_count_ = output_planes_count_;
gl_image_device_ = device_;
}
// Only set fourcc for output; resolution, etc., will come from the
......@@ -1395,20 +1392,22 @@ void V4L2SliceVideoDecodeAccelerator::CreateGLImageFor(
return;
}
V4L2Device* gl_device =
image_processor_device_ ? image_processor_device_.get() : device_.get();
scoped_refptr<gl::GLImage> gl_image =
gl_image_device_->CreateGLImage(size, fourcc, std::move(handle));
gl_device->CreateGLImage(size, fourcc, std::move(handle));
if (!gl_image) {
VLOGF(1) << "Could not create GLImage,"
<< " index=" << buffer_index << " texture_id=" << texture_id;
NOTIFY_ERROR(PLATFORM_FAILURE);
return;
}
gl::ScopedTextureBinder bind_restore(gl_image_device_->GetTextureTarget(),
gl::ScopedTextureBinder bind_restore(gl_device->GetTextureTarget(),
texture_id);
bool ret = gl_image->BindTexImage(gl_image_device_->GetTextureTarget());
bool ret = gl_image->BindTexImage(gl_device->GetTextureTarget());
DCHECK(ret);
bind_image_cb_.Run(client_texture_id, gl_image_device_->GetTextureTarget(),
gl_image, true);
bind_image_cb_.Run(client_texture_id, gl_device->GetTextureTarget(), gl_image,
true);
}
void V4L2SliceVideoDecodeAccelerator::ImportBufferForPicture(
......
......@@ -489,8 +489,6 @@ class MEDIA_GPU_EXPORT V4L2SliceVideoDecodeAccelerator
// Image processor. Accessed on |decoder_thread_|.
std::unique_ptr<ImageProcessor> image_processor_;
// The V4L2Device GLImage is created from.
scoped_refptr<V4L2Device> gl_image_device_;
// The format of GLImage.
base::Optional<Fourcc> gl_image_format_fourcc_;
// The logical dimensions of GLImage buffer in pixels.
......
......@@ -491,7 +491,9 @@ void V4L2VideoDecodeAccelerator::CreateEGLImageFor(
gl::ScopedTextureBinder bind_restore(GL_TEXTURE_EXTERNAL_OES, 0);
EGLImageKHR egl_image = egl_image_device_->CreateEGLImage(
V4L2Device* egl_device =
image_processor_device_ ? image_processor_device_.get() : device_.get();
EGLImageKHR egl_image = egl_device->CreateEGLImage(
egl_display_, gl_context->GetHandle(), texture_id, size, buffer_index,
fourcc, std::move(handle));
if (egl_image == EGL_NO_IMAGE_KHR) {
......@@ -1931,8 +1933,6 @@ void V4L2VideoDecodeAccelerator::DestroyTask() {
// First liberate all the frames held by the client.
buffers_at_client_.clear();
egl_image_device_ = nullptr;
// The image processor's thread was the user of the image processor device,
// so let it keep the last reference and destroy it in its own thread.
image_processor_device_ = nullptr;
......@@ -2366,10 +2366,8 @@ bool V4L2VideoDecodeAccelerator::SetupFormats() {
VLOGF(1) << "Could not create a V4L2Device for image processor";
return false;
}
egl_image_device_ = image_processor_device_;
} else {
egl_image_format_fourcc_ = output_format_fourcc_;
egl_image_device_ = device_;
}
VLOGF(2) << "Output format=" << output_format_fourcc_->ToString();
......
......@@ -589,8 +589,6 @@ class MEDIA_GPU_EXPORT V4L2VideoDecodeAccelerator
// Image processor. Accessed on |decoder_thread_|.
std::unique_ptr<ImageProcessor> image_processor_;
// The V4L2Device EGLImage is created from.
scoped_refptr<V4L2Device> egl_image_device_;
// The format of EGLImage.
base::Optional<Fourcc> egl_image_format_fourcc_;
// The logical dimensions of EGLImage buffer in pixels.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment