summaryrefslogtreecommitdiffstats
path: root/content/common/gpu/client/command_buffer_proxy_impl.cc
diff options
context:
space:
mode:
authorreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-22 23:13:09 +0000
committerreveman@chromium.org <reveman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-22 23:13:09 +0000
commitbc10f46abc6b4d6338fd1819b0360bc9115846f2 (patch)
tree34595adeaffa513af37b0caa4e9afd05cfcf65d0 /content/common/gpu/client/command_buffer_proxy_impl.cc
parent9f67dd0edac097ff862e9f92e988da2f5cb19348 (diff)
downloadchromium_src-bc10f46abc6b4d6338fd1819b0360bc9115846f2.zip
chromium_src-bc10f46abc6b4d6338fd1819b0360bc9115846f2.tar.gz
chromium_src-bc10f46abc6b4d6338fd1819b0360bc9115846f2.tar.bz2
Add multi-process GpuMemoryBuffer framework.
This adds a multi-process framework for reading/writing directly to memory that the 3D graphics hardware can use for rendering without any costly copying having to be done on the GPU process side. A GpuMemoryBuffer is a type of shared memory that can be accessed by the GPU. The high level procedure required to allocate this type of memory is almost exactly the same as that for standard shared memory. Only the browser process can allocated the memory and it needs to be shared and registered with the GPU process before it can be used. This also adds a GpuMemoryBuffer type that is backed by standard shared memory for testing purposes. TEST=gpu_unittests --gtest_filter=MockGpuMemoryBufferTest.Lifecycle BUG=261649 Review URL: https://codereview.chromium.org/19762004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@230248 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/common/gpu/client/command_buffer_proxy_impl.cc')
-rw-r--r--content/common/gpu/client/command_buffer_proxy_impl.cc54
1 files changed, 50 insertions, 4 deletions
diff --git a/content/common/gpu/client/command_buffer_proxy_impl.cc b/content/common/gpu/client/command_buffer_proxy_impl.cc
index 94abbe1..3fbe537 100644
--- a/content/common/gpu/client/command_buffer_proxy_impl.cc
+++ b/content/common/gpu/client/command_buffer_proxy_impl.cc
@@ -367,7 +367,7 @@ void CommandBufferProxyImpl::SetContextLostReason(
}
bool CommandBufferProxyImpl::SupportsGpuMemoryBuffer() {
- return false;
+ return true;
}
gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer(
@@ -375,12 +375,58 @@ gfx::GpuMemoryBuffer* CommandBufferProxyImpl::CreateGpuMemoryBuffer(
size_t height,
unsigned internalformat,
int32* id) {
- NOTREACHED();
- return NULL;
+ *id = -1;
+
+ if (last_state_.error != gpu::error::kNoError)
+ return NULL;
+
+ int32 new_id = channel_->ReserveGpuMemoryBufferId();
+ DCHECK(gpu_memory_buffers_.find(new_id) == gpu_memory_buffers_.end());
+
+ scoped_ptr<gfx::GpuMemoryBuffer> gpu_memory_buffer(
+ channel_->factory()->AllocateGpuMemoryBuffer(width,
+ height,
+ internalformat));
+ if (!gpu_memory_buffer)
+ return NULL;
+
+ DCHECK(GpuChannelHost::IsValidGpuMemoryBuffer(
+ gpu_memory_buffer->GetHandle()));
+
+ // This handle is owned by the GPU process and must be passed to it or it
+ // will leak. In otherwords, do not early out on error between here and the
+ // sending of the RegisterGpuMemoryBuffer IPC below.
+ gfx::GpuMemoryBufferHandle handle =
+ channel_->ShareGpuMemoryBufferToGpuProcess(
+ gpu_memory_buffer->GetHandle());
+
+ if (!Send(new GpuCommandBufferMsg_RegisterGpuMemoryBuffer(
+ route_id_,
+ new_id,
+ handle,
+ width,
+ height,
+ internalformat))) {
+ return NULL;
+ }
+
+ *id = new_id;
+ gpu_memory_buffers_[new_id] = gpu_memory_buffer.release();
+ return gpu_memory_buffers_[new_id];
}
void CommandBufferProxyImpl::DestroyGpuMemoryBuffer(int32 id) {
- NOTREACHED();
+ if (last_state_.error != gpu::error::kNoError)
+ return;
+
+ // Remove the gpu memory buffer from the client side cache.
+ GpuMemoryBufferMap::iterator it = gpu_memory_buffers_.find(id);
+ if (it != gpu_memory_buffers_.end()) {
+ delete it->second;
+ gpu_memory_buffers_.erase(it);
+ }
+
+ Send(new GpuCommandBufferMsg_DestroyGpuMemoryBuffer(route_id_, id));
}
int CommandBufferProxyImpl::GetRouteID() const {