Index: ui/gfx/gl/gl_surface_cgl.cc |
=================================================================== |
--- ui/gfx/gl/gl_surface_cgl.cc (revision 104937) |
+++ ui/gfx/gl/gl_surface_cgl.cc (working copy) |
@@ -6,7 +6,9 @@ |
#include "base/basictypes.h" |
#include "base/logging.h" |
+#include "base/mac/mac_util.h" |
#include "ui/gfx/gl/gl_bindings.h" |
+#include "ui/gfx/gl/gl_context.h" |
namespace gfx { |
@@ -25,13 +27,21 @@ |
if (initialized) |
return true; |
- static const CGLPixelFormatAttribute attribs[] = { |
- (CGLPixelFormatAttribute) kCGLPFAPBuffer, |
- (CGLPixelFormatAttribute) 0 |
- }; |
+ // This is called from the sandbox warmup code on Mac OS X. |
+ // GPU-related stuff is very slow without this, probably because |
+ // the sandbox prevents loading graphics drivers or some such. |
+ std::vector<CGLPixelFormatAttribute> attribs; |
+ if (GLContext::SupportsDualGpus()) { |
+ // Avoid switching to the discrete GPU just for this pixel |
Mark Mentovai
2011/10/12 00:48:18
Fix indentation.
Ken Russell (switch to Gerrit)
2011/10/12 01:16:36
Done.
|
+ // format selection. |
+ attribs.push_back(kCGLPFAAllowOfflineRenderers); |
+ } |
+ attribs.push_back((CGLPixelFormatAttribute) 0); |
Mark Mentovai
2011/10/12 00:48:18
Use a proper C++<style>(cast).
Ken Russell (switch to Gerrit)
2011/10/12 01:16:36
Done.
|
+ |
+ CGLPixelFormatObj format; |
GLint num_pixel_formats; |
- if (CGLChoosePixelFormat(attribs, |
- &g_pixel_format, |
+ if (CGLChoosePixelFormat(&attribs.front(), |
+ &format, |
&num_pixel_formats) != kCGLNoError) { |
LOG(ERROR) << "Error choosing pixel format."; |
return false; |
@@ -40,11 +50,11 @@ |
LOG(ERROR) << "num_pixel_formats == 0."; |
return false; |
} |
- if (!g_pixel_format) { |
+ if (!format) { |
LOG(ERROR) << "pixel_format == 0."; |
Mark Mentovai
2011/10/12 00:48:18
This isn’t called pixel_format now (and actually w
Ken Russell (switch to Gerrit)
2011/10/12 01:16:36
Fixed.
|
return false; |
} |
- |
+ CGLReleasePixelFormat(format); |
Mark Mentovai
2011/10/12 00:48:18
Is there any way for format to be nonzero but num_
Ken Russell (switch to Gerrit)
2011/10/12 01:16:36
Thanks for the suggestion. Implemented.
|
initialized = true; |
return true; |
} |