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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 // Contexts that prefer integrated gpu are known to use only the subset of GL | 132 // Contexts that prefer integrated gpu are known to use only the subset of GL |
133 // that can be safely migrated between the iGPU and the dGPU. Mark those | 133 // that can be safely migrated between the iGPU and the dGPU. Mark those |
134 // contexts as safe to forcibly transition between the GPUs by default. | 134 // contexts as safe to forcibly transition between the GPUs by default. |
135 // http://crbug.com/180876, http://crbug.com/227228 | 135 // http://crbug.com/180876, http://crbug.com/227228 |
136 safe_to_force_gpu_switch_ = gpu_preference == PreferIntegratedGpu; | 136 safe_to_force_gpu_switch_ = gpu_preference == PreferIntegratedGpu; |
137 return true; | 137 return true; |
138 } | 138 } |
139 | 139 |
140 void GLContextCGL::Destroy() { | 140 void GLContextCGL::Destroy() { |
141 if (yuv_to_rgb_converter_) { | 141 if (yuv_to_rgb_converter_) { |
142 gl::ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_)); | 142 ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_)); |
143 yuv_to_rgb_converter_.reset(); | 143 yuv_to_rgb_converter_.reset(); |
144 } | 144 } |
145 if (discrete_pixelformat_) { | 145 if (discrete_pixelformat_) { |
146 if (base::MessageLoop::current() != nullptr) { | 146 if (base::MessageLoop::current() != nullptr) { |
147 // Delay releasing the pixel format for 10 seconds to reduce the number of | 147 // Delay releasing the pixel format for 10 seconds to reduce the number of |
148 // unnecessary GPU switches. | 148 // unnecessary GPU switches. |
149 base::MessageLoop::current()->PostDelayedTask( | 149 base::MessageLoop::current()->PostDelayedTask( |
150 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_), | 150 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_), |
151 base::TimeDelta::FromSeconds(10)); | 151 base::TimeDelta::FromSeconds(10)); |
152 } else { | 152 } else { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 screen_ = i; | 194 screen_ = i; |
195 break; | 195 break; |
196 } | 196 } |
197 } | 197 } |
198 renderer_id_ = renderer_id; | 198 renderer_id_ = renderer_id; |
199 } | 199 } |
200 } | 200 } |
201 return true; | 201 return true; |
202 } | 202 } |
203 | 203 |
204 gl::YUVToRGBConverter* GLContextCGL::GetYUVToRGBConverter() { | 204 YUVToRGBConverter* GLContextCGL::GetYUVToRGBConverter() { |
205 if (!yuv_to_rgb_converter_) | 205 if (!yuv_to_rgb_converter_) |
206 yuv_to_rgb_converter_.reset(new gl::YUVToRGBConverter); | 206 yuv_to_rgb_converter_.reset(new YUVToRGBConverter); |
207 return yuv_to_rgb_converter_.get(); | 207 return yuv_to_rgb_converter_.get(); |
208 } | 208 } |
209 | 209 |
210 bool GLContextCGL::MakeCurrent(GLSurface* surface) { | 210 bool GLContextCGL::MakeCurrent(GLSurface* surface) { |
211 DCHECK(context_); | 211 DCHECK(context_); |
212 | 212 |
213 if (!ForceGpuSwitchIfNeeded()) | 213 if (!ForceGpuSwitchIfNeeded()) |
214 return false; | 214 return false; |
215 | 215 |
216 if (IsCurrent(surface)) | 216 if (IsCurrent(surface)) |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 | 279 |
280 GLContextCGL::~GLContextCGL() { | 280 GLContextCGL::~GLContextCGL() { |
281 Destroy(); | 281 Destroy(); |
282 } | 282 } |
283 | 283 |
284 GpuPreference GLContextCGL::GetGpuPreference() { | 284 GpuPreference GLContextCGL::GetGpuPreference() { |
285 return gpu_preference_; | 285 return gpu_preference_; |
286 } | 286 } |
287 | 287 |
288 } // namespace gl | 288 } // namespace gl |
OLD | NEW |