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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/logging.h" | 6 #include "base/logging.h" |
7 #include "base/mac/mac_util.h" | |
7 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
8 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" | 9 #include "third_party/mesa/MesaLib/include/GL/osmesa.h" |
9 #include "ui/gfx/gl/gl_bindings.h" | 10 #include "ui/gfx/gl/gl_bindings.h" |
10 #include "ui/gfx/gl/gl_context_cgl.h" | 11 #include "ui/gfx/gl/gl_context_cgl.h" |
11 #include "ui/gfx/gl/gl_context_osmesa.h" | 12 #include "ui/gfx/gl/gl_context_osmesa.h" |
12 #include "ui/gfx/gl/gl_context_stub.h" | 13 #include "ui/gfx/gl/gl_context_stub.h" |
13 #include "ui/gfx/gl/gl_implementation.h" | 14 #include "ui/gfx/gl/gl_implementation.h" |
14 #include "ui/gfx/gl/gl_surface_cgl.h" | 15 #include "ui/gfx/gl/gl_surface_cgl.h" |
15 #include "ui/gfx/gl/gl_surface_osmesa.h" | 16 #include "ui/gfx/gl/gl_surface_osmesa.h" |
16 | 17 |
17 namespace gfx { | 18 namespace gfx { |
18 | 19 |
19 class GLShareGroup; | 20 class GLShareGroup; |
20 | 21 |
21 scoped_refptr<GLContext> GLContext::CreateGLContext( | 22 scoped_refptr<GLContext> GLContext::CreateGLContext( |
22 GLShareGroup* share_group, | 23 GLShareGroup* share_group, |
23 GLSurface* compatible_surface) { | 24 GLSurface* compatible_surface, |
25 GpuPreference gpu_preference) { | |
24 switch (GetGLImplementation()) { | 26 switch (GetGLImplementation()) { |
25 case kGLImplementationDesktopGL: { | 27 case kGLImplementationDesktopGL: { |
26 scoped_refptr<GLContext> context(new GLContextCGL(share_group)); | 28 scoped_refptr<GLContext> context(new GLContextCGL(share_group)); |
27 if (!context->Initialize(compatible_surface)) | 29 if (!context->Initialize(compatible_surface, gpu_preference)) |
28 return NULL; | 30 return NULL; |
29 | 31 |
30 return context; | 32 return context; |
31 } | 33 } |
32 case kGLImplementationOSMesaGL: { | 34 case kGLImplementationOSMesaGL: { |
33 scoped_refptr<GLContext> context(new GLContextOSMesa(share_group)); | 35 scoped_refptr<GLContext> context(new GLContextOSMesa(share_group)); |
34 if (!context->Initialize(compatible_surface)) | 36 if (!context->Initialize(compatible_surface, gpu_preference)) |
35 return NULL; | 37 return NULL; |
36 | 38 |
37 return context; | 39 return context; |
38 } | 40 } |
39 case kGLImplementationMockGL: | 41 case kGLImplementationMockGL: |
40 return new GLContextStub; | 42 return new GLContextStub; |
41 default: | 43 default: |
42 NOTREACHED(); | 44 NOTREACHED(); |
43 return NULL; | 45 return NULL; |
44 } | 46 } |
45 } | 47 } |
46 | 48 |
49 bool GLContext::SupportsDualGpus() { | |
50 // TODO(kbr): the precision of this query could be improved, in | |
51 // particular to detect single-GPU systems. | |
Mark Mentovai
2011/10/12 00:48:18
This is the one thing I think we can do way better
Ken Russell (switch to Gerrit)
2011/10/12 01:16:36
I agree, this could be done better. Unfortunately
| |
52 return base::mac::IsOSLionOrLater(); | |
53 } | |
54 | |
47 } // namespace gfx | 55 } // namespace gfx |
OLD | NEW |