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

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

Issue 1882953006: Attach YUV420 to RGB converter to GLContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Move output arg Created 4 years, 8 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
« no previous file with comments | « ui/gl/gl_context_cgl.h ('k') | ui/gl/gl_image_io_surface.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <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"
20 #include "ui/gl/yuv_to_rgb_converter.h"
19 21
20 namespace gfx { 22 namespace gfx {
21 23
22 namespace { 24 namespace {
23 25
24 bool g_support_renderer_switching; 26 bool g_support_renderer_switching;
25 27
26 struct CGLRendererInfoObjDeleter { 28 struct CGLRendererInfoObjDeleter {
27 void operator()(CGLRendererInfoObj* x) { 29 void operator()(CGLRendererInfoObj* x) {
28 if (x) 30 if (x)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
129 gpu_preference_ = gpu_preference; 131 gpu_preference_ = gpu_preference;
130 // 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
131 // 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
132 // contexts as safe to forcibly transition between the GPUs by default. 134 // contexts as safe to forcibly transition between the GPUs by default.
133 // http://crbug.com/180876, http://crbug.com/227228 135 // http://crbug.com/180876, http://crbug.com/227228
134 safe_to_force_gpu_switch_ = gpu_preference == PreferIntegratedGpu; 136 safe_to_force_gpu_switch_ = gpu_preference == PreferIntegratedGpu;
135 return true; 137 return true;
136 } 138 }
137 139
138 void GLContextCGL::Destroy() { 140 void GLContextCGL::Destroy() {
141 if (yuv_to_rgb_converter_) {
142 gfx::ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_));
143 yuv_to_rgb_converter_.reset();
144 }
139 if (discrete_pixelformat_) { 145 if (discrete_pixelformat_) {
140 if (base::MessageLoop::current() != nullptr) { 146 if (base::MessageLoop::current() != nullptr) {
141 // 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
142 // unnecessary GPU switches. 148 // unnecessary GPU switches.
143 base::MessageLoop::current()->PostDelayedTask( 149 base::MessageLoop::current()->PostDelayedTask(
144 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_), 150 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_),
145 base::TimeDelta::FromSeconds(10)); 151 base::TimeDelta::FromSeconds(10));
146 } else { 152 } else {
147 CGLReleasePixelFormat(discrete_pixelformat_); 153 CGLReleasePixelFormat(discrete_pixelformat_);
148 } 154 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 screen_ = i; 194 screen_ = i;
189 break; 195 break;
190 } 196 }
191 } 197 }
192 renderer_id_ = renderer_id; 198 renderer_id_ = renderer_id;
193 } 199 }
194 } 200 }
195 return true; 201 return true;
196 } 202 }
197 203
204 gl::YUVToRGBConverter* GLContextCGL::GetYUVToRGBConverter() {
205 if (!yuv_to_rgb_converter_)
206 yuv_to_rgb_converter_.reset(new gl::YUVToRGBConverter);
207 return yuv_to_rgb_converter_.get();
208 }
209
198 bool GLContextCGL::MakeCurrent(GLSurface* surface) { 210 bool GLContextCGL::MakeCurrent(GLSurface* surface) {
199 DCHECK(context_); 211 DCHECK(context_);
200 212
201 if (!ForceGpuSwitchIfNeeded()) 213 if (!ForceGpuSwitchIfNeeded())
202 return false; 214 return false;
203 215
204 if (IsCurrent(surface)) 216 if (IsCurrent(surface))
205 return true; 217 return true;
206 218
207 ScopedReleaseCurrent release_current; 219 ScopedReleaseCurrent release_current;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
267 279
268 GLContextCGL::~GLContextCGL() { 280 GLContextCGL::~GLContextCGL() {
269 Destroy(); 281 Destroy();
270 } 282 }
271 283
272 GpuPreference GLContextCGL::GetGpuPreference() { 284 GpuPreference GLContextCGL::GetGpuPreference() {
273 return gpu_preference_; 285 return gpu_preference_;
274 } 286 }
275 287
276 } // namespace gfx 288 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context_cgl.h ('k') | ui/gl/gl_image_io_surface.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698