Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(515)

Unified Diff: content/renderer/render_thread_impl.cc

Issue 19762004: Add multi-process GpuMemoryBuffer framework. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/render_thread_impl.cc
diff --git a/content/renderer/render_thread_impl.cc b/content/renderer/render_thread_impl.cc
index 4f719e393a5ed53f7afca5c9b2dd57c1d4c53628..aa5b56543f8c061e4a315f02247eb85f1b25f8fa 100644
--- a/content/renderer/render_thread_impl.cc
+++ b/content/renderer/render_thread_impl.cc
@@ -44,6 +44,7 @@
#include "content/common/dom_storage/dom_storage_messages.h"
#include "content/common/gpu/client/context_provider_command_buffer.h"
#include "content/common/gpu/client/gpu_channel_host.h"
+#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/resource_messages.h"
#include "content/common/view_messages.h"
@@ -1052,6 +1053,47 @@ void RenderThreadImpl::DeleteImage(int32 image_id, int32 sync_point) {
NOTREACHED();
}
+scoped_ptr<gfx::GpuMemoryBuffer> RenderThreadImpl::AllocateGpuMemoryBuffer(
+ size_t width,
+ size_t height,
+ unsigned internalformat) {
+ if (!GpuMemoryBufferImpl::IsFormatValid(internalformat))
+ return scoped_ptr<gfx::GpuMemoryBuffer>();
+
+ size_t size = width * height *
+ GpuMemoryBufferImpl::BytesPerPixel(internalformat);
+ if (size > static_cast<size_t>(std::numeric_limits<int>::max()))
+ return scoped_ptr<gfx::GpuMemoryBuffer>();
+
+ gfx::GpuMemoryBufferHandle handle;
+ bool success;
+ IPC::Message* message =
+ new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(size, &handle);
+
+ // Allow calling this from the compositor thread.
+ if (base::MessageLoop::current() == message_loop())
+ success = ChildThread::Send(message);
+ else
+ success = sync_message_filter()->Send(message);
+
+ 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));
+}
+
void RenderThreadImpl::DoNotSuspendWebKitSharedTimer() {
suspend_webkit_shared_timer_ = false;
}
« no previous file with comments | « content/renderer/render_thread_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698