Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Unified Diff: ui/gfx/gl/gl_surface_cgl.cc

Issue 8233027: Support dynamic switching between integrated and discrete GPUs on Mac OS X. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/gfx/gl/gl_share_group.cc ('k') | ui/gfx/gl/gpu_preference.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/gfx/gl/gl_surface_cgl.cc
===================================================================
--- ui/gfx/gl/gl_surface_cgl.cc (revision 105357)
+++ 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,26 +27,31 @@
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
+ // format selection.
+ attribs.push_back(kCGLPFAAllowOfflineRenderers);
+ }
+ attribs.push_back(static_cast<CGLPixelFormatAttribute>(0));
+
+ 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;
}
- if (num_pixel_formats == 0) {
- LOG(ERROR) << "num_pixel_formats == 0.";
+ if (!format) {
+ LOG(ERROR) << "format == 0.";
return false;
}
- if (!g_pixel_format) {
- LOG(ERROR) << "pixel_format == 0.";
- return false;
- }
-
+ CGLReleasePixelFormat(format);
+ DCHECK_NE(num_pixel_formats, 0);
initialized = true;
return true;
}
« no previous file with comments | « ui/gfx/gl/gl_share_group.cc ('k') | ui/gfx/gl/gpu_preference.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698