| 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 e79834db313b05b15aa0e92aa42103d16cbc9e11..6d8f48eeb1f5112830b8fcd0760f2df9eb691ba4 100644
|
| --- a/content/renderer/media/renderer_gpu_video_decoder_factories.cc
|
| +++ b/content/renderer/media/renderer_gpu_video_decoder_factories.cc
|
| @@ -9,21 +9,23 @@
|
| #include "content/common/child_thread.h"
|
| #include "content/common/gpu/client/command_buffer_proxy.h"
|
| #include "content/common/gpu/client/gpu_channel_host.h"
|
| -#include "content/common/gpu/client/content_gl_context.h"
|
| +#include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h"
|
| #include "gpu/command_buffer/client/gles2_implementation.h"
|
|
|
| RendererGpuVideoDecoderFactories::~RendererGpuVideoDecoderFactories() {}
|
| RendererGpuVideoDecoderFactories::RendererGpuVideoDecoderFactories(
|
| - GpuChannelHost* gpu_channel_host, base::WeakPtr<ContentGLContext> context)
|
| - : message_loop_(MessageLoop::current()),
|
| + GpuChannelHost* gpu_channel_host, MessageLoop* message_loop,
|
| + WebGraphicsContext3DCommandBufferImpl* wgc3dcbi)
|
| + : message_loop_(message_loop),
|
| gpu_channel_host_(gpu_channel_host),
|
| - context_(context) {
|
| + wgc3dcbi_(wgc3dcbi) {
|
| }
|
|
|
| media::VideoDecodeAccelerator*
|
| RendererGpuVideoDecoderFactories::CreateVideoDecodeAccelerator(
|
| media::VideoDecodeAccelerator::Profile profile,
|
| media::VideoDecodeAccelerator::Client* client) {
|
| + DCHECK_NE(MessageLoop::current(), message_loop_);
|
| media::VideoDecodeAccelerator* vda = NULL;
|
| base::WaitableEvent waiter(false, false);
|
| message_loop_->PostTask(FROM_HERE, base::Bind(
|
| @@ -38,9 +40,11 @@ void RendererGpuVideoDecoderFactories::AsyncCreateVideoDecodeAccelerator(
|
| media::VideoDecodeAccelerator::Client* client,
|
| media::VideoDecodeAccelerator** vda,
|
| base::WaitableEvent* waiter) {
|
| - if (context_) {
|
| + DCHECK_EQ(MessageLoop::current(), message_loop_);
|
| + if (wgc3dcbi_->makeContextCurrent()) {
|
| *vda = gpu_channel_host_->CreateVideoDecoder(
|
| - context_->GetCommandBufferProxy()->route_id(), profile, client);
|
| + wgc3dcbi_->context()->GetCommandBufferProxy()->route_id(),
|
| + profile, client);
|
| } else {
|
| *vda = NULL;
|
| }
|
| @@ -51,6 +55,7 @@ bool RendererGpuVideoDecoderFactories::CreateTextures(
|
| int32 count, const gfx::Size& size,
|
| std::vector<uint32>* texture_ids,
|
| uint32* texture_target) {
|
| + DCHECK_NE(MessageLoop::current(), message_loop_);
|
| bool success = false;
|
| base::WaitableEvent waiter(false, false);
|
| message_loop_->PostTask(FROM_HERE, base::Bind(
|
| @@ -63,12 +68,14 @@ bool RendererGpuVideoDecoderFactories::CreateTextures(
|
| void RendererGpuVideoDecoderFactories::AsyncCreateTextures(
|
| int32 count, const gfx::Size& size, std::vector<uint32>* texture_ids,
|
| uint32* texture_target, bool* success, base::WaitableEvent* waiter) {
|
| - if (!context_) {
|
| + DCHECK_EQ(MessageLoop::current(), message_loop_);
|
| + if (!wgc3dcbi_->makeContextCurrent()) {
|
| *success = false;
|
| waiter->Signal();
|
| return;
|
| }
|
| - gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
|
| + gpu::gles2::GLES2Implementation* gles2 =
|
| + wgc3dcbi_->context()->GetImplementation();
|
| texture_ids->resize(count);
|
| gles2->GenTextures(count, &texture_ids->at(0));
|
| *texture_target = GL_TEXTURE_2D;
|
| @@ -93,24 +100,27 @@ void RendererGpuVideoDecoderFactories::AsyncCreateTextures(
|
| }
|
|
|
| void RendererGpuVideoDecoderFactories::DeleteTexture(uint32 texture_id) {
|
| + DCHECK_NE(MessageLoop::current(), message_loop_);
|
| message_loop_->PostTask(FROM_HERE, base::Bind(
|
| &RendererGpuVideoDecoderFactories::AsyncDeleteTexture, this, texture_id));
|
| }
|
|
|
| void RendererGpuVideoDecoderFactories::AsyncDeleteTexture(uint32 texture_id) {
|
| DCHECK_EQ(MessageLoop::current(), message_loop_);
|
| - if (!context_)
|
| + if (!wgc3dcbi_->makeContextCurrent())
|
| return;
|
| - gpu::gles2::GLES2Implementation* gles2 = context_->GetImplementation();
|
| + gpu::gles2::GLES2Implementation* gles2 =
|
| + wgc3dcbi_->context()->GetImplementation();
|
| gles2->DeleteTextures(1, &texture_id);
|
| DCHECK_EQ(gles2->GetError(), static_cast<GLenum>(GL_NO_ERROR));
|
| }
|
|
|
| base::SharedMemory* RendererGpuVideoDecoderFactories::CreateSharedMemory(
|
| size_t size) {
|
| + DCHECK_NE(MessageLoop::current(), ChildThread::current()->message_loop());
|
| base::SharedMemory* shm = NULL;
|
| base::WaitableEvent waiter(false, false);
|
| - message_loop_->PostTask(FROM_HERE, base::Bind(
|
| + ChildThread::current()->message_loop()->PostTask(FROM_HERE, base::Bind(
|
| &RendererGpuVideoDecoderFactories::AsyncCreateSharedMemory, this,
|
| size, &shm, &waiter));
|
| waiter.Wait();
|
| @@ -119,6 +129,7 @@ base::SharedMemory* RendererGpuVideoDecoderFactories::CreateSharedMemory(
|
|
|
| void RendererGpuVideoDecoderFactories::AsyncCreateSharedMemory(
|
| size_t size, base::SharedMemory** shm, base::WaitableEvent* waiter) {
|
| + DCHECK_EQ(MessageLoop::current(), ChildThread::current()->message_loop());
|
| *shm = ChildThread::current()->AllocateSharedMemory(size);
|
| waiter->Signal();
|
| }
|
|
|