Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Unified Diff: content/renderer/media/renderer_gpu_video_decoder_factories.cc

Issue 14199002: Send hardware video frames with mailboxes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Ifdefed Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..66e0b5684ebecd29b665859a9cb2a768994d57d4 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,73 @@ 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 sync_point = 0;
+ if (message_loop_->BelongsToCurrentThread()) {
+ AsyncProduceTextureToMailbox(mailbox, texture_id, &sync_point);
+ return sync_point;
+ }
+
+ message_loop_->PostTask(FROM_HERE, base::Bind(
+ &RendererGpuVideoDecoderFactories::AsyncProduceTextureToMailbox,
+ this,
+ mailbox,
+ texture_id,
+ &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* sync_point) {
+ DCHECK(message_loop_->BelongsToCurrentThread());
+
+ *sync_point = 0;
+ if (!context_) {
+ async_waiter_.Signal();
+ return;
+ }
+
+ gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
+ gles2->BindTexture(GL_TEXTURE_2D, texture_id);
+ gles2->ProduceTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
+ *sync_point = gles2->InsertSyncPointCHROMIUM();
+}
+
+void RendererGpuVideoDecoderFactories::ConsumeMailboxToTexture(
+ const gpu::Mailbox& mailbox, uint32 texture_id, uint32 sync_point) {
+ if (message_loop_->BelongsToCurrentThread()) {
+ AsyncConsumeMailboxToTexture(mailbox, texture_id, sync_point);
+ return;
+ }
+
+ message_loop_->PostTask(FROM_HERE, base::Bind(
+ &RendererGpuVideoDecoderFactories::AsyncConsumeMailboxToTexture,
+ this,
+ mailbox,
+ texture_id,
+ 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 sync_point) {
+ DCHECK(message_loop_->BelongsToCurrentThread());
+ if (!context_) {
+ async_waiter_.Signal();
+ return;
+ }
+
+ gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
+ gles2->WaitSyncPointCHROMIUM(sync_point);
+ gles2->BindTexture(GL_TEXTURE_2D, texture_id);
+ gles2->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox.name);
+}
+
void RendererGpuVideoDecoderFactories::ReadPixels(
uint32 texture_id, uint32 texture_target, const gfx::Size& size,
const SkBitmap& pixels) {

Powered by Google App Engine
This is Rietveld 408576698