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

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

Issue 2005463002: Attach YUV420 to RGB converter to GLContext (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2704
Patch Set: Created 4 years, 7 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 #include <vector> 9 #include <vector>
10 10
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
13 #include "base/trace_event/trace_event.h" 13 #include "base/trace_event/trace_event.h"
14 #include "ui/gl/gl_bindings.h" 14 #include "ui/gl/gl_bindings.h"
15 #include "ui/gl/gl_implementation.h" 15 #include "ui/gl/gl_implementation.h"
16 #include "ui/gl/gl_surface.h" 16 #include "ui/gl/gl_surface.h"
17 #include "ui/gl/gpu_switching_manager.h" 17 #include "ui/gl/gpu_switching_manager.h"
18 #include "ui/gl/scoped_cgl.h"
19 #include "ui/gl/yuv_to_rgb_converter.h"
18 20
19 namespace gfx { 21 namespace gfx {
20 22
21 namespace { 23 namespace {
22 24
23 bool g_support_renderer_switching; 25 bool g_support_renderer_switching;
24 26
25 struct CGLRendererInfoObjDeleter { 27 struct CGLRendererInfoObjDeleter {
26 void operator()(CGLRendererInfoObj* x) { 28 void operator()(CGLRendererInfoObj* x) {
27 if (x) 29 if (x)
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 gpu_preference_ = gpu_preference; 130 gpu_preference_ = gpu_preference;
129 // Contexts that prefer integrated gpu are known to use only the subset of GL 131 // Contexts that prefer integrated gpu are known to use only the subset of GL
130 // that can be safely migrated between the iGPU and the dGPU. Mark those 132 // that can be safely migrated between the iGPU and the dGPU. Mark those
131 // contexts as safe to forcibly transition between the GPUs by default. 133 // contexts as safe to forcibly transition between the GPUs by default.
132 // http://crbug.com/180876, http://crbug.com/227228 134 // http://crbug.com/180876, http://crbug.com/227228
133 safe_to_force_gpu_switch_ = gpu_preference == PreferIntegratedGpu; 135 safe_to_force_gpu_switch_ = gpu_preference == PreferIntegratedGpu;
134 return true; 136 return true;
135 } 137 }
136 138
137 void GLContextCGL::Destroy() { 139 void GLContextCGL::Destroy() {
140 if (yuv_to_rgb_converter_) {
141 gfx::ScopedCGLSetCurrentContext(static_cast<CGLContextObj>(context_));
142 yuv_to_rgb_converter_.reset();
143 }
138 if (discrete_pixelformat_) { 144 if (discrete_pixelformat_) {
139 if (base::MessageLoop::current() != nullptr) { 145 if (base::MessageLoop::current() != nullptr) {
140 // Delay releasing the pixel format for 10 seconds to reduce the number of 146 // Delay releasing the pixel format for 10 seconds to reduce the number of
141 // unnecessary GPU switches. 147 // unnecessary GPU switches.
142 base::MessageLoop::current()->PostDelayedTask( 148 base::MessageLoop::current()->PostDelayedTask(
143 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_), 149 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_),
144 base::TimeDelta::FromSeconds(10)); 150 base::TimeDelta::FromSeconds(10));
145 } else { 151 } else {
146 CGLReleasePixelFormat(discrete_pixelformat_); 152 CGLReleasePixelFormat(discrete_pixelformat_);
147 } 153 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 screen_ = i; 193 screen_ = i;
188 break; 194 break;
189 } 195 }
190 } 196 }
191 renderer_id_ = renderer_id; 197 renderer_id_ = renderer_id;
192 } 198 }
193 } 199 }
194 return true; 200 return true;
195 } 201 }
196 202
203 gl::YUVToRGBConverter* GLContextCGL::GetYUVToRGBConverter() {
204 if (!yuv_to_rgb_converter_)
205 yuv_to_rgb_converter_.reset(new gl::YUVToRGBConverter);
206 return yuv_to_rgb_converter_.get();
207 }
208
197 bool GLContextCGL::MakeCurrent(GLSurface* surface) { 209 bool GLContextCGL::MakeCurrent(GLSurface* surface) {
198 DCHECK(context_); 210 DCHECK(context_);
199 211
200 if (!ForceGpuSwitchIfNeeded()) 212 if (!ForceGpuSwitchIfNeeded())
201 return false; 213 return false;
202 214
203 if (IsCurrent(surface)) 215 if (IsCurrent(surface))
204 return true; 216 return true;
205 217
206 ScopedReleaseCurrent release_current; 218 ScopedReleaseCurrent release_current;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 278
267 GLContextCGL::~GLContextCGL() { 279 GLContextCGL::~GLContextCGL() {
268 Destroy(); 280 Destroy();
269 } 281 }
270 282
271 GpuPreference GLContextCGL::GetGpuPreference() { 283 GpuPreference GLContextCGL::GetGpuPreference() {
272 return gpu_preference_; 284 return gpu_preference_;
273 } 285 }
274 286
275 } // namespace gfx 287 } // 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