| Index: content/renderer/media/renderer_gpu_video_decoder_factories.cc
|
| ===================================================================
|
| --- content/renderer/media/renderer_gpu_video_decoder_factories.cc (revision 161170)
|
| +++ content/renderer/media/renderer_gpu_video_decoder_factories.cc (working copy)
|
| @@ -121,8 +121,8 @@
|
| gles2->BindTexture(texture_target, texture_id);
|
| gles2->TexParameteri(texture_target, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
| gles2->TexParameteri(texture_target, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
| - gles2->TexParameterf(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| - gles2->TexParameterf(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| + gles2->TexParameteri(texture_target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| + gles2->TexParameteri(texture_target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| if (texture_target == GL_TEXTURE_2D) {
|
| gles2->TexImage2D(texture_target, 0, GL_RGBA, size.width(), size.height(),
|
| 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
| @@ -152,6 +152,49 @@
|
| DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR));
|
| }
|
|
|
| +void RendererGpuVideoDecoderFactories::ReadPixels(
|
| + uint32 texture_id, uint32 texture_target, const gfx::Size& size,
|
| + void* pixels) {
|
| + base::WaitableEvent waiter(false, false);
|
| + if (!message_loop_->BelongsToCurrentThread()) {
|
| + message_loop_->PostTask(FROM_HERE, base::Bind(
|
| + &RendererGpuVideoDecoderFactories::AsyncReadPixels, this,
|
| + texture_id, texture_target, size, pixels, &waiter));
|
| + waiter.Wait();
|
| + } else {
|
| + AsyncReadPixels(texture_id, texture_target, size, pixels, &waiter);
|
| + }
|
| +}
|
| +
|
| +void RendererGpuVideoDecoderFactories::AsyncReadPixels(
|
| + uint32 texture_id, uint32 texture_target, const gfx::Size& size,
|
| + void* pixels, base::WaitableEvent* waiter) {
|
| + DCHECK(message_loop_->BelongsToCurrentThread());
|
| + if (!context_)
|
| + return;
|
| +
|
| + gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
|
| +
|
| + gles2->ActiveTexture(GL_TEXTURE0);
|
| + gles2->BindTexture(texture_target, texture_id);
|
| + gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
| + gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
| + gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
| + gles2->TexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
| +
|
| + GLuint fb;
|
| + gles2->GenFramebuffers(1, &fb);
|
| + gles2->BindFramebuffer(GL_FRAMEBUFFER, fb);
|
| + gles2->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
| + texture_target, texture_id, 0);
|
| + gles2->PixelStorei(GL_PACK_ALIGNMENT, 4);
|
| + gles2->ReadPixels(0, 0, size.width(), size.height(), GL_RGBA,
|
| + GL_UNSIGNED_BYTE, pixels);
|
| + gles2->DeleteFramebuffers(1, &fb);
|
| + DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR));
|
| + waiter->Signal();
|
| +}
|
| +
|
| base::SharedMemory* RendererGpuVideoDecoderFactories::CreateSharedMemory(
|
| size_t size) {
|
| DCHECK_NE(MessageLoop::current(), ChildThread::current()->message_loop());
|
|
|