| Index: content/renderer/render_thread_impl.cc
|
| diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
|
| index 3f7ec1ec1cf019eeab7807396ec2cbc37c36048b..65ecb40bf5e6b6c9979a3ef3da59937896ab2b27 100644
|
| --- a/content/renderer/render_thread_impl.cc
|
| +++ b/content/renderer/render_thread_impl.cc
|
| @@ -406,6 +406,10 @@ void RenderThreadImpl::Init() {
|
|
|
| renderer_process_id_ = base::kNullProcessId;
|
|
|
| + // AllocateGpuMemoryBuffer must be used exclusively on one thread but
|
| + // it doesn't have to be the same thread RenderThreadImpl is created on.
|
| + allocate_gpu_memory_buffer_thread_checker_.DetachFromThread();
|
| +
|
| TRACE_EVENT_END_ETW("RenderThreadImpl::Init", 0, "");
|
| }
|
|
|
| @@ -1070,18 +1074,18 @@ scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
|
| size_t width,
|
| size_t height,
|
| unsigned internalformat) {
|
| - if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
|
| - return scoped_ptr<gfx::GpuMemoryBuffer>();
|
| + DCHECK(allocate_gpu_memory_buffer_thread_checker_.CalledOnValidThread());
|
|
|
| - size_t size = width * height *
|
| - GpuMemoryBufferImpl::BytesPerPixel(internalformat);
|
| - if (size > static_cast<size_t>(std::numeric_limits<int>::max()))
|
| + if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
|
| return scoped_ptr<gfx::GpuMemoryBuffer>();
|
|
|
| gfx::GpuMemoryBufferHandle handle;
|
| bool success;
|
| IPC::Message* message =
|
| - new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(size, &handle);
|
| + new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(width,
|
| + height,
|
| + internalformat,
|
| + &handle);
|
|
|
| // Allow calling this from the compositor thread.
|
| if (base::MessageLoop::current() == message_loop())
|
| @@ -1092,19 +1096,10 @@ scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
|
| if (!success)
|
| return scoped_ptr<gfx::GpuMemoryBuffer>();
|
|
|
| - // Currently, shared memory is the only supported buffer type.
|
| - if (handle.type != gfx::SHARED_MEMORY_BUFFER)
|
| - return scoped_ptr<gfx::GpuMemoryBuffer>();
|
| -
|
| - if (!base::SharedMemory::IsHandleValid(handle.handle))
|
| - return scoped_ptr<gfx::GpuMemoryBuffer>();
|
| -
|
| - return make_scoped_ptr<gfx::GpuMemoryBuffer>(
|
| - new GpuMemoryBufferImpl(
|
| - make_scoped_ptr(new base::SharedMemory(handle.handle, false)),
|
| - width,
|
| - height,
|
| - internalformat));
|
| + return GpuMemoryBufferImpl::Create(
|
| + handle,
|
| + gfx::Size(width, height),
|
| + internalformat).PassAs<gfx::GpuMemoryBuffer>();
|
| }
|
|
|
| void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
|
|
|