OLD | NEW |
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 <OpenGL/CGLTypes.h> | 8 #include <OpenGL/CGLTypes.h> |
9 | 9 |
10 #include <memory> | 10 #include <memory> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 : GLContextReal(share_group), | 84 : GLContextReal(share_group), |
85 context_(nullptr), | 85 context_(nullptr), |
86 gpu_preference_(PreferIntegratedGpu), | 86 gpu_preference_(PreferIntegratedGpu), |
87 discrete_pixelformat_(nullptr), | 87 discrete_pixelformat_(nullptr), |
88 screen_(-1), | 88 screen_(-1), |
89 renderer_id_(-1), | 89 renderer_id_(-1), |
90 safe_to_force_gpu_switch_(true) { | 90 safe_to_force_gpu_switch_(true) { |
91 } | 91 } |
92 | 92 |
93 bool GLContextCGL::Initialize(GLSurface* compatible_surface, | 93 bool GLContextCGL::Initialize(GLSurface* compatible_surface, |
94 GpuPreference gpu_preference) { | 94 const GLContextAttribs& attribs) { |
95 DCHECK(compatible_surface); | 95 DCHECK(compatible_surface); |
96 | 96 |
97 gpu_preference = ui::GpuSwitchingManager::GetInstance()->AdjustGpuPreference( | 97 // webgl_compatibility_context and disabling bind_generates_resource are not |
98 gpu_preference); | 98 // supported. |
| 99 DCHECK(!attribs.webgl_compatibility_context && |
| 100 attribs.bind_generates_resource); |
| 101 |
| 102 GpuPreference gpu_preference = |
| 103 ui::GpuSwitchingManager::GetInstance()->AdjustGpuPreference( |
| 104 attribs.gpu_preference); |
99 | 105 |
100 GLContextCGL* share_context = share_group() ? | 106 GLContextCGL* share_context = share_group() ? |
101 static_cast<GLContextCGL*>(share_group()->GetContext()) : nullptr; | 107 static_cast<GLContextCGL*>(share_group()->GetContext()) : nullptr; |
102 | 108 |
103 CGLPixelFormatObj format = GetPixelFormat(); | 109 CGLPixelFormatObj format = GetPixelFormat(); |
104 if (!format) | 110 if (!format) |
105 return false; | 111 return false; |
106 | 112 |
107 // If using the discrete gpu, create a pixel format requiring it before we | 113 // If using the discrete gpu, create a pixel format requiring it before we |
108 // create the context. | 114 // create the context. |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
281 | 287 |
282 GLContextCGL::~GLContextCGL() { | 288 GLContextCGL::~GLContextCGL() { |
283 Destroy(); | 289 Destroy(); |
284 } | 290 } |
285 | 291 |
286 GpuPreference GLContextCGL::GetGpuPreference() { | 292 GpuPreference GLContextCGL::GetGpuPreference() { |
287 return gpu_preference_; | 293 return gpu_preference_; |
288 } | 294 } |
289 | 295 |
290 } // namespace gl | 296 } // namespace gl |
OLD | NEW |