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

Unified Diff: gpu/command_buffer/service/gpu_control_service.cc

Issue 20017005: gpu: Refactor GpuMemoryBuffer framework for multi-process support. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 4 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
Index: gpu/command_buffer/service/gpu_control_service.cc
diff --git a/gpu/command_buffer/service/gpu_control_service.cc b/gpu/command_buffer/service/gpu_control_service.cc
new file mode 100644
index 0000000000000000000000000000000000000000..974dd36ef911737ee33ed7c3cfd54f87affbe19f
--- /dev/null
+++ b/gpu/command_buffer/service/gpu_control_service.cc
@@ -0,0 +1,74 @@
+// Copyright (c) 2013 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 "gpu/command_buffer/service/gpu_control_service.h"
+
+#include "gpu/command_buffer/client/gpu_memory_buffer_factory.h"
+#include "gpu/command_buffer/service/gpu_memory_buffer_manager.h"
+
+namespace gpu {
+
+GpuControlService::GpuControlService(
+ GpuMemoryBufferManagerInterface* gpu_memory_buffer_manager,
+ GpuMemoryBufferFactory* gpu_memory_buffer_factory)
+ : gpu_memory_buffer_manager_(gpu_memory_buffer_manager),
+ gpu_memory_buffer_factory_(gpu_memory_buffer_factory) {
+}
+
+GpuControlService::~GpuControlService() {
+}
+
+gfx::GpuMemoryBuffer* GpuControlService::CreateGpuMemoryBuffer(
+ size_t width,
+ size_t height,
+ unsigned internalformat,
+ int32* id) {
+ *id = -1;
+
+ CHECK(gpu_memory_buffer_factory_) << "No GPU memory buffer factory provided";
+ linked_ptr<gfx::GpuMemoryBuffer> buffer = make_linked_ptr(
+ gpu_memory_buffer_factory_->CreateGpuMemoryBuffer(width,
+ height,
+ internalformat));
+ if (!buffer.get())
+ return NULL;
+
+ static int32 next_id = 1;
+ *id = next_id++;
+
+ if (!RegisterGpuMemoryBuffer(*id,
+ buffer->GetHandle(),
+ width,
+ height,
+ internalformat)) {
+ *id = -1;
+ return NULL;
+ }
+
+ gpu_memory_buffers_[*id] = buffer;
+ return buffer.get();
+}
+
+void GpuControlService::DestroyGpuMemoryBuffer(int32 id) {
+ GpuMemoryBufferMap::iterator it = gpu_memory_buffers_.find(id);
+ if (it != gpu_memory_buffers_.end())
+ gpu_memory_buffers_.erase(it);
+
+ gpu_memory_buffer_manager_->DestroyGpuMemoryBuffer(id);
+}
+
+bool GpuControlService::RegisterGpuMemoryBuffer(
+ int32 id,
+ gfx::GpuMemoryBufferHandle buffer,
+ size_t width,
+ size_t height,
+ unsigned internalformat) {
+ return gpu_memory_buffer_manager_->RegisterGpuMemoryBuffer(id,
+ buffer,
+ width,
+ height,
+ internalformat);
+}
+
+} // namespace gpu
« no previous file with comments | « gpu/command_buffer/service/gpu_control_service.h ('k') | gpu/command_buffer/service/gpu_memory_buffer_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698