| 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
| 6 #include "base/command_line.h" | 6 #include "base/command_line.h" |
| 7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/mac/mac_util.h" | 9 #include "base/mac/mac_util.h" |
| 10 #include "base/memory/scoped_generic_obj.h" | |
| 11 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 12 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" | 11 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" |
| 13 #include "ui/gl/gl_bindings.h" | 12 #include "ui/gl/gl_bindings.h" |
| 14 #include "ui/gl/gl_context_cgl.h" | 13 #include "ui/gl/gl_context_cgl.h" |
| 15 #include "ui/gl/gl_context_osmesa.h" | 14 #include "ui/gl/gl_context_osmesa.h" |
| 16 #include "ui/gl/gl_context_stub.h" | 15 #include "ui/gl/gl_context_stub.h" |
| 17 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
| 18 #include "ui/gl/gl_surface.h" | 17 #include "ui/gl/gl_surface.h" |
| 19 #include "ui/gl/gl_switches.h" | 18 #include "ui/gl/gl_switches.h" |
| 20 | 19 |
| 21 #if defined(USE_AURA) | 20 #if defined(USE_AURA) |
| 22 #include "ui/gl/gl_context_nsview.h" | 21 #include "ui/gl/gl_context_nsview.h" |
| 23 #endif | 22 #endif |
| 24 | 23 |
| 25 namespace { | |
| 26 | |
| 27 // ScopedGenericObj functor for CGLDestroyRendererInfo(). | |
| 28 class ScopedDestroyRendererInfo { | |
| 29 public: | |
| 30 void operator()(CGLRendererInfoObj x) const { | |
| 31 CGLDestroyRendererInfo(x); | |
| 32 } | |
| 33 }; | |
| 34 | |
| 35 } // namespace | |
| 36 | |
| 37 namespace gfx { | 24 namespace gfx { |
| 38 | 25 |
| 39 class GLShareGroup; | 26 class GLShareGroup; |
| 40 | 27 |
| 41 scoped_refptr<GLContext> GLContext::CreateGLContext( | 28 scoped_refptr<GLContext> GLContext::CreateGLContext( |
| 42 GLShareGroup* share_group, | 29 GLShareGroup* share_group, |
| 43 GLSurface* compatible_surface, | 30 GLSurface* compatible_surface, |
| 44 GpuPreference gpu_preference) { | 31 GpuPreference gpu_preference) { |
| 45 TRACE_EVENT0("gpu", "GLContext::CreateGLContext"); | 32 TRACE_EVENT0("gpu", "GLContext::CreateGLContext"); |
| 46 switch (GetGLImplementation()) { | 33 switch (GetGLImplementation()) { |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 | 99 |
| 113 bool found_online = false; | 100 bool found_online = false; |
| 114 bool found_offline = false; | 101 bool found_offline = false; |
| 115 | 102 |
| 116 if (CGLQueryRendererInfo(display_mask, | 103 if (CGLQueryRendererInfo(display_mask, |
| 117 &renderer_info, | 104 &renderer_info, |
| 118 &num_renderers) != kCGLNoError) { | 105 &num_renderers) != kCGLNoError) { |
| 119 return false; | 106 return false; |
| 120 } | 107 } |
| 121 | 108 |
| 122 ScopedGenericObj<CGLRendererInfoObj, ScopedDestroyRendererInfo> | 109 ScopedCGLRendererInfoObj scoper(renderer_info); |
| 123 scoper(renderer_info); | |
| 124 | 110 |
| 125 for (GLint i = 0; i < num_renderers; ++i) { | 111 for (GLint i = 0; i < num_renderers; ++i) { |
| 126 GLint accelerated = 0; | 112 GLint accelerated = 0; |
| 127 if (CGLDescribeRenderer(renderer_info, | 113 if (CGLDescribeRenderer(renderer_info, |
| 128 i, | 114 i, |
| 129 kCGLRPAccelerated, | 115 kCGLRPAccelerated, |
| 130 &accelerated) != kCGLNoError) { | 116 &accelerated) != kCGLNoError) { |
| 131 return false; | 117 return false; |
| 132 } | 118 } |
| 133 | 119 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 return false; | 160 return false; |
| 175 } | 161 } |
| 176 | 162 |
| 177 supports_dual_gpus = true; | 163 supports_dual_gpus = true; |
| 178 } | 164 } |
| 179 | 165 |
| 180 return supports_dual_gpus; | 166 return supports_dual_gpus; |
| 181 } | 167 } |
| 182 | 168 |
| 183 } // namespace gfx | 169 } // namespace gfx |
| OLD | NEW |