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

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

Issue 175223003: HW Video: Make media::VideoFrame handle the sync point of the compositor as well as webgl (Closed) Base URL: https://git.chromium.org/chromium/src.git@master
Patch Set: Make GpuVideoAcceleratorFactories::ReadPixels() receive mailbox, instead of texture Created 6 years, 9 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_accelerator_factories.cc
diff --git a/content/renderer/media/renderer_gpu_video_accelerator_factories.cc b/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
index 02fd859d0cc1f3376cc971185f657ce9af98ff0c..78eab82fa78cf62ad77c9dc0a41e2c22e76fe174 100644
--- a/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
+++ b/content/renderer/media/renderer_gpu_video_accelerator_factories.cc
@@ -14,6 +14,7 @@
#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
#include "content/renderer/render_thread_impl.h"
#include "gpu/command_buffer/client/gles2_implementation.h"
+#include "gpu/command_buffer/common/mailbox_holder.h"
#include "third_party/skia/include/core/SkBitmap.h"
#include "third_party/skia/include/core/SkPixelRef.h"
@@ -166,8 +167,7 @@ void RendererGpuVideoAcceleratorFactories::WaitSyncPoint(uint32 sync_point) {
}
void RendererGpuVideoAcceleratorFactories::ReadPixels(
- uint32 texture_id,
- const gfx::Rect& visible_rect,
+ const scoped_refptr<media::VideoFrame>& video_frame,
dshwang 2014/03/10 17:38:08 This CL changes GpuVideoAcceleratorFactories::Read
const SkBitmap& pixels) {
DCHECK(task_runner_->BelongsToCurrentThread());
@@ -175,8 +175,19 @@ void RendererGpuVideoAcceleratorFactories::ReadPixels(
if (!context)
return;
+ DCHECK_EQ(media::VideoFrame::NATIVE_TEXTURE, video_frame->format());
+ gpu::MailboxHolder* mailbox_holder = video_frame->mailbox_holder();
+ DCHECK(mailbox_holder);
gpu::gles2::GLES2Implementation* gles2 = context->GetImplementation();
+ uint32 texture_id = 0;
+ gles2->GenTextures(1, &texture_id);
+ gles2->WaitSyncPointCHROMIUM(mailbox_holder->sync_point);
+ // Currently, Android doesn't use this.
+ DCHECK_EQ(GL_TEXTURE_2D, mailbox_holder->texture_target);
+ gles2->BindTexture(GL_TEXTURE_2D, texture_id);
+ gles2->ConsumeTextureCHROMIUM(GL_TEXTURE_2D, mailbox_holder->mailbox.name);
+
GLuint tmp_texture;
gles2->GenTextures(1, &tmp_texture);
gles2->BindTexture(GL_TEXTURE_2D, tmp_texture);
@@ -186,6 +197,7 @@ void RendererGpuVideoAcceleratorFactories::ReadPixels(
gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
context->copyTextureCHROMIUM(
GL_TEXTURE_2D, texture_id, tmp_texture, 0, GL_RGBA, GL_UNSIGNED_BYTE);
+ gles2->DeleteTextures(1, &texture_id);
GLuint fb;
gles2->GenFramebuffers(1, &fb);
@@ -202,6 +214,7 @@ void RendererGpuVideoAcceleratorFactories::ReadPixels(
#else
#error Unexpected Skia ARGB_8888 layout!
#endif
+ gfx::Rect visible_rect = video_frame->visible_rect();
gles2->ReadPixels(visible_rect.x(),
visible_rect.y(),
visible_rect.width(),
@@ -211,6 +224,8 @@ void RendererGpuVideoAcceleratorFactories::ReadPixels(
pixels.pixelRef()->pixels());
gles2->DeleteFramebuffers(1, &fb);
gles2->DeleteTextures(1, &tmp_texture);
+ gles2->Flush();
dshwang 2014/03/10 17:38:08 Now, this API can be called for the video frame th
+ video_frame->AppendReleaseSyncPoint(gles2->InsertSyncPointCHROMIUM());
DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR));
}

Powered by Google App Engine
This is Rietveld 408576698