Index: gpu/command_buffer/service/path_manager.cc |
diff --git a/gpu/command_buffer/service/path_manager.cc b/gpu/command_buffer/service/path_manager.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d67de116676596c13740a1b29ac993f75d0ceaef |
--- /dev/null |
+++ b/gpu/command_buffer/service/path_manager.cc |
@@ -0,0 +1,57 @@ |
+// Copyright (c) 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 "gpu/command_buffer/service/path_manager.h" |
+#include "base/logging.h" |
+#include "base/strings/stringprintf.h" |
+#include "gpu/command_buffer/common/gles2_cmd_utils.h" |
+#include "ui/gl/gl_bindings.h" |
+ |
+namespace gpu { |
+namespace gles2 { |
+ |
+PathManager::PathManager() : have_context_(true) { |
+} |
+ |
+PathManager::~PathManager() { |
+ DCHECK(path_map_.empty()); |
+} |
+ |
+void PathManager::Destroy(bool have_context) { |
+ have_context_ = have_context; |
+ if (have_context_) { |
+ for (PathMap::iterator it = path_map_.begin(); it != path_map_.end(); |
+ ++it) { |
+ glDeletePathsNV(it->second, 1); |
+ } |
+ } |
+ path_map_.clear(); |
+} |
+ |
+void PathManager::CreatePath(GLuint client_id, GLuint service_id) { |
+ path_map_.insert(std::make_pair(client_id, service_id)); |
+} |
+ |
+bool PathManager::GetPath(GLuint client_id, GLuint* service_id) { |
+ PathMap::iterator it = path_map_.find(client_id); |
+ if (it == path_map_.end()) |
+ return false; |
+ |
+ if (service_id) |
+ *service_id = it->second; |
+ return true; |
+} |
+ |
+void PathManager::RemovePaths(GLuint path, GLuint range) { |
+ for (GLuint ii = path; ii < path + range; ++ii) { |
+ PathMap::iterator it = path_map_.find(ii); |
+ if (it == path_map_.end()) |
+ continue; |
+ glDeletePathsNV(it->second, 1); |
+ path_map_.erase(it); |
+ } |
+} |
+ |
+} // namespace gles2 |
+} // namespace gpu |