Index: content/browser/gpu/browser_gpu_channel_host_factory.cc |
diff --git a/content/browser/gpu/browser_gpu_channel_host_factory.cc b/content/browser/gpu/browser_gpu_channel_host_factory.cc |
index 0c43205d3d80b81a60230fba718914d1348b886f..60b358f4d15af60d1a0df6bc22eb339c41c833a5 100644 |
--- a/content/browser/gpu/browser_gpu_channel_host_factory.cc |
+++ b/content/browser/gpu/browser_gpu_channel_host_factory.cc |
@@ -469,4 +469,89 @@ void BrowserGpuChannelHostFactory::SetHandlerForControlMessages( |
filter)); |
} |
+void BrowserGpuChannelHostFactory::CreateGpuMemoryBuffer( |
+ size_t width, |
+ size_t height, |
+ unsigned internalformat, |
+ unsigned usage, |
+ const gfx::GpuMemoryBufferHandle& handle, |
+ const CreateGpuMemoryBufferCallback& callback) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ GetIOLoopProxy()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&BrowserGpuChannelHostFactory::CreateGpuMemoryBufferOnIO, |
+ base::Unretained(this), |
+ width, |
+ height, |
+ internalformat, |
+ usage, |
+ handle, |
+ callback)); |
+} |
+ |
+void BrowserGpuChannelHostFactory::DeleteGpuMemoryBuffer( |
+ const gfx::GpuMemoryBufferHandle& handle, |
+ int32 sync_point) { |
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
+ GetIOLoopProxy()->PostTask( |
+ FROM_HERE, |
+ base::Bind(&BrowserGpuChannelHostFactory::DeleteGpuMemoryBufferOnIO, |
+ base::Unretained(this), |
+ handle, |
+ sync_point)); |
+} |
+ |
+void BrowserGpuChannelHostFactory::CreateGpuMemoryBufferOnIO( |
+ size_t width, |
+ size_t height, |
+ unsigned internalformat, |
+ unsigned usage, |
+ const gfx::GpuMemoryBufferHandle& handle, |
+ const CreateGpuMemoryBufferCallback& callback) { |
+ GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
+ if (!host) { |
+ GpuMemoryBufferCreatedOnIO(callback, gfx::GpuMemoryBufferHandle()); |
+ return; |
+ } |
+ |
+ host->CreateGpuMemoryBuffer( |
+ width, |
+ height, |
+ internalformat, |
+ usage, |
+ handle, |
+ base::Bind(&BrowserGpuChannelHostFactory::GpuMemoryBufferCreatedOnIO, |
+ callback)); |
+} |
+ |
+// static |
+void BrowserGpuChannelHostFactory::GpuMemoryBufferCreatedOnIO( |
+ const CreateGpuMemoryBufferCallback& callback, |
+ const gfx::GpuMemoryBufferHandle& handle) { |
+ BrowserThread::PostTask( |
+ BrowserThread::UI, |
+ FROM_HERE, |
+ base::Bind(&BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated, |
+ callback, |
+ handle)); |
+} |
+ |
+// static |
+void BrowserGpuChannelHostFactory::OnGpuMemoryBufferCreated( |
+ const CreateGpuMemoryBufferCallback& callback, |
+ const gfx::GpuMemoryBufferHandle& handle) { |
+ callback.Run(handle); |
+} |
+ |
+void BrowserGpuChannelHostFactory::DeleteGpuMemoryBufferOnIO( |
+ const gfx::GpuMemoryBufferHandle& handle, |
+ int32 sync_point) { |
+ GpuProcessHost* host = GpuProcessHost::FromID(gpu_host_id_); |
+ if (!host) { |
+ return; |
+ } |
+ |
+ host->DeleteGpuMemoryBuffer(handle, sync_point); |
+} |
+ |
} // namespace content |