1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/child/child_gpu_memory_buffer_manager.h"
7 #include "content/common/child_process_messages.h"
8 #include "content/common/gpu/client/gpu_memory_buffer_impl.h"
13 void DeletedGpuMemoryBuffer(ThreadSafeSender
* sender
,
14 gfx::GpuMemoryBufferId id
,
16 TRACE_EVENT0("renderer",
17 "ChildGpuMemoryBufferManager::DeletedGpuMemoryBuffer");
18 sender
->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(id
, sync_point
));
23 ChildGpuMemoryBufferManager::ChildGpuMemoryBufferManager(
24 ThreadSafeSender
* sender
)
28 ChildGpuMemoryBufferManager::~ChildGpuMemoryBufferManager() {
31 scoped_ptr
<gfx::GpuMemoryBuffer
>
32 ChildGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
33 const gfx::Size
& size
,
34 gfx::GpuMemoryBuffer::Format format
,
35 gfx::GpuMemoryBuffer::Usage usage
) {
36 TRACE_EVENT2("renderer",
37 "ChildGpuMemoryBufferManager::AllocateGpuMemoryBuffer",
43 gfx::GpuMemoryBufferHandle handle
;
44 IPC::Message
* message
= new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(
45 size
.width(), size
.height(), format
, usage
, &handle
);
46 bool success
= sender_
->Send(message
);
48 return scoped_ptr
<gfx::GpuMemoryBuffer
>();
50 scoped_ptr
<GpuMemoryBufferImpl
> buffer(GpuMemoryBufferImpl::CreateFromHandle(
54 base::Bind(&DeletedGpuMemoryBuffer
, sender_
, handle
.id
)));
56 sender_
->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(handle
.id
, 0));
57 return scoped_ptr
<gfx::GpuMemoryBuffer
>();
64 ChildGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer(
65 ClientBuffer buffer
) {
66 return GpuMemoryBufferImpl::FromClientBuffer(buffer
);
69 void ChildGpuMemoryBufferManager::SetDestructionSyncPoint(
70 gfx::GpuMemoryBuffer
* buffer
,
72 static_cast<GpuMemoryBufferImpl
*>(buffer
)
73 ->set_destruction_sync_point(sync_point
);
76 } // namespace content