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

Unified Diff: content/child/child_gpu_memory_buffer_manager.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/child/child_gpu_memory_buffer_manager.h ('k') | content/child/child_thread.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/child/child_gpu_memory_buffer_manager.cc
diff --git a/content/child/child_gpu_memory_buffer_manager.cc b/content/child/child_gpu_memory_buffer_manager.cc
new file mode 100644
index 0000000000000000000000000000000000000000..23065aed0a32eba0ea8a30a88f03972c6388fa56
--- /dev/null
+++ b/content/child/child_gpu_memory_buffer_manager.cc
@@ -0,0 +1,72 @@
+// Copyright 2014 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/child/child_gpu_memory_buffer_manager.h"
+
+#include "content/child/child_thread.h"
+#include "content/common/child_process_messages.h"
+#include "content/common/gpu/client/gpu_memory_buffer_impl.h"
+
+namespace content {
+namespace {
+
+void DeletedGpuMemoryBuffer(ThreadSafeSender* sender,
+ gfx::GpuMemoryBufferType type,
+ const gfx::GpuMemoryBufferId& id) {
+ TRACE_EVENT0("renderer",
+ "ChildGpuMemoryBufferManager::DeletedGpuMemoryBuffer");
+ sender->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(type, id));
+}
+
+} // namespace
+
+ChildGpuMemoryBufferManager::ChildGpuMemoryBufferManager(
+ ThreadSafeSender* sender)
+ : sender_(sender) {
+}
+
+ChildGpuMemoryBufferManager::~ChildGpuMemoryBufferManager() {
+}
+
+scoped_ptr<gfx::GpuMemoryBuffer>
+ChildGpuMemoryBufferManager::AllocateGpuMemoryBuffer(
+ const gfx::Size& size,
+ gfx::GpuMemoryBuffer::Format format,
+ gfx::GpuMemoryBuffer::Usage usage) {
+ TRACE_EVENT2("renderer",
+ "ChildGpuMemoryBufferManager::AllocateGpuMemoryBuffer",
+ "width",
+ size.width(),
+ "height",
+ size.height());
+
+ gfx::GpuMemoryBufferHandle handle;
+ IPC::Message* message = new ChildProcessHostMsg_SyncAllocateGpuMemoryBuffer(
+ size.width(), size.height(), format, usage, &handle);
+ bool success = sender_->Send(message);
+ if (!success)
+ return scoped_ptr<gfx::GpuMemoryBuffer>();
+
+ scoped_ptr<GpuMemoryBufferImpl> buffer(GpuMemoryBufferImpl::CreateFromHandle(
+ handle,
+ size,
+ format,
+ base::Bind(
+ &DeletedGpuMemoryBuffer, sender_, handle.type, handle.global_id)));
+ if (!buffer) {
+ sender_->Send(new ChildProcessHostMsg_DeletedGpuMemoryBuffer(
+ handle.type, handle.global_id));
+ return scoped_ptr<gfx::GpuMemoryBuffer>();
+ }
+
+ return buffer.PassAs<gfx::GpuMemoryBuffer>();
+}
+
+gfx::GpuMemoryBuffer*
+ChildGpuMemoryBufferManager::GpuMemoryBufferFromClientBuffer(
+ ClientBuffer buffer) {
+ return GpuMemoryBufferImpl::FromClientBuffer(buffer);
+}
+
+} // namespace content
« no previous file with comments | « content/child/child_gpu_memory_buffer_manager.h ('k') | content/child/child_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698