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

Unified Diff: content/common/child_process_host_impl.cc

Issue 634083002: gpu: Compositor management of GpuMemoryBuffer instances. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@cc-pre-chromium-image-refactor
Patch Set: rebase Created 6 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/common/child_process_host_impl.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/common/child_process_host_impl.cc
diff --git a/content/common/child_process_host_impl.cc b/content/common/child_process_host_impl.cc
index c4d209e08773d5b103922d3809f43556e85210dc..a1fa5fc8b0bc557ab21f6b611b1c0c38668abb6c 100644
--- a/content/common/child_process_host_impl.cc
+++ b/content/common/child_process_host_impl.cc
@@ -11,13 +11,14 @@
#include "base/files/file_path.h"
#include "base/logging.h"
#include "base/metrics/histogram.h"
+#include "base/numerics/safe_math.h"
#include "base/path_service.h"
#include "base/process/process_metrics.h"
#include "base/rand_util.h"
#include "base/strings/stringprintf.h"
#include "base/third_party/dynamic_annotations/dynamic_annotations.h"
#include "content/common/child_process_messages.h"
-#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
+#include "content/common/gpu/client/gpu_memory_buffer_impl_shared_memory.h"
#include "content/public/common/child_process_host_delegate.h"
#include "content/public/common/content_paths.h"
#include "content/public/common/content_switches.h"
@@ -253,8 +254,11 @@ bool ChildProcessHostImpl::OnMessageReceived(const IPC::Message& msg) {
OnShutdownRequest)
IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateSharedMemory,
OnAllocateSharedMemory)
- IPC_MESSAGE_HANDLER(ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
- OnAllocateGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER_DELAY_REPLY(
+ ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer,
+ OnAllocateGpuMemoryBuffer)
+ IPC_MESSAGE_HANDLER(ChildProcessHostMsg_DeletedGpuMemoryBuffer,
+ OnDeletedGpuMemoryBuffer)
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
@@ -310,14 +314,47 @@ void ChildProcessHostImpl::OnShutdownRequest() {
void ChildProcessHostImpl::OnAllocateGpuMemoryBuffer(
uint32 width,
uint32 height,
- uint32 internalformat,
- uint32 usage,
- gfx::GpuMemoryBufferHandle* handle) {
- handle->type = gfx::SHARED_MEMORY_BUFFER;
- AllocateSharedMemory(
- width * height * GpuMemoryBufferImpl::BytesPerPixel(internalformat),
+ gfx::GpuMemoryBuffer::Format format,
+ gfx::GpuMemoryBuffer::Usage usage,
+ IPC::Message* reply) {
+ base::CheckedNumeric<int> size = width;
+ size *= height;
+ if (!size.IsValid()) {
+ GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle());
+ return;
+ }
+
+ // TODO(reveman): Add support for other types of GpuMemoryBuffers.
+ if (!GpuMemoryBufferImplSharedMemory::IsConfigurationSupported(
+ gfx::Size(width, height), format, usage)) {
+ GpuMemoryBufferAllocated(reply, gfx::GpuMemoryBufferHandle());
+ return;
+ }
+
+ // Note: It is safe to use base::Unretained here as the shared memory
+ // implementation of AllocateForChildProcess() calls this synchronously.
+ GpuMemoryBufferImplSharedMemory::AllocateForChildProcess(
+ gfx::Size(width, height),
+ format,
peer_handle_,
- &handle->handle);
+ base::Bind(&ChildProcessHostImpl::GpuMemoryBufferAllocated,
+ base::Unretained(this),
+ reply));
+}
+
+void ChildProcessHostImpl::OnDeletedGpuMemoryBuffer(
+ gfx::GpuMemoryBufferType type,
+ const gfx::GpuMemoryBufferId& id) {
+ // Note: Nothing to do here as ownership of shared memory backed
+ // GpuMemoryBuffers is passed with IPC.
+}
+
+void ChildProcessHostImpl::GpuMemoryBufferAllocated(
+ IPC::Message* reply,
+ const gfx::GpuMemoryBufferHandle& handle) {
+ ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer::WriteReplyParams(reply,
+ handle);
+ Send(reply);
}
} // namespace content
« no previous file with comments | « content/common/child_process_host_impl.h ('k') | content/common/child_process_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698