| 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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 75 | 75 |
| 76 bool GLContext::GetTotalGpuMemory(size_t* bytes) { | 76 bool GLContext::GetTotalGpuMemory(size_t* bytes) { |
| 77 DCHECK(bytes); | 77 DCHECK(bytes); |
| 78 *bytes = 0; | 78 *bytes = 0; |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 | 81 |
| 82 void GLContext::SetSafeToForceGpuSwitch() { | 82 void GLContext::SetSafeToForceGpuSwitch() { |
| 83 } | 83 } |
| 84 | 84 |
| 85 bool GLContext::ForceGpuSwitchIfNeeded() { |
| 86 return true; |
| 87 } |
| 88 |
| 85 void GLContext::SetUnbindFboOnMakeCurrent() { | 89 void GLContext::SetUnbindFboOnMakeCurrent() { |
| 86 NOTIMPLEMENTED(); | 90 NOTIMPLEMENTED(); |
| 87 } | 91 } |
| 88 | 92 |
| 89 std::string GLContext::GetExtensions() { | 93 std::string GLContext::GetExtensions() { |
| 90 DCHECK(IsCurrent(NULL)); | 94 DCHECK(IsCurrent(NULL)); |
| 91 const char* ext = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); | 95 const char* ext = reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)); |
| 92 return std::string(ext ? ext : ""); | 96 return std::string(ext ? ext : ""); |
| 93 } | 97 } |
| 94 | 98 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 void GLContext::SetupForVirtualization() { | 196 void GLContext::SetupForVirtualization() { |
| 193 if (!virtual_gl_api_) { | 197 if (!virtual_gl_api_) { |
| 194 virtual_gl_api_.reset(new VirtualGLApi()); | 198 virtual_gl_api_.reset(new VirtualGLApi()); |
| 195 virtual_gl_api_->Initialize(&g_driver_gl, this); | 199 virtual_gl_api_->Initialize(&g_driver_gl, this); |
| 196 } | 200 } |
| 197 } | 201 } |
| 198 | 202 |
| 199 bool GLContext::MakeVirtuallyCurrent( | 203 bool GLContext::MakeVirtuallyCurrent( |
| 200 GLContext* virtual_context, GLSurface* surface) { | 204 GLContext* virtual_context, GLSurface* surface) { |
| 201 DCHECK(virtual_gl_api_); | 205 DCHECK(virtual_gl_api_); |
| 206 if (!ForceGpuSwitchIfNeeded()) |
| 207 return false; |
| 202 return virtual_gl_api_->MakeCurrent(virtual_context, surface); | 208 return virtual_gl_api_->MakeCurrent(virtual_context, surface); |
| 203 } | 209 } |
| 204 | 210 |
| 205 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { | 211 void GLContext::OnReleaseVirtuallyCurrent(GLContext* virtual_context) { |
| 206 if (virtual_gl_api_) | 212 if (virtual_gl_api_) |
| 207 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); | 213 virtual_gl_api_->OnReleaseVirtuallyCurrent(virtual_context); |
| 208 } | 214 } |
| 209 | 215 |
| 210 void GLContext::SetRealGLApi() { | 216 void GLContext::SetRealGLApi() { |
| 211 SetGLToRealGLApi(); | 217 SetGLToRealGLApi(); |
| 212 } | 218 } |
| 213 | 219 |
| 214 void GLContext::OnFlush() { | 220 void GLContext::OnFlush() { |
| 215 for (size_t n = 0; n < flush_events_.size(); n++) | 221 for (size_t n = 0; n < flush_events_.size(); n++) |
| 216 flush_events_[n]->Signal(); | 222 flush_events_[n]->Signal(); |
| 217 flush_events_.clear(); | 223 flush_events_.clear(); |
| 218 } | 224 } |
| 219 | 225 |
| 220 GLContextReal::GLContextReal(GLShareGroup* share_group) | 226 GLContextReal::GLContextReal(GLShareGroup* share_group) |
| 221 : GLContext(share_group) {} | 227 : GLContext(share_group) {} |
| 222 | 228 |
| 223 GLContextReal::~GLContextReal() {} | 229 GLContextReal::~GLContextReal() {} |
| 224 | 230 |
| 225 void GLContextReal::SetCurrent(GLSurface* surface) { | 231 void GLContextReal::SetCurrent(GLSurface* surface) { |
| 226 GLContext::SetCurrent(surface); | 232 GLContext::SetCurrent(surface); |
| 227 current_real_context_.Pointer()->Set(surface ? this : NULL); | 233 current_real_context_.Pointer()->Set(surface ? this : NULL); |
| 228 } | 234 } |
| 229 | 235 |
| 230 } // namespace gfx | 236 } // namespace gfx |
| OLD | NEW |