| 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 "content/common/gpu/media/vaapi_wrapper.h" | 5 #include "content/common/gpu/media/vaapi_wrapper.h" |
| 6 | 6 |
| 7 #include <dlfcn.h> | 7 #include <dlfcn.h> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 required_attribs.insert( | 107 required_attribs.insert( |
| 108 required_attribs.end(), | 108 required_attribs.end(), |
| 109 kEncodeVAConfigAttribs, | 109 kEncodeVAConfigAttribs, |
| 110 kEncodeVAConfigAttribs + arraysize(kEncodeVAConfigAttribs)); | 110 kEncodeVAConfigAttribs + arraysize(kEncodeVAConfigAttribs)); |
| 111 } | 111 } |
| 112 return required_attribs; | 112 return required_attribs; |
| 113 } | 113 } |
| 114 | 114 |
| 115 VASurface::VASurface(VASurfaceID va_surface_id, | 115 VASurface::VASurface(VASurfaceID va_surface_id, |
| 116 const gfx::Size& size, | 116 const gfx::Size& size, |
| 117 const unsigned int format, |
| 117 const ReleaseCB& release_cb) | 118 const ReleaseCB& release_cb) |
| 118 : va_surface_id_(va_surface_id), size_(size), release_cb_(release_cb) { | 119 : va_surface_id_(va_surface_id), |
| 120 size_(size), |
| 121 format_(format), |
| 122 release_cb_(release_cb) { |
| 119 DCHECK(!release_cb_.is_null()); | 123 DCHECK(!release_cb_.is_null()); |
| 120 } | 124 } |
| 121 | 125 |
| 122 VASurface::~VASurface() { | 126 VASurface::~VASurface() { |
| 123 release_cb_.Run(va_surface_id_); | 127 release_cb_.Run(va_surface_id_); |
| 124 } | 128 } |
| 125 | 129 |
| 126 VaapiWrapper::VaapiWrapper() | 130 VaapiWrapper::VaapiWrapper() |
| 127 : va_display_(NULL), | 131 : va_display_(NULL), |
| 128 va_config_id_(VA_INVALID_ID), | 132 va_config_id_(VA_INVALID_ID), |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 &va_surface_id, 1, &attribs[0], attribs.size()); | 576 &va_surface_id, 1, &attribs[0], attribs.size()); |
| 573 | 577 |
| 574 scoped_refptr<VASurface> va_surface; | 578 scoped_refptr<VASurface> va_surface; |
| 575 VA_SUCCESS_OR_RETURN(va_res, "Failed to create unowned VASurface", | 579 VA_SUCCESS_OR_RETURN(va_res, "Failed to create unowned VASurface", |
| 576 va_surface); | 580 va_surface); |
| 577 | 581 |
| 578 // This is safe to use Unretained() here, because the VDA takes care | 582 // This is safe to use Unretained() here, because the VDA takes care |
| 579 // of the destruction order. All the surfaces will be destroyed | 583 // of the destruction order. All the surfaces will be destroyed |
| 580 // before VaapiWrapper. | 584 // before VaapiWrapper. |
| 581 va_surface = new VASurface( | 585 va_surface = new VASurface( |
| 582 va_surface_id, size, | 586 va_surface_id, size, va_format, |
| 583 base::Bind(&VaapiWrapper::DestroyUnownedSurface, base::Unretained(this))); | 587 base::Bind(&VaapiWrapper::DestroyUnownedSurface, base::Unretained(this))); |
| 584 | 588 |
| 585 return va_surface; | 589 return va_surface; |
| 586 } | 590 } |
| 587 | 591 |
| 588 void VaapiWrapper::DestroyUnownedSurface(VASurfaceID va_surface_id) { | 592 void VaapiWrapper::DestroyUnownedSurface(VASurfaceID va_surface_id) { |
| 589 base::AutoLock auto_lock(*va_lock_); | 593 base::AutoLock auto_lock(*va_lock_); |
| 590 | 594 |
| 591 VAStatus va_res = vaDestroySurfaces(va_display_, &va_surface_id, 1); | 595 VAStatus va_res = vaDestroySurfaces(va_display_, &va_surface_id, 1); |
| 592 VA_LOG_ON_ERROR(va_res, "vaDestroySurfaces on surface failed"); | 596 VA_LOG_ON_ERROR(va_res, "vaDestroySurfaces on surface failed"); |
| (...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1150 drm_fd_.reset(HANDLE_EINTR(dup(fd))); | 1154 drm_fd_.reset(HANDLE_EINTR(dup(fd))); |
| 1151 } | 1155 } |
| 1152 #endif // USE_OZONE | 1156 #endif // USE_OZONE |
| 1153 | 1157 |
| 1154 bool VaapiWrapper::VADisplayState::VAAPIVersionLessThan(int major, int minor) { | 1158 bool VaapiWrapper::VADisplayState::VAAPIVersionLessThan(int major, int minor) { |
| 1155 return (major_version_ < major) || | 1159 return (major_version_ < major) || |
| 1156 (major_version_ == major && minor_version_ < minor); | 1160 (major_version_ == major && minor_version_ < minor); |
| 1157 } | 1161 } |
| 1158 | 1162 |
| 1159 } // namespace content | 1163 } // namespace content |
| OLD | NEW |