| 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/location.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/single_thread_task_runner.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" |
| 14 #include "base/trace_event/trace_event.h" | 17 #include "base/trace_event/trace_event.h" |
| 15 #include "ui/gl/gl_bindings.h" | 18 #include "ui/gl/gl_bindings.h" |
| 16 #include "ui/gl/gl_implementation.h" | 19 #include "ui/gl/gl_implementation.h" |
| 17 #include "ui/gl/gl_surface.h" | 20 #include "ui/gl/gl_surface.h" |
| 18 #include "ui/gl/gpu_switching_manager.h" | 21 #include "ui/gl/gpu_switching_manager.h" |
| 19 #include "ui/gl/scoped_cgl.h" | 22 #include "ui/gl/scoped_cgl.h" |
| 20 #include "ui/gl/yuv_to_rgb_converter.h" | 23 #include "ui/gl/yuv_to_rgb_converter.h" |
| 21 | 24 |
| 22 namespace gl { | 25 namespace gl { |
| 23 | 26 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 | 142 |
| 140 void GLContextCGL::Destroy() { | 143 void GLContextCGL::Destroy() { |
| 141 if (yuv_to_rgb_converter_) { | 144 if (yuv_to_rgb_converter_) { |
| 142 ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_)); | 145 ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_)); |
| 143 yuv_to_rgb_converter_.reset(); | 146 yuv_to_rgb_converter_.reset(); |
| 144 } | 147 } |
| 145 if (discrete_pixelformat_) { | 148 if (discrete_pixelformat_) { |
| 146 if (base::MessageLoop::current() != nullptr) { | 149 if (base::MessageLoop::current() != nullptr) { |
| 147 // Delay releasing the pixel format for 10 seconds to reduce the number of | 150 // Delay releasing the pixel format for 10 seconds to reduce the number of |
| 148 // unnecessary GPU switches. | 151 // unnecessary GPU switches. |
| 149 base::MessageLoop::current()->PostDelayedTask( | 152 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( |
| 150 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_), | 153 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_), |
| 151 base::TimeDelta::FromSeconds(10)); | 154 base::TimeDelta::FromSeconds(10)); |
| 152 } else { | 155 } else { |
| 153 CGLReleasePixelFormat(discrete_pixelformat_); | 156 CGLReleasePixelFormat(discrete_pixelformat_); |
| 154 } | 157 } |
| 155 discrete_pixelformat_ = nullptr; | 158 discrete_pixelformat_ = nullptr; |
| 156 } | 159 } |
| 157 if (context_) { | 160 if (context_) { |
| 158 CGLDestroyContext(static_cast<CGLContextObj>(context_)); | 161 CGLDestroyContext(static_cast<CGLContextObj>(context_)); |
| 159 context_ = nullptr; | 162 context_ = nullptr; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 | 282 |
| 280 GLContextCGL::~GLContextCGL() { | 283 GLContextCGL::~GLContextCGL() { |
| 281 Destroy(); | 284 Destroy(); |
| 282 } | 285 } |
| 283 | 286 |
| 284 GpuPreference GLContextCGL::GetGpuPreference() { | 287 GpuPreference GLContextCGL::GetGpuPreference() { |
| 285 return gpu_preference_; | 288 return gpu_preference_; |
| 286 } | 289 } |
| 287 | 290 |
| 288 } // namespace gl | 291 } // namespace gl |
| OLD | NEW |