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

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
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;
}

Powered by Google App Engine
This is Rietveld 408576698