Chromium Code Reviews| Index: content/common/gpu/media/vaapi_drm_picture.cc |
| diff --git a/content/common/gpu/media/vaapi_drm_picture.cc b/content/common/gpu/media/vaapi_drm_picture.cc |
| index 45cd8b3083bb57a2c926de54ae75e53c3e3d4fca..dc1991ebb8120086e3d3d0ec41027bfbada669a3 100644 |
| --- a/content/common/gpu/media/vaapi_drm_picture.cc |
| +++ b/content/common/gpu/media/vaapi_drm_picture.cc |
| @@ -19,6 +19,18 @@ |
| namespace content { |
| +int GetVASurfaceFormatFromPixmapFormat(gfx::BufferFormat fmt) { |
|
Pawel Osciak
2015/10/29 11:28:36
s/GetVASurfaceFormatFromPixmapFormat/BufferFormatT
william.xie1
2015/10/29 14:14:53
Done.
|
| + switch (fmt) { |
| + case gfx::BufferFormat::BGRX_8888: |
| + return VA_FOURCC_BGRX; |
| + case gfx::BufferFormat::UYVY_422: |
| + return VA_FOURCC_UYVY; |
| + default: |
| + NOTREACHED(); |
| + return 0; |
| + } |
| +} |
| + |
| VaapiDrmPicture::VaapiDrmPicture( |
| VaapiWrapper* vaapi_wrapper, |
| const base::Callback<bool(void)>& make_context_current, |
| @@ -54,7 +66,8 @@ scoped_refptr<VASurface> VaapiDrmPicture::CreateVASurfaceForPixmap( |
| // Create a VASurface out of the created buffer using the dmabuf. |
| VASurfaceAttribExternalBuffers va_attrib_extbuf; |
| memset(&va_attrib_extbuf, 0, sizeof(va_attrib_extbuf)); |
| - va_attrib_extbuf.pixel_format = VA_FOURCC_BGRX; |
| + va_attrib_extbuf.pixel_format = |
| + GetVASurfaceFormatFromPixmapFormat(pixmap->GetBufferFormat()); |
| va_attrib_extbuf.width = pixmap_size.width(); |
| va_attrib_extbuf.height = pixmap_size.height(); |
| va_attrib_extbuf.data_size = pixmap_size.height() * dmabuf_pitch; |
| @@ -80,7 +93,9 @@ scoped_refptr<VASurface> VaapiDrmPicture::CreateVASurfaceForPixmap( |
| va_attribs[1].value.value.p = &va_attrib_extbuf; |
| scoped_refptr<VASurface> va_surface = vaapi_wrapper_->CreateUnownedSurface( |
| - VA_RT_FORMAT_RGB32, pixmap_size, va_attribs); |
| + va_attrib_extbuf.pixel_format == VA_FOURCC_UYVY ? VA_RT_FORMAT_YUV422 |
|
Pawel Osciak
2015/10/29 11:28:36
Please have a method for this conversion (VA_FOURC
william.xie1
2015/10/29 14:14:53
Done.
|
| + : VA_RT_FORMAT_RGB32, |
| + pixmap_size, va_attribs); |
| if (!va_surface) { |
| LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; |
| return nullptr; |
| @@ -90,13 +105,13 @@ scoped_refptr<VASurface> VaapiDrmPicture::CreateVASurfaceForPixmap( |
| } |
| scoped_refptr<ui::NativePixmap> VaapiDrmPicture::CreateNativePixmap( |
| - gfx::Size size) { |
| + gfx::Size size, |
| + gfx::BufferFormat format) { |
| ui::OzonePlatform* platform = ui::OzonePlatform::GetInstance(); |
| ui::SurfaceFactoryOzone* factory = platform->GetSurfaceFactoryOzone(); |
| // Create a buffer from Ozone. |
| - return factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, |
| - gfx::BufferFormat::BGRX_8888, |
| + return factory->CreateNativePixmap(gfx::kNullAcceleratedWidget, size, format, |
| gfx::BufferUsage::SCANOUT); |
| } |
| @@ -104,7 +119,7 @@ bool VaapiDrmPicture::Initialize() { |
| // We want to create a VASurface and an EGLImage out of the same |
| // memory buffer, so we can output decoded pictures to it using |
| // VAAPI and also use it to paint with GL. |
| - pixmap_ = CreateNativePixmap(size()); |
| + pixmap_ = CreateNativePixmap(size(), gfx::BufferFormat::BGRX_8888); |
|
Pawel Osciak
2015/10/29 11:28:36
Please instead of using constants directly in code
william.xie1
2015/10/29 14:14:53
Done.
|
| if (!pixmap_) { |
| LOG(ERROR) << "Failed creating an Ozone NativePixmap"; |
| return false; |
| @@ -163,7 +178,7 @@ scoped_refptr<ui::NativePixmap> VaapiDrmPicture::CallScalePixmap( |
| scoped_refptr<ui::NativePixmap> VaapiDrmPicture::ScalePixmap( |
| gfx::Size new_size) { |
| if (!scaled_va_surface_.get() || scaled_va_surface_->size() != new_size) { |
| - scaled_pixmap_ = CreateNativePixmap(new_size); |
| + scaled_pixmap_ = CreateNativePixmap(new_size, gfx::BufferFormat::UYVY_422); |
|
Pawel Osciak
2015/10/29 11:28:36
It's not obvious that "ScalePixmap" also does auto
william.xie1
2015/10/29 14:14:53
Dear Pawel, since this method is a callback functi
|
| if (!scaled_pixmap_) { |
| LOG(ERROR) << "Failed creating an Ozone NativePixmap for scaling"; |
| scaled_va_surface_ = nullptr; |