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

Side by Side Diff: ui/gl/gl_context_cgl.cc

Issue 10909221: Implement blacklist's force GPU capability in dual GPU machines. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/gl/gl_context_cgl.h" 5 #include "ui/gl/gl_context_cgl.h"
6 6
7 #include <OpenGL/CGLRenderers.h> 7 #include <OpenGL/CGLRenderers.h>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/debug/trace_event.h" 10 #include "base/debug/trace_event.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "ui/gl/gl_bindings.h" 12 #include "ui/gl/gl_bindings.h"
13 #include "ui/gl/gl_implementation.h" 13 #include "ui/gl/gl_implementation.h"
14 #include "ui/gl/gl_surface_cgl.h" 14 #include "ui/gl/gl_surface_cgl.h"
15 #include "ui/gl/gpu_switching_manager.h"
15 16
16 namespace gfx { 17 namespace gfx {
17 18
18 GLContextCGL::GLContextCGL(GLShareGroup* share_group) 19 GLContextCGL::GLContextCGL(GLShareGroup* share_group)
19 : GLContext(share_group), 20 : GLContext(share_group),
20 context_(NULL), 21 context_(NULL),
21 gpu_preference_(PreferIntegratedGpu), 22 gpu_preference_(PreferIntegratedGpu),
22 discrete_pixelformat_(NULL) { 23 discrete_pixelformat_(NULL) {
23 } 24 }
24 25
25 bool GLContextCGL::Initialize(GLSurface* compatible_surface, 26 bool GLContextCGL::Initialize(GLSurface* compatible_surface,
26 GpuPreference gpu_preference) { 27 GpuPreference gpu_preference) {
27 DCHECK(compatible_surface); 28 DCHECK(compatible_surface);
28 29
30 gpu_preference = GpuSwitchingManager::GetInstance()->AdjustGpuPreference(
31 gpu_preference);
32
29 GLContextCGL* share_context = share_group() ? 33 GLContextCGL* share_context = share_group() ?
30 static_cast<GLContextCGL*>(share_group()->GetContext()) : NULL; 34 static_cast<GLContextCGL*>(share_group()->GetContext()) : NULL;
31 35
32 std::vector<CGLPixelFormatAttribute> attribs; 36 std::vector<CGLPixelFormatAttribute> attribs;
33 // If the system supports dual gpus then allow offline renderers for every 37 // If the system supports dual gpus then allow offline renderers for every
34 // context, so that they can all be in the same share group. 38 // context, so that they can all be in the same share group.
35 if (SupportsDualGpus()) 39 if (SupportsDualGpus())
36 attribs.push_back(kCGLPFAAllowOfflineRenderers); 40 attribs.push_back(kCGLPFAAllowOfflineRenderers);
37 if (GetGLImplementation() == kGLImplementationAppleGL) { 41 if (GetGLImplementation() == kGLImplementationAppleGL) {
38 attribs.push_back(kCGLPFARendererID); 42 attribs.push_back(kCGLPFARendererID);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 } 159 }
156 160
157 GLContextCGL::~GLContextCGL() { 161 GLContextCGL::~GLContextCGL() {
158 Destroy(); 162 Destroy();
159 } 163 }
160 164
161 GpuPreference GLContextCGL::GetGpuPreference() { 165 GpuPreference GLContextCGL::GetGpuPreference() {
162 return gpu_preference_; 166 return gpu_preference_;
163 } 167 }
164 168
165 void GLContextCGL::ForceUseOfDiscreteGPU() {
166 static CGLPixelFormatObj format = NULL;
167 if (format)
168 return;
169 CGLPixelFormatAttribute attribs[1];
170 attribs[0] = static_cast<CGLPixelFormatAttribute>(0);
171 GLint num_pixel_formats = 0;
172 CGLChoosePixelFormat(attribs, &format, &num_pixel_formats);
173 // format is deliberately leaked.
174 }
175
176 } // namespace gfx 169 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context_cgl.h ('k') | ui/gl/gl_context_mac.mm » ('j') | ui/gl/gl_switches.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698