OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/dxva_picture_buffer_win.h" | 5 #include "media/gpu/dxva_picture_buffer_win.h" |
6 | 6 |
7 #include "media/gpu/dxva_video_decode_accelerator_win.h" | 7 #include "media/gpu/dxva_video_decode_accelerator_win.h" |
8 #include "third_party/angle/include/EGL/egl.h" | 8 #include "third_party/angle/include/EGL/egl.h" |
9 #include "third_party/angle/include/EGL/eglext.h" | 9 #include "third_party/angle/include/EGL/eglext.h" |
10 #include "ui/gl/gl_bindings.h" | 10 #include "ui/gl/gl_bindings.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 | 29 |
30 enum { | 30 enum { |
31 // The keyed mutex should always be released before the other thread | 31 // The keyed mutex should always be released before the other thread |
32 // attempts to acquire it, so AcquireSync should always return immediately. | 32 // attempts to acquire it, so AcquireSync should always return immediately. |
33 kAcquireSyncWaitMs = 0, | 33 kAcquireSyncWaitMs = 0, |
34 }; | 34 }; |
35 | 35 |
36 // static | 36 // static |
37 linked_ptr<DXVAPictureBuffer> DXVAPictureBuffer::Create( | 37 linked_ptr<DXVAPictureBuffer> DXVAPictureBuffer::Create( |
38 const DXVAVideoDecodeAccelerator& decoder, | 38 const DXVAVideoDecodeAccelerator& decoder, |
39 const media::PictureBuffer& buffer, | 39 const PictureBuffer& buffer, |
40 EGLConfig egl_config) { | 40 EGLConfig egl_config) { |
41 if (decoder.share_nv12_textures_) { | 41 if (decoder.share_nv12_textures_) { |
42 linked_ptr<EGLStreamPictureBuffer> picture_buffer( | 42 linked_ptr<EGLStreamPictureBuffer> picture_buffer( |
43 new EGLStreamPictureBuffer(buffer)); | 43 new EGLStreamPictureBuffer(buffer)); |
44 if (!picture_buffer->Initialize()) | 44 if (!picture_buffer->Initialize()) |
45 return linked_ptr<DXVAPictureBuffer>(nullptr); | 45 return linked_ptr<DXVAPictureBuffer>(nullptr); |
46 | 46 |
47 return picture_buffer; | 47 return picture_buffer; |
48 } | 48 } |
49 linked_ptr<PbufferPictureBuffer> picture_buffer( | 49 linked_ptr<PbufferPictureBuffer> picture_buffer( |
(...skipping 27 matching lines...) Expand all Loading... |
77 gl::GLFence* DXVAPictureBuffer::reuse_fence() { | 77 gl::GLFence* DXVAPictureBuffer::reuse_fence() { |
78 return nullptr; | 78 return nullptr; |
79 } | 79 } |
80 | 80 |
81 bool DXVAPictureBuffer::CopySurfaceComplete(IDirect3DSurface9* src_surface, | 81 bool DXVAPictureBuffer::CopySurfaceComplete(IDirect3DSurface9* src_surface, |
82 IDirect3DSurface9* dest_surface) { | 82 IDirect3DSurface9* dest_surface) { |
83 NOTREACHED(); | 83 NOTREACHED(); |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 DXVAPictureBuffer::DXVAPictureBuffer(const media::PictureBuffer& buffer) | 87 DXVAPictureBuffer::DXVAPictureBuffer(const PictureBuffer& buffer) |
88 : available_(true), picture_buffer_(buffer) {} | 88 : available_(true), picture_buffer_(buffer) {} |
89 | 89 |
90 bool DXVAPictureBuffer::BindSampleToTexture( | 90 bool DXVAPictureBuffer::BindSampleToTexture( |
91 base::win::ScopedComPtr<IMFSample> sample) { | 91 base::win::ScopedComPtr<IMFSample> sample) { |
92 NOTREACHED(); | 92 NOTREACHED(); |
93 return false; | 93 return false; |
94 } | 94 } |
95 | 95 |
96 bool PbufferPictureBuffer::Initialize(const DXVAVideoDecodeAccelerator& decoder, | 96 bool PbufferPictureBuffer::Initialize(const DXVAVideoDecodeAccelerator& decoder, |
97 EGLConfig egl_config) { | 97 EGLConfig egl_config) { |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 } | 277 } |
278 | 278 |
279 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); | 279 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
280 eglBindTexImage(egl_display, decoding_surface_, EGL_BACK_BUFFER); | 280 eglBindTexImage(egl_display, decoding_surface_, EGL_BACK_BUFFER); |
281 | 281 |
282 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 282 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
283 glBindTexture(GL_TEXTURE_2D, current_texture); | 283 glBindTexture(GL_TEXTURE_2D, current_texture); |
284 return true; | 284 return true; |
285 } | 285 } |
286 | 286 |
287 PbufferPictureBuffer::PbufferPictureBuffer(const media::PictureBuffer& buffer) | 287 PbufferPictureBuffer::PbufferPictureBuffer(const PictureBuffer& buffer) |
288 : DXVAPictureBuffer(buffer), | 288 : DXVAPictureBuffer(buffer), |
289 waiting_to_reuse_(false), | 289 waiting_to_reuse_(false), |
290 decoding_surface_(NULL), | 290 decoding_surface_(NULL), |
291 texture_share_handle_(nullptr), | 291 texture_share_handle_(nullptr), |
292 keyed_mutex_value_(0), | 292 keyed_mutex_value_(0), |
293 use_rgb_(true) {} | 293 use_rgb_(true) {} |
294 | 294 |
295 PbufferPictureBuffer::~PbufferPictureBuffer() { | 295 PbufferPictureBuffer::~PbufferPictureBuffer() { |
296 if (decoding_surface_) { | 296 if (decoding_surface_) { |
297 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); | 297 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
(...skipping 15 matching lines...) Expand all Loading... |
313 decoder_dx11_texture_.Release(); | 313 decoder_dx11_texture_.Release(); |
314 waiting_to_reuse_ = false; | 314 waiting_to_reuse_ = false; |
315 set_available(true); | 315 set_available(true); |
316 if (egl_keyed_mutex_) { | 316 if (egl_keyed_mutex_) { |
317 HRESULT hr = egl_keyed_mutex_->ReleaseSync(++keyed_mutex_value_); | 317 HRESULT hr = egl_keyed_mutex_->ReleaseSync(++keyed_mutex_value_); |
318 RETURN_ON_FAILURE(hr == S_OK, "Could not release sync mutex", false); | 318 RETURN_ON_FAILURE(hr == S_OK, "Could not release sync mutex", false); |
319 } | 319 } |
320 return true; | 320 return true; |
321 } | 321 } |
322 | 322 |
323 EGLStreamPictureBuffer::EGLStreamPictureBuffer( | 323 EGLStreamPictureBuffer::EGLStreamPictureBuffer(const PictureBuffer& buffer) |
324 const media::PictureBuffer& buffer) | |
325 : DXVAPictureBuffer(buffer), stream_(nullptr) {} | 324 : DXVAPictureBuffer(buffer), stream_(nullptr) {} |
326 | 325 |
327 EGLStreamPictureBuffer::~EGLStreamPictureBuffer() { | 326 EGLStreamPictureBuffer::~EGLStreamPictureBuffer() { |
328 if (stream_) { | 327 if (stream_) { |
329 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); | 328 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
330 eglDestroyStreamKHR(egl_display, stream_); | 329 eglDestroyStreamKHR(egl_display, stream_); |
331 stream_ = nullptr; | 330 stream_ = nullptr; |
332 } | 331 } |
333 } | 332 } |
334 | 333 |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 EGLBoolean result = eglStreamPostD3DTextureNV12ANGLE( | 417 EGLBoolean result = eglStreamPostD3DTextureNV12ANGLE( |
419 egl_display, stream_, static_cast<void*>(dx11_decoding_texture_.get()), | 418 egl_display, stream_, static_cast<void*>(dx11_decoding_texture_.get()), |
420 frame_attributes); | 419 frame_attributes); |
421 RETURN_ON_FAILURE(result, "Could not post texture", false); | 420 RETURN_ON_FAILURE(result, "Could not post texture", false); |
422 result = eglStreamConsumerAcquireKHR(egl_display, stream_); | 421 result = eglStreamConsumerAcquireKHR(egl_display, stream_); |
423 RETURN_ON_FAILURE(result, "Could not post acquire stream", false); | 422 RETURN_ON_FAILURE(result, "Could not post acquire stream", false); |
424 return true; | 423 return true; |
425 } | 424 } |
426 | 425 |
427 } // namespace media | 426 } // namespace media |
OLD | NEW |