| 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> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/logging.h" | 13 #include "base/logging.h" |
| 14 #include "base/trace_event/trace_event.h" | 14 #include "base/trace_event/trace_event.h" |
| 15 #include "ui/gl/gl_bindings.h" | 15 #include "ui/gl/gl_bindings.h" |
| 16 #include "ui/gl/gl_implementation.h" | 16 #include "ui/gl/gl_implementation.h" |
| 17 #include "ui/gl/gl_surface.h" | 17 #include "ui/gl/gl_surface.h" |
| 18 #include "ui/gl/gpu_switching_manager.h" | 18 #include "ui/gl/gpu_switching_manager.h" |
| 19 #include "ui/gl/scoped_cgl.h" | 19 #include "ui/gl/scoped_cgl.h" |
| 20 #include "ui/gl/yuv_to_rgb_converter.h" | 20 #include "ui/gl/yuv_to_rgb_converter.h" |
| 21 | 21 |
| 22 namespace gfx { | 22 namespace gl { |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 bool g_support_renderer_switching; | 26 bool g_support_renderer_switching; |
| 27 | 27 |
| 28 struct CGLRendererInfoObjDeleter { | 28 struct CGLRendererInfoObjDeleter { |
| 29 void operator()(CGLRendererInfoObj* x) { | 29 void operator()(CGLRendererInfoObj* x) { |
| 30 if (x) | 30 if (x) |
| 31 CGLDestroyRendererInfo(*x); | 31 CGLDestroyRendererInfo(*x); |
| 32 } | 32 } |
| (...skipping 99 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 gfx::ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_)); | 142 gl::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 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 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 gfx | 288 } // namespace gl |
| OLD | NEW |