OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "gpu/command_buffer/service/path_manager.h" |
| 6 #include "base/logging.h" |
| 7 #include "base/strings/stringprintf.h" |
| 8 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 9 #include "ui/gl/gl_bindings.h" |
| 10 |
| 11 namespace gpu { |
| 12 namespace gles2 { |
| 13 |
| 14 PathManager::PathManager() : have_context_(true) { |
| 15 } |
| 16 |
| 17 PathManager::~PathManager() { |
| 18 DCHECK(path_map_.empty()); |
| 19 } |
| 20 |
| 21 void PathManager::Destroy(bool have_context) { |
| 22 have_context_ = have_context; |
| 23 if (have_context_) { |
| 24 for (PathMap::iterator it = path_map_.begin(); it != path_map_.end(); |
| 25 ++it) { |
| 26 glDeletePathsNV(it->second, 1); |
| 27 } |
| 28 } |
| 29 path_map_.clear(); |
| 30 } |
| 31 |
| 32 void PathManager::CreatePath(GLuint client_id, GLuint service_id) { |
| 33 path_map_.insert(std::make_pair(client_id, service_id)); |
| 34 } |
| 35 |
| 36 bool PathManager::GetPath(GLuint client_id, GLuint* service_id) { |
| 37 PathMap::iterator it = path_map_.find(client_id); |
| 38 if (it == path_map_.end()) |
| 39 return false; |
| 40 |
| 41 if (service_id) |
| 42 *service_id = it->second; |
| 43 return true; |
| 44 } |
| 45 |
| 46 void PathManager::RemovePaths(GLuint path, GLuint range) { |
| 47 for (GLuint ii = path; ii < path + range; ++ii) { |
| 48 PathMap::iterator it = path_map_.find(ii); |
| 49 if (it == path_map_.end()) |
| 50 continue; |
| 51 glDeletePathsNV(it->second, 1); |
| 52 path_map_.erase(it); |
| 53 } |
| 54 } |
| 55 |
| 56 } // namespace gles2 |
| 57 } // namespace gpu |
OLD | NEW |