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

Side by Side Diff: webkit/gpu/webgraphicscontext3d_in_process_impl.cc

Issue 8233027: Support dynamic switching between integrated and discrete GPUs on Mac OS X. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "webkit/gpu/webgraphicscontext3d_in_process_impl.h" 5 #include "webkit/gpu/webgraphicscontext3d_in_process_impl.h"
6 6
7 #include <string.h> 7 #include <string.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <string> 10 #include <string>
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // and force them to drop their contexts, sending a context lost event if 157 // and force them to drop their contexts, sending a context lost event if
158 // necessary. 158 // necessary.
159 if (webView) webView->mainFrame()->collectGarbage(); 159 if (webView) webView->mainFrame()->collectGarbage();
160 160
161 gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false, 161 gl_surface_ = gfx::GLSurface::CreateOffscreenGLSurface(false,
162 gfx::Size(1, 1)); 162 gfx::Size(1, 1));
163 if (!gl_surface_.get()) 163 if (!gl_surface_.get())
164 return false; 164 return false;
165 } 165 }
166 166
167 // TODO(kbr): This implementation doesn't yet support lost contexts
168 // and therefore can't yet properly support GPU switching.
169 gfx::GpuPreference gpu_preference = gfx::PreferDiscreteGpu;
170
167 gl_context_ = gfx::GLContext::CreateGLContext(share_group, 171 gl_context_ = gfx::GLContext::CreateGLContext(share_group,
168 gl_surface_.get()); 172 gl_surface_.get(),
173 gpu_preference);
169 if (!gl_context_.get()) { 174 if (!gl_context_.get()) {
170 if (!is_gles2_) 175 if (!is_gles2_)
171 return false; 176 return false;
172 177
173 // Embedded systems have smaller limit on number of GL contexts. Sometimes 178 // Embedded systems have smaller limit on number of GL contexts. Sometimes
174 // failure of GL context creation is because of existing GL contexts 179 // failure of GL context creation is because of existing GL contexts
175 // referenced by JavaScript garbages. Collect garbage and try again. 180 // referenced by JavaScript garbages. Collect garbage and try again.
176 // TODO: Besides this solution, kbr@chromium.org suggested: upon receiving 181 // TODO: Besides this solution, kbr@chromium.org suggested: upon receiving
177 // a page unload event, iterate down any live WebGraphicsContext3D instances 182 // a page unload event, iterate down any live WebGraphicsContext3D instances
178 // and force them to drop their contexts, sending a context lost event if 183 // and force them to drop their contexts, sending a context lost event if
179 // necessary. 184 // necessary.
180 if (webView) webView->mainFrame()->collectGarbage(); 185 if (webView) webView->mainFrame()->collectGarbage();
181 186
182 gl_context_ = gfx::GLContext::CreateGLContext(share_group, 187 gl_context_ = gfx::GLContext::CreateGLContext(share_group,
183 gl_surface_.get()); 188 gl_surface_.get(),
189 gpu_preference);
184 if (!gl_context_.get()) 190 if (!gl_context_.get())
185 return false; 191 return false;
186 } 192 }
187 193
188 attributes_ = attributes; 194 attributes_ = attributes;
189 195
190 // FIXME: for the moment we disable multisampling for the compositor. 196 // FIXME: for the moment we disable multisampling for the compositor.
191 // It actually works in this implementation, but there are a few 197 // It actually works in this implementation, but there are a few
192 // considerations. First, we likely want to reduce the fuzziness in 198 // considerations. First, we likely want to reduce the fuzziness in
193 // these tests as much as possible because we want to run pixel tests. 199 // these tests as much as possible because we want to run pixel tests.
(...skipping 1470 matching lines...) Expand 10 before | Expand all | Expand 10 after
1664 if (length > 1) { 1670 if (length > 1) {
1665 entry->translated_source.reset(new char[length]); 1671 entry->translated_source.reset(new char[length]);
1666 ShGetObjectCode(compiler, entry->translated_source.get()); 1672 ShGetObjectCode(compiler, entry->translated_source.get());
1667 } 1673 }
1668 entry->is_valid = true; 1674 entry->is_valid = true;
1669 return true; 1675 return true;
1670 } 1676 }
1671 1677
1672 } // namespace gpu 1678 } // namespace gpu
1673 } // namespace webkit 1679 } // namespace webkit
OLDNEW
« no previous file with comments | « webkit/gpu/webgraphicscontext3d_in_process_command_buffer_impl.cc ('k') | webkit/plugins/npapi/webplugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698