| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/gfx/gl/gl_implementation.h" | 5 #include "ui/gfx/gl/gl_implementation.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/at_exit.h" | 10 #include "base/at_exit.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return kGLImplementationNamePairs[i].name; | 58 return kGLImplementationNamePairs[i].name; |
| 59 } | 59 } |
| 60 | 60 |
| 61 return "unknown"; | 61 return "unknown"; |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool InitializeRequestedGLBindings( | 64 bool InitializeRequestedGLBindings( |
| 65 const GLImplementation* allowed_implementations_begin, | 65 const GLImplementation* allowed_implementations_begin, |
| 66 const GLImplementation* allowed_implementations_end, | 66 const GLImplementation* allowed_implementations_end, |
| 67 GLImplementation default_implementation) { | 67 GLImplementation default_implementation) { |
| 68 bool fallback_to_osmesa = false; |
| 68 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) { | 69 if (CommandLine::ForCurrentProcess()->HasSwitch(switches::kUseGL)) { |
| 69 std::string requested_implementation_name = | 70 std::string requested_implementation_name = |
| 70 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); | 71 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(switches::kUseGL); |
| 71 GLImplementation requested_implementation = | 72 GLImplementation requested_implementation; |
| 73 if (requested_implementation_name == "any") { |
| 74 requested_implementation = default_implementation; |
| 75 fallback_to_osmesa = true; |
| 76 } else { |
| 77 requested_implementation = |
| 72 GetNamedGLImplementation(requested_implementation_name); | 78 GetNamedGLImplementation(requested_implementation_name); |
| 79 } |
| 73 if (std::find(allowed_implementations_begin, | 80 if (std::find(allowed_implementations_begin, |
| 74 allowed_implementations_end, | 81 allowed_implementations_end, |
| 75 requested_implementation) == allowed_implementations_end) { | 82 requested_implementation) == allowed_implementations_end) { |
| 76 LOG(ERROR) << "Requested GL implementation is not available."; | 83 LOG(ERROR) << "Requested GL implementation is not available."; |
| 77 return false; | 84 return false; |
| 78 } | 85 } |
| 79 | 86 |
| 80 InitializeGLBindings(requested_implementation); | 87 InitializeGLBindings(requested_implementation); |
| 81 } else { | 88 } else { |
| 82 InitializeGLBindings(default_implementation); | 89 InitializeGLBindings(default_implementation); |
| 83 } | 90 } |
| 84 | 91 |
| 92 if (GetGLImplementation() == kGLImplementationNone && fallback_to_osmesa) |
| 93 InitializeGLBindings(kGLImplementationOSMesaGL); |
| 94 |
| 85 if (CommandLine::ForCurrentProcess()->HasSwitch( | 95 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 86 switches::kEnableGPUServiceLogging)) { | 96 switches::kEnableGPUServiceLogging)) { |
| 87 InitializeDebugGLBindings(); | 97 InitializeDebugGLBindings(); |
| 88 } | 98 } |
| 89 | 99 |
| 90 if (GetGLImplementation() == kGLImplementationNone) { | 100 if (GetGLImplementation() == kGLImplementationNone) { |
| 91 LOG(ERROR) << "Could not initialize GL."; | 101 LOG(ERROR) << "Could not initialize GL."; |
| 92 return false; | 102 return false; |
| 93 } else { | 103 } else { |
| 94 LOG(INFO) << "Using " | 104 LOG(INFO) << "Using " |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 if (g_get_proc_address) { | 152 if (g_get_proc_address) { |
| 143 void* proc = g_get_proc_address(name); | 153 void* proc = g_get_proc_address(name); |
| 144 if (proc) | 154 if (proc) |
| 145 return proc; | 155 return proc; |
| 146 } | 156 } |
| 147 | 157 |
| 148 return NULL; | 158 return NULL; |
| 149 } | 159 } |
| 150 | 160 |
| 151 } // namespace gfx | 161 } // namespace gfx |
| OLD | NEW |