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 2a59e673e6df567325d02b2f86cc78dc7586e052..c3b7d0ce097da780c3c38f231ba02c81fe723445 100644 |
| --- a/content/renderer/media/renderer_gpu_video_decoder_factories.cc |
| +++ b/content/renderer/media/renderer_gpu_video_decoder_factories.cc |
| @@ -99,6 +99,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( |
| @@ -110,6 +111,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; |
| } |
| @@ -124,6 +126,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); |
| @@ -137,6 +140,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); |
|
piman
2013/06/14 21:47:29
With the new semantics, we can simply produce now,
danakj
2013/06/14 21:54:39
Done. Changed produce method to take a set of mail
|
| } |
| // 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 |
| @@ -162,6 +166,91 @@ 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_, |
| + &compositor_loop_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_) { |
| + compositor_loop_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(); |
| + compositor_loop_async_waiter_.Signal(); |
| +} |
| + |
| +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_, |
| + &compositor_loop_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_) { |
| + compositor_loop_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); |
|
piman
2013/06/14 21:47:29
Same here, we don't actually need to consume any m
danakj
2013/06/14 21:54:39
Done. Changed this method to WaitSyncPoint()
|
| + compositor_loop_async_waiter_.Signal(); |
| +} |
| + |
| void RendererGpuVideoDecoderFactories::ReadPixels( |
| uint32 texture_id, uint32 texture_target, const gfx::Size& size, |
| const SkBitmap& pixels) { |