Commit aed1b2a9 authored by Miguel Casas-Sanchez's avatar Miguel Casas-Sanchez Committed by Commit Bot

vaapi: use |sequence_checker_| in vaapi_*_picture.cc

This CL makes |sequence_checker_| a protected member var in
vaapi_picture.h and uses it in every method in the derived
classes in vaapi_{drm,tfp}_picture.cc. Opportunistically it
also moves the service function BufferFormatToInternalFormat()
to an anonymous namespace in vaapi_drm_picture.cc.

TEST=**No new code intended**, these classes are supposed
to be single threaded, so this is just a help for future
and present devs by enforcing assumptions. (But just in case
I tried the usual playback in Soraka-simplechrome, ensuring
  dcheck_always_on = true
in the appropriate args.gn, otherwise Release builds don't
have DCHECKs on).


Bug: 717265
Cq-Include-Trybots: master.tryserver.chromium.android:android_optional_gpu_tests_rel;master.tryserver.chromium.linux:linux_optional_gpu_tests_rel;master.tryserver.chromium.mac:mac_optional_gpu_tests_rel;master.tryserver.chromium.win:win_optional_gpu_tests_rel
Change-Id: I9e96440ec7ade318f5ac4c9289fcee1e77c6d90a
Reviewed-on: https://chromium-review.googlesource.com/744903
Commit-Queue: Miguel Casas <mcasas@chromium.org>
Reviewed-by: default avatarPawel Osciak <posciak@chromium.org>
Cr-Commit-Position: refs/heads/master@{#512819}
parent 27198849
...@@ -17,6 +17,27 @@ ...@@ -17,6 +17,27 @@
namespace media { namespace media {
namespace {
static unsigned BufferFormatToInternalFormat(gfx::BufferFormat format) {
switch (format) {
case gfx::BufferFormat::BGRX_8888:
return GL_RGB;
case gfx::BufferFormat::BGRA_8888:
return GL_BGRA_EXT;
case gfx::BufferFormat::YVU_420:
return GL_RGB_YCRCB_420_CHROMIUM;
default:
NOTREACHED();
return GL_BGRA_EXT;
}
}
} // anonymous namespace
VaapiDrmPicture::VaapiDrmPicture( VaapiDrmPicture::VaapiDrmPicture(
const scoped_refptr<VaapiWrapper>& vaapi_wrapper, const scoped_refptr<VaapiWrapper>& vaapi_wrapper,
const MakeGLContextCurrentCallback& make_context_current_cb, const MakeGLContextCurrentCallback& make_context_current_cb,
...@@ -31,33 +52,20 @@ VaapiDrmPicture::VaapiDrmPicture( ...@@ -31,33 +52,20 @@ VaapiDrmPicture::VaapiDrmPicture(
picture_buffer_id, picture_buffer_id,
size, size,
texture_id, texture_id,
client_texture_id) {} client_texture_id) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
VaapiDrmPicture::~VaapiDrmPicture() { VaapiDrmPicture::~VaapiDrmPicture() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (gl_image_ && make_context_current_cb_.Run()) { if (gl_image_ && make_context_current_cb_.Run()) {
gl_image_->ReleaseTexImage(GL_TEXTURE_EXTERNAL_OES); gl_image_->ReleaseTexImage(GL_TEXTURE_EXTERNAL_OES);
DCHECK_EQ(glGetError(), static_cast<GLenum>(GL_NO_ERROR)); DCHECK_EQ(glGetError(), static_cast<GLenum>(GL_NO_ERROR));
} }
} }
static unsigned BufferFormatToInternalFormat(gfx::BufferFormat format) {
switch (format) {
case gfx::BufferFormat::BGRX_8888:
return GL_RGB;
case gfx::BufferFormat::BGRA_8888:
return GL_BGRA_EXT;
case gfx::BufferFormat::YVU_420:
return GL_RGB_YCRCB_420_CHROMIUM;
default:
NOTREACHED();
return GL_BGRA_EXT;
}
}
bool VaapiDrmPicture::Initialize() { bool VaapiDrmPicture::Initialize() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(pixmap_); DCHECK(pixmap_);
va_surface_ = vaapi_wrapper_->CreateVASurfaceForPixmap(pixmap_); va_surface_ = vaapi_wrapper_->CreateVASurfaceForPixmap(pixmap_);
...@@ -100,6 +108,7 @@ bool VaapiDrmPicture::Initialize() { ...@@ -100,6 +108,7 @@ bool VaapiDrmPicture::Initialize() {
} }
bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) { bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance();
ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone();
pixmap_ = factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size_, pixmap_ = factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size_,
...@@ -115,6 +124,7 @@ bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) { ...@@ -115,6 +124,7 @@ bool VaapiDrmPicture::Allocate(gfx::BufferFormat format) {
bool VaapiDrmPicture::ImportGpuMemoryBufferHandle( bool VaapiDrmPicture::ImportGpuMemoryBufferHandle(
gfx::BufferFormat format, gfx::BufferFormat format,
const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) { const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance();
ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone();
// CreateNativePixmapFromHandle() will take ownership of the handle. // CreateNativePixmapFromHandle() will take ownership of the handle.
...@@ -131,10 +141,12 @@ bool VaapiDrmPicture::ImportGpuMemoryBufferHandle( ...@@ -131,10 +141,12 @@ bool VaapiDrmPicture::ImportGpuMemoryBufferHandle(
bool VaapiDrmPicture::DownloadFromSurface( bool VaapiDrmPicture::DownloadFromSurface(
const scoped_refptr<VASurface>& va_surface) { const scoped_refptr<VASurface>& va_surface) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return vaapi_wrapper_->BlitSurface(va_surface, va_surface_); return vaapi_wrapper_->BlitSurface(va_surface, va_surface_);
} }
bool VaapiDrmPicture::AllowOverlay() const { bool VaapiDrmPicture::AllowOverlay() const {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return true; return true;
} }
......
...@@ -84,11 +84,11 @@ class VaapiPicture { ...@@ -84,11 +84,11 @@ class VaapiPicture {
const uint32_t texture_id_; const uint32_t texture_id_;
const uint32_t client_texture_id_; const uint32_t client_texture_id_;
SEQUENCE_CHECKER(sequence_checker_);
private: private:
const int32_t picture_buffer_id_; const int32_t picture_buffer_id_;
SEQUENCE_CHECKER(sequence_checker_);
DISALLOW_COPY_AND_ASSIGN(VaapiPicture); DISALLOW_COPY_AND_ASSIGN(VaapiPicture);
}; };
......
...@@ -31,9 +31,12 @@ VaapiTFPPicture::VaapiTFPPicture( ...@@ -31,9 +31,12 @@ VaapiTFPPicture::VaapiTFPPicture(
texture_id, texture_id,
client_texture_id), client_texture_id),
x_display_(gfx::GetXDisplay()), x_display_(gfx::GetXDisplay()),
x_pixmap_(0) {} x_pixmap_(0) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
}
VaapiTFPPicture::~VaapiTFPPicture() { VaapiTFPPicture::~VaapiTFPPicture() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (glx_image_.get() && make_context_current_cb_.Run()) { if (glx_image_.get() && make_context_current_cb_.Run()) {
glx_image_->ReleaseTexImage(GL_TEXTURE_2D); glx_image_->ReleaseTexImage(GL_TEXTURE_2D);
DCHECK_EQ(glGetError(), static_cast<GLenum>(GL_NO_ERROR)); DCHECK_EQ(glGetError(), static_cast<GLenum>(GL_NO_ERROR));
...@@ -44,6 +47,7 @@ VaapiTFPPicture::~VaapiTFPPicture() { ...@@ -44,6 +47,7 @@ VaapiTFPPicture::~VaapiTFPPicture() {
} }
bool VaapiTFPPicture::Initialize() { bool VaapiTFPPicture::Initialize() {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
DCHECK(x_pixmap_); DCHECK(x_pixmap_);
if (texture_id_ != 0 && !make_context_current_cb_.is_null()) { if (texture_id_ != 0 && !make_context_current_cb_.is_null()) {
...@@ -68,6 +72,7 @@ bool VaapiTFPPicture::Initialize() { ...@@ -68,6 +72,7 @@ bool VaapiTFPPicture::Initialize() {
} }
bool VaapiTFPPicture::Allocate(gfx::BufferFormat format) { bool VaapiTFPPicture::Allocate(gfx::BufferFormat format) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
if (format != gfx::BufferFormat::BGRX_8888 && if (format != gfx::BufferFormat::BGRX_8888 &&
format != gfx::BufferFormat::BGRA_8888) { format != gfx::BufferFormat::BGRA_8888) {
DLOG(ERROR) << "Unsupported format"; DLOG(ERROR) << "Unsupported format";
...@@ -92,12 +97,14 @@ bool VaapiTFPPicture::Allocate(gfx::BufferFormat format) { ...@@ -92,12 +97,14 @@ bool VaapiTFPPicture::Allocate(gfx::BufferFormat format) {
bool VaapiTFPPicture::ImportGpuMemoryBufferHandle( bool VaapiTFPPicture::ImportGpuMemoryBufferHandle(
gfx::BufferFormat format, gfx::BufferFormat format,
const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) { const gfx::GpuMemoryBufferHandle& gpu_memory_buffer_handle) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
NOTIMPLEMENTED() << "GpuMemoryBufferHandle import not implemented"; NOTIMPLEMENTED() << "GpuMemoryBufferHandle import not implemented";
return false; return false;
} }
bool VaapiTFPPicture::DownloadFromSurface( bool VaapiTFPPicture::DownloadFromSurface(
const scoped_refptr<VASurface>& va_surface) { const scoped_refptr<VASurface>& va_surface) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
return vaapi_wrapper_->PutSurfaceIntoPixmap(va_surface->id(), x_pixmap_, return vaapi_wrapper_->PutSurfaceIntoPixmap(va_surface->id(), x_pixmap_,
va_surface->size()); va_surface->size());
} }
......
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