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

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: video-mailbox: remove extra produce in webmediaplayer_impl Created 7 years, 6 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 2a59e673e6df567325d02b2f86cc78dc7586e052..8789de03d372a5aef6ef34f035d3d43129514300 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);
}
// 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,80 @@ void RendererGpuVideoDecoderFactories::AsyncDeleteTexture(uint32 texture_id) {
DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR));
}
+uint32 RendererGpuVideoDecoderFactories::ProduceTexturesToMailboxes(
+ const std::vector<gpu::Mailbox>& mailboxes,
+ const std::vector<uint32>& texture_ids,
+ uint32 texture_target) {
+ uint32 sync_point = 0;
+ if (message_loop_->BelongsToCurrentThread()) {
+ AsyncProduceTextureToMailbox(
+ mailboxes, texture_ids, texture_target, &sync_point);
+ return sync_point;
+ }
+
+ message_loop_->PostTask(FROM_HERE, base::Bind(
+ &RendererGpuVideoDecoderFactories::AsyncProduceTextureToMailbox,
+ this,
+ mailboxes,
+ texture_ids,
+ 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 std::vector<gpu::Mailbox>& mailboxes,
+ const std::vector<uint32>& texture_ids,
+ 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();
+ DCHECK_EQ(mailboxes.size(), texture_ids.size());
+ for (size_t i = 0; i < mailboxes.size() && i < texture_ids.size(); ++i) {
+ gles2->BindTexture(texture_target, texture_ids[i]);
+ gles2->ProduceTextureCHROMIUM(texture_target, mailboxes[i].name);
+ }
+ *sync_point = gles2->InsertSyncPointCHROMIUM();
+ compositor_loop_async_waiter_.Signal();
+}
+
+void RendererGpuVideoDecoderFactories::WaitSyncPoint(uint32 sync_point) {
+ if (message_loop_->BelongsToCurrentThread()) {
+ AsyncWaitSyncPoint(sync_point);
+ return;
+ }
+
+ message_loop_->PostTask(FROM_HERE, base::Bind(
+ &RendererGpuVideoDecoderFactories::AsyncWaitSyncPoint,
+ this,
+ sync_point));
+ base::WaitableEvent* objects[] = {&aborted_waiter_,
+ &compositor_loop_async_waiter_};
+ base::WaitableEvent::WaitMany(objects, arraysize(objects));
+}
+
+void RendererGpuVideoDecoderFactories::AsyncWaitSyncPoint(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);
+ compositor_loop_async_waiter_.Signal();
+}
+
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