Chromium Code Reviews| Index: content/renderer/media/renderer_gpu_video_decoder_factories.cc |
| diff --git a/content/renderer/media/renderer_gpu_video_decoder_factories.cc b/content/renderer/media/renderer_gpu_video_decoder_factories.cc |
| index 1f0e85a754badb76c2f739d0ec3b049ed7ca7af3..fb46a6c5ddbaf71098c1f68ce41e95561caaec9e 100644 |
| --- a/content/renderer/media/renderer_gpu_video_decoder_factories.cc |
| +++ b/content/renderer/media/renderer_gpu_video_decoder_factories.cc |
| @@ -98,6 +98,7 @@ void RendererGpuVideoDecoderFactories::AsyncCreateVideoDecodeAccelerator( |
| bool RendererGpuVideoDecoderFactories::CreateTextures( |
| int32 count, const gfx::Size& size, |
| std::vector<uint32>* texture_ids, |
| + std::vector<gpu::Mailbox>* texture_mailboxes, |
| uint32 texture_target) { |
| DCHECK(!message_loop_->BelongsToCurrentThread()); |
| message_loop_->PostTask(FROM_HERE, base::Bind( |
| @@ -108,6 +109,7 @@ bool RendererGpuVideoDecoderFactories::CreateTextures( |
| if (base::WaitableEvent::WaitMany(objects, arraysize(objects)) == 0) |
| return false; |
| texture_ids->swap(created_textures_); |
| + texture_mailboxes->swap(created_texture_mailboxes_); |
| return true; |
| } |
| @@ -122,6 +124,7 @@ void RendererGpuVideoDecoderFactories::AsyncCreateTextures( |
| } |
| gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); |
| created_textures_.resize(count); |
| + created_texture_mailboxes_.resize(count); |
| gles2->GenTextures(count, &created_textures_[0]); |
| for (int i = 0; i < count; ++i) { |
| gles2->ActiveTexture(GL_TEXTURE0); |
| @@ -135,6 +138,7 @@ void RendererGpuVideoDecoderFactories::AsyncCreateTextures( |
| gles2->TexImage2D(texture_target, 0, GL_RGBA, size.width(), size.height(), |
| 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); |
| } |
| + gles2->GenMailboxCHROMIUM(created_texture_mailboxes_[i].name); |
| } |
| // We need a glFlush here to guarantee the decoder (in the GPU process) can |
| // use the texture ids we return here. Since textures are expected to be |
| @@ -160,6 +164,89 @@ void RendererGpuVideoDecoderFactories::AsyncDeleteTexture(uint32 texture_id) { |
| DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR)); |
| } |
| +uint32 RendererGpuVideoDecoderFactories::ProduceTextureToMailbox( |
| + const gpu::Mailbox& mailbox, |
| + uint32 texture_id, |
| + uint32 texture_target) { |
| + uint32 sync_point = 0; |
| + if (message_loop_->BelongsToCurrentThread()) { |
| + AsyncProduceTextureToMailbox( |
| + mailbox, texture_id, texture_target, &sync_point); |
| + return sync_point; |
| + } |
| + |
| + message_loop_->PostTask(FROM_HERE, base::Bind( |
| + &RendererGpuVideoDecoderFactories::AsyncProduceTextureToMailbox, |
| + this, |
| + mailbox, |
| + texture_id, |
| + texture_target, |
| + &sync_point)); |
| + base::WaitableEvent* objects[] = {&aborted_waiter_, &async_waiter_}; |
| + base::WaitableEvent::WaitMany(objects, arraysize(objects)); |
| + return sync_point; |
| +} |
| + |
| +void RendererGpuVideoDecoderFactories::AsyncProduceTextureToMailbox( |
| + const gpu::Mailbox& mailbox, |
| + uint32 texture_id, |
| + uint32 texture_target, |
| + uint32* sync_point) { |
| + DCHECK(message_loop_->BelongsToCurrentThread()); |
| + |
| + *sync_point = 0; |
| + if (!context_) { |
| + async_waiter_.Signal(); |
| + return; |
| + } |
| + |
| + gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); |
| + gles2->BindTexture(texture_target, texture_id); |
| + gles2->ProduceTextureCHROMIUM(texture_target, mailbox.name); |
| + *sync_point = gles2->InsertSyncPointCHROMIUM(); |
| + async_waiter_.Signal(); |
|
danakj
2013/04/19 20:44:43
I was missing these Signal()s which broke everythi
|
| +} |
| + |
| +void RendererGpuVideoDecoderFactories::ConsumeMailboxToTexture( |
| + const gpu::Mailbox& mailbox, |
| + uint32 texture_id, |
| + uint32 texture_target, |
| + uint32 sync_point) { |
| + if (message_loop_->BelongsToCurrentThread()) { |
| + AsyncConsumeMailboxToTexture( |
| + mailbox, texture_id, texture_target, sync_point); |
| + return; |
| + } |
| + |
| + message_loop_->PostTask(FROM_HERE, base::Bind( |
| + &RendererGpuVideoDecoderFactories::AsyncConsumeMailboxToTexture, |
| + this, |
| + mailbox, |
| + texture_id, |
| + texture_target, |
| + sync_point)); |
| + base::WaitableEvent* objects[] = {&aborted_waiter_, &async_waiter_}; |
| + base::WaitableEvent::WaitMany(objects, arraysize(objects)); |
| +} |
| + |
| +void RendererGpuVideoDecoderFactories::AsyncConsumeMailboxToTexture( |
| + const gpu::Mailbox& mailbox, |
| + uint32 texture_id, |
| + uint32 texture_target, |
| + uint32 sync_point) { |
| + DCHECK(message_loop_->BelongsToCurrentThread()); |
| + if (!context_) { |
| + async_waiter_.Signal(); |
| + return; |
| + } |
| + |
| + gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation(); |
| + gles2->WaitSyncPointCHROMIUM(sync_point); |
| + gles2->BindTexture(texture_target, texture_id); |
| + gles2->ConsumeTextureCHROMIUM(texture_target, mailbox.name); |
| + async_waiter_.Signal(); |
| +} |
| + |
| void RendererGpuVideoDecoderFactories::ReadPixels( |
| uint32 texture_id, uint32 texture_target, const gfx::Size& size, |
| const SkBitmap& pixels) { |