| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/dxva_video_decode_accelerator_win.h" | 5 #include "content/common/gpu/media/dxva_video_decode_accelerator_win.h" |
| 6 | 6 |
| 7 #if !defined(OS_WIN) | 7 #if !defined(OS_WIN) |
| 8 #error This file should only be built on Windows. | 8 #error This file should only be built on Windows. |
| 9 #endif // !defined(OS_WIN) | 9 #endif // !defined(OS_WIN) |
| 10 | 10 |
| (...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 767 } | 767 } |
| 768 | 768 |
| 769 bool DXVAVideoDecodeAccelerator::DXVAPictureBuffer::CopySurfaceComplete( | 769 bool DXVAVideoDecodeAccelerator::DXVAPictureBuffer::CopySurfaceComplete( |
| 770 IDirect3DSurface9* src_surface, | 770 IDirect3DSurface9* src_surface, |
| 771 IDirect3DSurface9* dest_surface) { | 771 IDirect3DSurface9* dest_surface) { |
| 772 DCHECK(!available()); | 772 DCHECK(!available()); |
| 773 | 773 |
| 774 GLint current_texture = 0; | 774 GLint current_texture = 0; |
| 775 glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); | 775 glGetIntegerv(GL_TEXTURE_BINDING_2D, ¤t_texture); |
| 776 | 776 |
| 777 glBindTexture(GL_TEXTURE_2D, picture_buffer_.texture_id()); | 777 glBindTexture(GL_TEXTURE_2D, picture_buffer_.texture_ids()[0]); |
| 778 | 778 |
| 779 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | 779 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
| 780 | 780 |
| 781 if (src_surface && dest_surface) { | 781 if (src_surface && dest_surface) { |
| 782 DCHECK_EQ(src_surface, decoder_surface_.get()); | 782 DCHECK_EQ(src_surface, decoder_surface_.get()); |
| 783 DCHECK_EQ(dest_surface, target_surface_.get()); | 783 DCHECK_EQ(dest_surface, target_surface_.get()); |
| 784 decoder_surface_.Release(); | 784 decoder_surface_.Release(); |
| 785 target_surface_.Release(); | 785 target_surface_.Release(); |
| 786 } else { | 786 } else { |
| 787 DCHECK(decoder_dx11_texture_.get()); | 787 DCHECK(decoder_dx11_texture_.get()); |
| (...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 RETURN_AND_NOTIFY_ON_FAILURE((state != kUninitialized), | 1143 RETURN_AND_NOTIFY_ON_FAILURE((state != kUninitialized), |
| 1144 "Invalid state: " << state, ILLEGAL_STATE,); | 1144 "Invalid state: " << state, ILLEGAL_STATE,); |
| 1145 RETURN_AND_NOTIFY_ON_FAILURE((kNumPictureBuffers >= buffers.size()), | 1145 RETURN_AND_NOTIFY_ON_FAILURE((kNumPictureBuffers >= buffers.size()), |
| 1146 "Failed to provide requested picture buffers. (Got " << buffers.size() << | 1146 "Failed to provide requested picture buffers. (Got " << buffers.size() << |
| 1147 ", requested " << kNumPictureBuffers << ")", INVALID_ARGUMENT,); | 1147 ", requested " << kNumPictureBuffers << ")", INVALID_ARGUMENT,); |
| 1148 | 1148 |
| 1149 // Copy the picture buffers provided by the client to the available list, | 1149 // Copy the picture buffers provided by the client to the available list, |
| 1150 // and mark these buffers as available for use. | 1150 // and mark these buffers as available for use. |
| 1151 for (size_t buffer_index = 0; buffer_index < buffers.size(); | 1151 for (size_t buffer_index = 0; buffer_index < buffers.size(); |
| 1152 ++buffer_index) { | 1152 ++buffer_index) { |
| 1153 DCHECK_LE(1u, buffers[buffer_index].texture_ids().size()); |
| 1153 linked_ptr<DXVAPictureBuffer> picture_buffer = | 1154 linked_ptr<DXVAPictureBuffer> picture_buffer = |
| 1154 DXVAPictureBuffer::Create(*this, buffers[buffer_index], egl_config_); | 1155 DXVAPictureBuffer::Create(*this, buffers[buffer_index], egl_config_); |
| 1155 RETURN_AND_NOTIFY_ON_FAILURE(picture_buffer.get(), | 1156 RETURN_AND_NOTIFY_ON_FAILURE(picture_buffer.get(), |
| 1156 "Failed to allocate picture buffer", PLATFORM_FAILURE,); | 1157 "Failed to allocate picture buffer", PLATFORM_FAILURE,); |
| 1157 | 1158 |
| 1158 bool inserted = output_picture_buffers_.insert(std::make_pair( | 1159 bool inserted = output_picture_buffers_.insert(std::make_pair( |
| 1159 buffers[buffer_index].id(), picture_buffer)).second; | 1160 buffers[buffer_index].id(), picture_buffer)).second; |
| 1160 DCHECK(inserted); | 1161 DCHECK(inserted); |
| 1161 } | 1162 } |
| 1162 | 1163 |
| (...skipping 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1879 void DXVAVideoDecodeAccelerator::NotifyResetDone() { | 1880 void DXVAVideoDecodeAccelerator::NotifyResetDone() { |
| 1880 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1881 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 1881 if (client_) | 1882 if (client_) |
| 1882 client_->NotifyResetDone(); | 1883 client_->NotifyResetDone(); |
| 1883 } | 1884 } |
| 1884 | 1885 |
| 1885 void DXVAVideoDecodeAccelerator::RequestPictureBuffers(int width, int height) { | 1886 void DXVAVideoDecodeAccelerator::RequestPictureBuffers(int width, int height) { |
| 1886 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1887 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 1887 // This task could execute after the decoder has been torn down. | 1888 // This task could execute after the decoder has been torn down. |
| 1888 if (GetState() != kUninitialized && client_) { | 1889 if (GetState() != kUninitialized && client_) { |
| 1889 client_->ProvidePictureBuffers( | 1890 client_->ProvidePictureBuffers(kNumPictureBuffers, 1, |
| 1890 kNumPictureBuffers, | 1891 gfx::Size(width, height), GL_TEXTURE_2D); |
| 1891 gfx::Size(width, height), | |
| 1892 GL_TEXTURE_2D); | |
| 1893 } | 1892 } |
| 1894 } | 1893 } |
| 1895 | 1894 |
| 1896 void DXVAVideoDecodeAccelerator::NotifyPictureReady( | 1895 void DXVAVideoDecodeAccelerator::NotifyPictureReady( |
| 1897 int picture_buffer_id, | 1896 int picture_buffer_id, |
| 1898 int input_buffer_id) { | 1897 int input_buffer_id) { |
| 1899 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); | 1898 DCHECK(main_thread_task_runner_->BelongsToCurrentThread()); |
| 1900 // This task could execute after the decoder has been torn down. | 1899 // This task could execute after the decoder has been torn down. |
| 1901 if (GetState() != kUninitialized && client_) { | 1900 if (GetState() != kUninitialized && client_) { |
| 1902 // TODO(henryhsu): Use correct visible size instead of (0, 0). We can't use | 1901 // TODO(henryhsu): Use correct visible size instead of (0, 0). We can't use |
| (...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2656 DismissStaleBuffers(true); | 2655 DismissStaleBuffers(true); |
| 2657 Invalidate(); | 2656 Invalidate(); |
| 2658 Initialize(config_, client_); | 2657 Initialize(config_, client_); |
| 2659 decoder_thread_task_runner_->PostTask( | 2658 decoder_thread_task_runner_->PostTask( |
| 2660 FROM_HERE, | 2659 FROM_HERE, |
| 2661 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, | 2660 base::Bind(&DXVAVideoDecodeAccelerator::DecodePendingInputBuffers, |
| 2662 base::Unretained(this))); | 2661 base::Unretained(this))); |
| 2663 } | 2662 } |
| 2664 | 2663 |
| 2665 } // namespace content | 2664 } // namespace content |
| OLD | NEW |