| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/gpu/vaapi_wrapper.h" | 5 #include "media/gpu/vaapi_wrapper.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 583 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 594 // before VaapiWrapper. | 594 // before VaapiWrapper. |
| 595 va_surface = new VASurface( | 595 va_surface = new VASurface( |
| 596 va_surface_id, size, va_format, | 596 va_surface_id, size, va_format, |
| 597 base::Bind(&VaapiWrapper::DestroyUnownedSurface, base::Unretained(this))); | 597 base::Bind(&VaapiWrapper::DestroyUnownedSurface, base::Unretained(this))); |
| 598 | 598 |
| 599 return va_surface; | 599 return va_surface; |
| 600 } | 600 } |
| 601 | 601 |
| 602 #if defined(USE_OZONE) | 602 #if defined(USE_OZONE) |
| 603 scoped_refptr<VASurface> VaapiWrapper::CreateVASurfaceForPixmap( | 603 scoped_refptr<VASurface> VaapiWrapper::CreateVASurfaceForPixmap( |
| 604 const scoped_refptr<ui::NativePixmap>& pixmap) { | 604 const scoped_refptr<gfx::NativePixmap>& pixmap) { |
| 605 // Create a VASurface for a NativePixmap by importing the underlying dmabufs. | 605 // Create a VASurface for a NativePixmap by importing the underlying dmabufs. |
| 606 VASurfaceAttribExternalBuffers va_attrib_extbuf; | 606 VASurfaceAttribExternalBuffers va_attrib_extbuf; |
| 607 memset(&va_attrib_extbuf, 0, sizeof(va_attrib_extbuf)); | 607 memset(&va_attrib_extbuf, 0, sizeof(va_attrib_extbuf)); |
| 608 | 608 |
| 609 va_attrib_extbuf.pixel_format = | 609 va_attrib_extbuf.pixel_format = |
| 610 BufferFormatToVAFourCC(pixmap->GetBufferFormat()); | 610 BufferFormatToVAFourCC(pixmap->GetBufferFormat()); |
| 611 gfx::Size size = pixmap->GetBufferSize(); | 611 gfx::Size size = pixmap->GetBufferSize(); |
| 612 va_attrib_extbuf.width = size.width(); | 612 va_attrib_extbuf.width = size.width(); |
| 613 va_attrib_extbuf.height = size.height(); | 613 va_attrib_extbuf.height = size.height(); |
| 614 | 614 |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 660 BufferFormatToVARTFormat(pixmap->GetBufferFormat()), size, va_attribs); | 660 BufferFormatToVARTFormat(pixmap->GetBufferFormat()), size, va_attribs); |
| 661 if (!va_surface) { | 661 if (!va_surface) { |
| 662 LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; | 662 LOG(ERROR) << "Failed to create VASurface for an Ozone NativePixmap"; |
| 663 return nullptr; | 663 return nullptr; |
| 664 } | 664 } |
| 665 | 665 |
| 666 return va_surface; | 666 return va_surface; |
| 667 } | 667 } |
| 668 | 668 |
| 669 bool VaapiWrapper::ProcessPixmap( | 669 bool VaapiWrapper::ProcessPixmap( |
| 670 const scoped_refptr<ui::NativePixmap>& source_pixmap, | 670 const scoped_refptr<gfx::NativePixmap>& source_pixmap, |
| 671 scoped_refptr<ui::NativePixmap> target_pixmap) { | 671 scoped_refptr<gfx::NativePixmap> target_pixmap) { |
| 672 scoped_refptr<VASurface> va_surface = CreateVASurfaceForPixmap(source_pixmap); | 672 scoped_refptr<VASurface> va_surface = CreateVASurfaceForPixmap(source_pixmap); |
| 673 if (!va_surface) { | 673 if (!va_surface) { |
| 674 LOG(ERROR) << "Failed creating VA Surface for source_pixmap"; | 674 LOG(ERROR) << "Failed creating VA Surface for source_pixmap"; |
| 675 return false; | 675 return false; |
| 676 } | 676 } |
| 677 | 677 |
| 678 scoped_refptr<VASurface> processed_va_surface = | 678 scoped_refptr<VASurface> processed_va_surface = |
| 679 CreateVASurfaceForPixmap(target_pixmap); | 679 CreateVASurfaceForPixmap(target_pixmap); |
| 680 if (!processed_va_surface) { | 680 if (!processed_va_surface) { |
| 681 LOG(ERROR) << "Failed creating processed VA Surface for pixmap"; | 681 LOG(ERROR) << "Failed creating processed VA Surface for pixmap"; |
| (...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1253 drm_fd_.reset(HANDLE_EINTR(dup(fd))); | 1253 drm_fd_.reset(HANDLE_EINTR(dup(fd))); |
| 1254 } | 1254 } |
| 1255 #endif // USE_OZONE | 1255 #endif // USE_OZONE |
| 1256 | 1256 |
| 1257 bool VaapiWrapper::VADisplayState::VAAPIVersionLessThan(int major, int minor) { | 1257 bool VaapiWrapper::VADisplayState::VAAPIVersionLessThan(int major, int minor) { |
| 1258 return (major_version_ < major) || | 1258 return (major_version_ < major) || |
| 1259 (major_version_ == major && minor_version_ < minor); | 1259 (major_version_ == major && minor_version_ < minor); |
| 1260 } | 1260 } |
| 1261 | 1261 |
| 1262 } // namespace media | 1262 } // namespace media |
| OLD | NEW |