| 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 <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/lazy_instance.h" | 8 #include "base/lazy_instance.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/threading/thread_local.h" | 10 #include "base/threading/thread_local.h" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 return std::string(ext ? ext : ""); | 59 return std::string(ext ? ext : ""); |
| 60 } | 60 } |
| 61 | 61 |
| 62 std::string GLContext::GetGLVersion() { | 62 std::string GLContext::GetGLVersion() { |
| 63 DCHECK(IsCurrent(NULL)); | 63 DCHECK(IsCurrent(NULL)); |
| 64 const char *version = | 64 const char *version = |
| 65 reinterpret_cast<const char*>(glGetString(GL_VERSION)); | 65 reinterpret_cast<const char*>(glGetString(GL_VERSION)); |
| 66 return std::string(version ? version : ""); | 66 return std::string(version ? version : ""); |
| 67 } | 67 } |
| 68 | 68 |
| 69 std::string GLContext::GetGLRenderer() { |
| 70 DCHECK(IsCurrent(NULL)); |
| 71 const char *renderer = |
| 72 reinterpret_cast<const char*>(glGetString(GL_RENDERER)); |
| 73 return std::string(renderer ? renderer : ""); |
| 74 } |
| 75 |
| 69 bool GLContext::HasExtension(const char* name) { | 76 bool GLContext::HasExtension(const char* name) { |
| 70 std::string extensions = GetExtensions(); | 77 std::string extensions = GetExtensions(); |
| 71 extensions += " "; | 78 extensions += " "; |
| 72 | 79 |
| 73 std::string delimited_name(name); | 80 std::string delimited_name(name); |
| 74 delimited_name += " "; | 81 delimited_name += " "; |
| 75 | 82 |
| 76 return extensions.find(delimited_name) != std::string::npos; | 83 return extensions.find(delimited_name) != std::string::npos; |
| 77 } | 84 } |
| 78 | 85 |
| 79 const GLVersionInfo* GLContext::GetVersionInfo() { | 86 const GLVersionInfo* GLContext::GetVersionInfo() { |
| 80 if(!version_info_) { | 87 if(!version_info_) { |
| 81 std::string version = GetGLVersion(); | 88 std::string version = GetGLVersion(); |
| 89 std::string renderer = GetGLRenderer(); |
| 82 version_info_ = scoped_ptr<GLVersionInfo>( | 90 version_info_ = scoped_ptr<GLVersionInfo>( |
| 83 new GLVersionInfo(version.c_str())); | 91 new GLVersionInfo(version.c_str(), renderer.c_str())); |
| 84 } | 92 } |
| 85 return version_info_.get(); | 93 return version_info_.get(); |
| 86 } | 94 } |
| 87 | 95 |
| 88 GLShareGroup* GLContext::share_group() { | 96 GLShareGroup* GLContext::share_group() { |
| 89 return share_group_.get(); | 97 return share_group_.get(); |
| 90 } | 98 } |
| 91 | 99 |
| 92 bool GLContext::LosesAllContextsOnContextLost() { | 100 bool GLContext::LosesAllContextsOnContextLost() { |
| 93 switch (GetGLImplementation()) { | 101 switch (GetGLImplementation()) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 : GLContext(share_group) {} | 176 : GLContext(share_group) {} |
| 169 | 177 |
| 170 GLContextReal::~GLContextReal() {} | 178 GLContextReal::~GLContextReal() {} |
| 171 | 179 |
| 172 void GLContextReal::SetCurrent(GLSurface* surface) { | 180 void GLContextReal::SetCurrent(GLSurface* surface) { |
| 173 GLContext::SetCurrent(surface); | 181 GLContext::SetCurrent(surface); |
| 174 current_real_context_.Pointer()->Set(surface ? this : NULL); | 182 current_real_context_.Pointer()->Set(surface ? this : NULL); |
| 175 } | 183 } |
| 176 | 184 |
| 177 } // namespace gfx | 185 } // namespace gfx |
| OLD | NEW |