| Index: ui/gl/gl_context_cgl.cc
|
| diff --git a/ui/gl/gl_context_cgl.cc b/ui/gl/gl_context_cgl.cc
|
| index 2fd20a086cbebc83ff8d157f2d8bbaa91acad501..9ec6facb67615c7f3c2ee5de404ac5adeb0a0085 100644
|
| --- a/ui/gl/gl_context_cgl.cc
|
| +++ b/ui/gl/gl_context_cgl.cc
|
| @@ -31,14 +31,15 @@ struct CGLRendererInfoObjDeleter {
|
|
|
| } // namespace
|
|
|
| -static CGLPixelFormatObj GetPixelFormat() {
|
| +static CGLPixelFormatObj GetPixelFormat(bool prevent_switchable) {
|
| static CGLPixelFormatObj format;
|
| if (format)
|
| return format;
|
| std::vector<CGLPixelFormatAttribute> attribs;
|
| // If the system supports dual gpus then allow offline renderers for every
|
| - // context, so that they can all be in the same share group.
|
| - if (ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus()) {
|
| + // context, so that they can all be in the same share group. Don't do this for
|
| + // discrete GPUs to avoid being offloaded to an idle GPU by OSX.
|
| + if (!prevent_switchable) {
|
| attribs.push_back(kCGLPFAAllowOfflineRenderers);
|
| g_support_renderer_switching = true;
|
| }
|
| @@ -93,14 +94,16 @@ bool GLContextCGL::Initialize(GLSurface* compatible_surface,
|
| GLContextCGL* share_context = share_group() ?
|
| static_cast<GLContextCGL*>(share_group()->GetContext()) : NULL;
|
|
|
| - CGLPixelFormatObj format = GetPixelFormat();
|
| + const bool prevent_switchable = gpu_preference == PreferDiscreteGpu ||
|
| + !ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus();
|
| +
|
| + CGLPixelFormatObj format = GetPixelFormat(prevent_switchable);
|
| if (!format)
|
| return false;
|
|
|
| // If using the discrete gpu, create a pixel format requiring it before we
|
| // create the context.
|
| - if (!ui::GpuSwitchingManager::GetInstance()->SupportsDualGpus() ||
|
| - gpu_preference == PreferDiscreteGpu) {
|
| + if (prevent_switchable) {
|
| std::vector<CGLPixelFormatAttribute> discrete_attribs;
|
| discrete_attribs.push_back((CGLPixelFormatAttribute) 0);
|
| GLint num_pixel_formats;
|
| @@ -164,7 +167,7 @@ bool GLContextCGL::ForceGpuSwitchIfNeeded() {
|
| // Attempt to find a virtual screen that's using the requested renderer,
|
| // and switch the context to use that screen. Don't attempt to switch if
|
| // the context requires the discrete GPU.
|
| - CGLPixelFormatObj format = GetPixelFormat();
|
| + CGLPixelFormatObj format = GetPixelFormat(false);
|
| int virtual_screen_count;
|
| if (CGLDescribePixelFormat(format, 0, kCGLPFAVirtualScreenCount,
|
| &virtual_screen_count) != kCGLNoError)
|
|
|