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 "ui/gl/gl_context.h" | 5 #include "ui/gl/gl_context.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/cancelable_callback.h" | 10 #include "base/cancelable_callback.h" |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 return std::string(version ? version : ""); | 85 return std::string(version ? version : ""); |
86 } | 86 } |
87 | 87 |
88 std::string GLContext::GetGLRenderer() { | 88 std::string GLContext::GetGLRenderer() { |
89 DCHECK(IsCurrent(nullptr)); | 89 DCHECK(IsCurrent(nullptr)); |
90 const char *renderer = | 90 const char *renderer = |
91 reinterpret_cast<const char*>(glGetString(GL_RENDERER)); | 91 reinterpret_cast<const char*>(glGetString(GL_RENDERER)); |
92 return std::string(renderer ? renderer : ""); | 92 return std::string(renderer ? renderer : ""); |
93 } | 93 } |
94 | 94 |
95 gl::YUVToRGBConverter* GLContext::GetYUVToRGBConverter() { | 95 YUVToRGBConverter* GLContext::GetYUVToRGBConverter() { |
96 return nullptr; | 96 return nullptr; |
97 } | 97 } |
98 | 98 |
99 bool GLContext::HasExtension(const char* name) { | 99 bool GLContext::HasExtension(const char* name) { |
100 std::string extensions = GetExtensions(); | 100 std::string extensions = GetExtensions(); |
101 extensions += " "; | 101 extensions += " "; |
102 | 102 |
103 std::string delimited_name(name); | 103 std::string delimited_name(name); |
104 delimited_name += " "; | 104 delimited_name += " "; |
105 | 105 |
106 return extensions.find(delimited_name) != std::string::npos; | 106 return extensions.find(delimited_name) != std::string::npos; |
107 } | 107 } |
108 | 108 |
109 const GLVersionInfo* GLContext::GetVersionInfo() { | 109 const GLVersionInfo* GLContext::GetVersionInfo() { |
110 if(!version_info_) { | 110 if (!version_info_) { |
111 std::string version = GetGLVersion(); | 111 std::string version = GetGLVersion(); |
112 std::string renderer = GetGLRenderer(); | 112 std::string renderer = GetGLRenderer(); |
113 version_info_ = base::WrapUnique(new GLVersionInfo( | 113 version_info_ = base::WrapUnique(new GLVersionInfo( |
114 version.c_str(), renderer.c_str(), GetExtensions().c_str())); | 114 version.c_str(), renderer.c_str(), GetExtensions().c_str())); |
115 } | 115 } |
116 return version_info_.get(); | 116 return version_info_.get(); |
117 } | 117 } |
118 | 118 |
119 GLShareGroup* GLContext::share_group() { | 119 GLShareGroup* GLContext::share_group() { |
120 return share_group_.get(); | 120 return share_group_.get(); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); | 206 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); |
207 } | 207 } |
208 | 208 |
209 void GLContext::SetRealGLApi() { | 209 void GLContext::SetRealGLApi() { |
210 SetGLToRealGLApi(); | 210 SetGLToRealGLApi(); |
211 } | 211 } |
212 | 212 |
213 GLContextReal::GLContextReal(GLShareGroup* share_group) | 213 GLContextReal::GLContextReal(GLShareGroup* share_group) |
214 : GLContext(share_group) {} | 214 : GLContext(share_group) {} |
215 | 215 |
216 scoped_refptr<gl::GPUTimingClient> GLContextReal::CreateGPUTimingClient() { | 216 scoped_refptr<GPUTimingClient> GLContextReal::CreateGPUTimingClient() { |
217 if (!gpu_timing_) { | 217 if (!gpu_timing_) { |
218 gpu_timing_.reset(GPUTiming::CreateGPUTiming(this)); | 218 gpu_timing_.reset(GPUTiming::CreateGPUTiming(this)); |
219 } | 219 } |
220 return gpu_timing_->CreateGPUTimingClient(); | 220 return gpu_timing_->CreateGPUTimingClient(); |
221 } | 221 } |
222 | 222 |
223 GLContextReal::~GLContextReal() { | 223 GLContextReal::~GLContextReal() { |
224 if (GetRealCurrent() == this) | 224 if (GetRealCurrent() == this) |
225 current_real_context_.Pointer()->Set(nullptr); | 225 current_real_context_.Pointer()->Set(nullptr); |
226 } | 226 } |
227 | 227 |
228 void GLContextReal::SetCurrent(GLSurface* surface) { | 228 void GLContextReal::SetCurrent(GLSurface* surface) { |
229 GLContext::SetCurrent(surface); | 229 GLContext::SetCurrent(surface); |
230 current_real_context_.Pointer()->Set(surface ? this : nullptr); | 230 current_real_context_.Pointer()->Set(surface ? this : nullptr); |
231 } | 231 } |
232 | 232 |
233 } // namespace gl | 233 } // namespace gl |
OLD | NEW |