| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "gpu/command_buffer/service/context_group.h" | 5 #include "gpu/command_buffer/service/context_group.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 feature_info_(new FeatureInfo()) { | 40 feature_info_(new FeatureInfo()) { |
| 41 id_namespaces_[id_namespaces::kBuffers].reset(new IdAllocator); | 41 id_namespaces_[id_namespaces::kBuffers].reset(new IdAllocator); |
| 42 id_namespaces_[id_namespaces::kFramebuffers].reset(new IdAllocator); | 42 id_namespaces_[id_namespaces::kFramebuffers].reset(new IdAllocator); |
| 43 id_namespaces_[id_namespaces::kProgramsAndShaders].reset( | 43 id_namespaces_[id_namespaces::kProgramsAndShaders].reset( |
| 44 new NonReusedIdAllocator); | 44 new NonReusedIdAllocator); |
| 45 id_namespaces_[id_namespaces::kRenderbuffers].reset(new IdAllocator); | 45 id_namespaces_[id_namespaces::kRenderbuffers].reset(new IdAllocator); |
| 46 id_namespaces_[id_namespaces::kTextures].reset(new IdAllocator); | 46 id_namespaces_[id_namespaces::kTextures].reset(new IdAllocator); |
| 47 id_namespaces_[id_namespaces::kQueries].reset(new IdAllocator); | 47 id_namespaces_[id_namespaces::kQueries].reset(new IdAllocator); |
| 48 } | 48 } |
| 49 | 49 |
| 50 ContextGroup::~ContextGroup() { | |
| 51 CHECK(num_contexts_ == 0); | |
| 52 } | |
| 53 | |
| 54 static void GetIntegerv(GLenum pname, uint32* var) { | 50 static void GetIntegerv(GLenum pname, uint32* var) { |
| 55 GLint value = 0; | 51 GLint value = 0; |
| 56 glGetIntegerv(pname, &value); | 52 glGetIntegerv(pname, &value); |
| 57 *var = value; | 53 *var = value; |
| 58 } | 54 } |
| 59 | 55 |
| 60 bool ContextGroup::CheckGLFeature(GLint min_required, GLint* v) { | |
| 61 GLint value = *v; | |
| 62 if (enforce_gl_minimums_) { | |
| 63 value = std::min(min_required, value); | |
| 64 } | |
| 65 *v = value; | |
| 66 return value >= min_required; | |
| 67 } | |
| 68 | |
| 69 bool ContextGroup::CheckGLFeatureU(GLint min_required, uint32* v) { | |
| 70 GLint value = *v; | |
| 71 if (enforce_gl_minimums_) { | |
| 72 value = std::min(min_required, value); | |
| 73 } | |
| 74 *v = value; | |
| 75 return value >= min_required; | |
| 76 } | |
| 77 | |
| 78 bool ContextGroup::QueryGLFeature( | |
| 79 GLenum pname, GLint min_required, GLint* v) { | |
| 80 GLint value = 0; | |
| 81 glGetIntegerv(pname, &value); | |
| 82 *v = value; | |
| 83 return CheckGLFeature(min_required, v); | |
| 84 } | |
| 85 | |
| 86 bool ContextGroup::QueryGLFeatureU( | |
| 87 GLenum pname, GLint min_required, uint32* v) { | |
| 88 uint32 value = 0; | |
| 89 GetIntegerv(pname, &value); | |
| 90 bool result = CheckGLFeatureU(min_required, &value); | |
| 91 *v = value; | |
| 92 return result; | |
| 93 } | |
| 94 | |
| 95 bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features, | 56 bool ContextGroup::Initialize(const DisallowedFeatures& disallowed_features, |
| 96 const char* allowed_features) { | 57 const char* allowed_features) { |
| 97 if (num_contexts_ > 0) { | 58 if (num_contexts_ > 0) { |
| 98 ++num_contexts_; | 59 ++num_contexts_; |
| 99 return true; | 60 return true; |
| 100 } | 61 } |
| 101 | 62 |
| 102 if (!feature_info_->Initialize(disallowed_features, allowed_features)) { | 63 if (!feature_info_->Initialize(disallowed_features, allowed_features)) { |
| 103 LOG(ERROR) << "ContextGroup::Initialize failed because FeatureInfo " | 64 LOG(ERROR) << "ContextGroup::Initialize failed because FeatureInfo " |
| 104 << "initialization failed."; | 65 << "initialization failed."; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 } | 224 } |
| 264 } | 225 } |
| 265 | 226 |
| 266 IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) { | 227 IdAllocatorInterface* ContextGroup::GetIdAllocator(unsigned namespace_id) { |
| 267 if (namespace_id >= arraysize(id_namespaces_)) | 228 if (namespace_id >= arraysize(id_namespaces_)) |
| 268 return NULL; | 229 return NULL; |
| 269 | 230 |
| 270 return id_namespaces_[namespace_id].get(); | 231 return id_namespaces_[namespace_id].get(); |
| 271 } | 232 } |
| 272 | 233 |
| 234 ContextGroup::~ContextGroup() { |
| 235 CHECK(num_contexts_ == 0); |
| 236 } |
| 237 |
| 238 bool ContextGroup::CheckGLFeature(GLint min_required, GLint* v) { |
| 239 GLint value = *v; |
| 240 if (enforce_gl_minimums_) { |
| 241 value = std::min(min_required, value); |
| 242 } |
| 243 *v = value; |
| 244 return value >= min_required; |
| 245 } |
| 246 |
| 247 bool ContextGroup::CheckGLFeatureU(GLint min_required, uint32* v) { |
| 248 GLint value = *v; |
| 249 if (enforce_gl_minimums_) { |
| 250 value = std::min(min_required, value); |
| 251 } |
| 252 *v = value; |
| 253 return value >= min_required; |
| 254 } |
| 255 |
| 256 bool ContextGroup::QueryGLFeature( |
| 257 GLenum pname, GLint min_required, GLint* v) { |
| 258 GLint value = 0; |
| 259 glGetIntegerv(pname, &value); |
| 260 *v = value; |
| 261 return CheckGLFeature(min_required, v); |
| 262 } |
| 263 |
| 264 bool ContextGroup::QueryGLFeatureU( |
| 265 GLenum pname, GLint min_required, uint32* v) { |
| 266 uint32 value = 0; |
| 267 GetIntegerv(pname, &value); |
| 268 bool result = CheckGLFeatureU(min_required, &value); |
| 269 *v = value; |
| 270 return result; |
| 271 } |
| 272 |
| 273 } // namespace gles2 | 273 } // namespace gles2 |
| 274 } // namespace gpu | 274 } // namespace gpu |
| 275 | 275 |
| 276 | 276 |
| OLD | NEW |