| 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 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 ID3D11Texture2D* dx11_texture, | 527 ID3D11Texture2D* dx11_texture, |
| 528 int input_buffer_id) { | 528 int input_buffer_id) { |
| 529 DCHECK(dx11_texture); | 529 DCHECK(dx11_texture); |
| 530 // Grab a reference on the decoder texture. This reference will be released | 530 // Grab a reference on the decoder texture. This reference will be released |
| 531 // when we receive a notification that the copy was completed or when the | 531 // when we receive a notification that the copy was completed or when the |
| 532 // DXVAPictureBuffer instance is destroyed. | 532 // DXVAPictureBuffer instance is destroyed. |
| 533 dx11_decoding_texture_ = dx11_texture; | 533 dx11_decoding_texture_ = dx11_texture; |
| 534 decoder->CopyTexture(dx11_texture, decoder_copy_texture_.get(), | 534 decoder->CopyTexture(dx11_texture, decoder_copy_texture_.get(), |
| 535 dx11_keyed_mutex_, keyed_mutex_value_, id(), | 535 dx11_keyed_mutex_, keyed_mutex_value_, id(), |
| 536 input_buffer_id); | 536 input_buffer_id); |
| 537 // The texture copy will acquire the current keyed mutex value and release |
| 538 // with the value + 1. |
| 539 keyed_mutex_value_++; |
| 537 return true; | 540 return true; |
| 538 } | 541 } |
| 539 | 542 |
| 540 bool EGLStreamCopyPictureBuffer::CopySurfaceComplete( | 543 bool EGLStreamCopyPictureBuffer::CopySurfaceComplete( |
| 541 IDirect3DSurface9* src_surface, | 544 IDirect3DSurface9* src_surface, |
| 542 IDirect3DSurface9* dest_surface) { | 545 IDirect3DSurface9* dest_surface) { |
| 543 DCHECK(!available()); | 546 DCHECK(!available()); |
| 544 DCHECK(!src_surface); | 547 DCHECK(!src_surface); |
| 545 DCHECK(!dest_surface); | 548 DCHECK(!dest_surface); |
| 546 | 549 |
| 547 dx11_decoding_texture_.Release(); | 550 dx11_decoding_texture_.Release(); |
| 548 | 551 |
| 549 keyed_mutex_value_++; | |
| 550 HRESULT hr = | 552 HRESULT hr = |
| 551 egl_keyed_mutex_->AcquireSync(keyed_mutex_value_, kAcquireSyncWaitMs); | 553 egl_keyed_mutex_->AcquireSync(keyed_mutex_value_, kAcquireSyncWaitMs); |
| 552 RETURN_ON_FAILURE(hr == S_OK, "Could not acquire sync mutex", false); | 554 RETURN_ON_FAILURE(hr == S_OK, "Could not acquire sync mutex", false); |
| 553 | 555 |
| 554 EGLAttrib frame_attributes[] = { | 556 EGLAttrib frame_attributes[] = { |
| 555 EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, 0, EGL_NONE, | 557 EGL_D3D_TEXTURE_SUBRESOURCE_ID_ANGLE, 0, EGL_NONE, |
| 556 }; | 558 }; |
| 557 | 559 |
| 558 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); | 560 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
| 559 | 561 |
| 560 EGLBoolean result = eglStreamPostD3DTextureNV12ANGLE( | 562 EGLBoolean result = eglStreamPostD3DTextureNV12ANGLE( |
| 561 egl_display, stream_, static_cast<void*>(angle_copy_texture_.get()), | 563 egl_display, stream_, static_cast<void*>(angle_copy_texture_.get()), |
| 562 frame_attributes); | 564 frame_attributes); |
| 563 RETURN_ON_FAILURE(result, "Could not post stream", false); | 565 RETURN_ON_FAILURE(result, "Could not post stream", false); |
| 564 result = eglStreamConsumerAcquireKHR(egl_display, stream_); | 566 result = eglStreamConsumerAcquireKHR(egl_display, stream_); |
| 565 RETURN_ON_FAILURE(result, "Could not post acquire stream", false); | 567 RETURN_ON_FAILURE(result, "Could not post acquire stream", false); |
| 568 frame_in_consumer_ = true; |
| 566 | 569 |
| 567 return true; | 570 return true; |
| 568 } | 571 } |
| 569 | 572 |
| 570 bool EGLStreamCopyPictureBuffer::ReusePictureBuffer() { | 573 bool EGLStreamCopyPictureBuffer::ReusePictureBuffer() { |
| 571 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); | 574 EGLDisplay egl_display = gl::GLSurfaceEGL::GetHardwareDisplay(); |
| 572 | 575 |
| 573 HRESULT hr = egl_keyed_mutex_->ReleaseSync(++keyed_mutex_value_); | 576 if (frame_in_consumer_) { |
| 574 RETURN_ON_FAILURE(hr == S_OK, "Could not release sync mutex", false); | 577 HRESULT hr = egl_keyed_mutex_->ReleaseSync(++keyed_mutex_value_); |
| 578 RETURN_ON_FAILURE(hr == S_OK, "Could not release sync mutex", false); |
| 579 } |
| 580 frame_in_consumer_ = false; |
| 575 | 581 |
| 576 if (stream_) { | 582 if (stream_) { |
| 577 EGLBoolean result = eglStreamConsumerReleaseKHR(egl_display, stream_); | 583 EGLBoolean result = eglStreamConsumerReleaseKHR(egl_display, stream_); |
| 578 RETURN_ON_FAILURE(result, "Could not release stream", false); | 584 RETURN_ON_FAILURE(result, "Could not release stream", false); |
| 579 } | 585 } |
| 580 set_available(true); | 586 set_available(true); |
| 581 return true; | 587 return true; |
| 582 } | 588 } |
| 583 | 589 |
| 584 } // namespace media | 590 } // namespace media |
| OLD | NEW |