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

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

Issue 952893003: Update from https://crrev.com/317530 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Fix gn for nacl Created 5 years, 10 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.cc ('k') | ui/gl/gl_mock_autogen_gl.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
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 Destroy(); 115 Destroy();
116 return false; 116 return false;
117 } 117 }
118 118
119 gpu_preference_ = gpu_preference; 119 gpu_preference_ = gpu_preference;
120 return true; 120 return true;
121 } 121 }
122 122
123 void GLContextCGL::Destroy() { 123 void GLContextCGL::Destroy() {
124 if (discrete_pixelformat_) { 124 if (discrete_pixelformat_) {
125 // Delay releasing the pixel format for 10 seconds to reduce the number of 125 if (base::MessageLoop::current() != NULL) {
126 // unnecessary GPU switches. 126 // Delay releasing the pixel format for 10 seconds to reduce the number of
127 base::MessageLoop::current()->PostDelayedTask( 127 // unnecessary GPU switches.
128 FROM_HERE, 128 base::MessageLoop::current()->PostDelayedTask(
129 base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_), 129 FROM_HERE, base::Bind(&CGLReleasePixelFormat, discrete_pixelformat_),
130 base::TimeDelta::FromSeconds(10)); 130 base::TimeDelta::FromSeconds(10));
131 } else {
132 CGLReleasePixelFormat(discrete_pixelformat_);
133 }
131 discrete_pixelformat_ = NULL; 134 discrete_pixelformat_ = NULL;
132 } 135 }
133 if (context_) { 136 if (context_) {
134 CGLDestroyContext(static_cast<CGLContextObj>(context_)); 137 CGLDestroyContext(static_cast<CGLContextObj>(context_));
135 context_ = NULL; 138 context_ = NULL;
136 } 139 }
137 } 140 }
138 141
139 bool GLContextCGL::ForceGpuSwitchIfNeeded() { 142 bool GLContextCGL::ForceGpuSwitchIfNeeded() {
140 DCHECK(context_); 143 DCHECK(context_);
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 305
303 GLContextCGL::~GLContextCGL() { 306 GLContextCGL::~GLContextCGL() {
304 Destroy(); 307 Destroy();
305 } 308 }
306 309
307 GpuPreference GLContextCGL::GetGpuPreference() { 310 GpuPreference GLContextCGL::GetGpuPreference() {
308 return gpu_preference_; 311 return gpu_preference_;
309 } 312 }
310 313
311 } // namespace gfx 314 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gl/gl_context.cc ('k') | ui/gl/gl_mock_autogen_gl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698