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

Side by Side Diff: content/common/gpu/gpu_command_buffer_stub.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
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.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) 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 #if defined(ENABLE_GPU) 5 #if defined(ENABLE_GPU)
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/debug/trace_event.h" 9 #include "base/debug/trace_event.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
(...skipping 11 matching lines...) Expand all
22 #endif 22 #endif
23 23
24 GpuCommandBufferStub::GpuCommandBufferStub( 24 GpuCommandBufferStub::GpuCommandBufferStub(
25 GpuChannel* channel, 25 GpuChannel* channel,
26 GpuCommandBufferStub* share_group, 26 GpuCommandBufferStub* share_group,
27 gfx::PluginWindowHandle handle, 27 gfx::PluginWindowHandle handle,
28 const gfx::Size& size, 28 const gfx::Size& size,
29 const gpu::gles2::DisallowedFeatures& disallowed_features, 29 const gpu::gles2::DisallowedFeatures& disallowed_features,
30 const std::string& allowed_extensions, 30 const std::string& allowed_extensions,
31 const std::vector<int32>& attribs, 31 const std::vector<int32>& attribs,
32 gfx::GpuPreference gpu_preference,
32 int32 route_id, 33 int32 route_id,
33 int32 renderer_id, 34 int32 renderer_id,
34 int32 render_view_id, 35 int32 render_view_id,
35 GpuWatchdog* watchdog, 36 GpuWatchdog* watchdog,
36 bool software) 37 bool software)
37 : channel_(channel), 38 : channel_(channel),
38 handle_(handle), 39 handle_(handle),
39 initial_size_(size), 40 initial_size_(size),
40 disallowed_features_(disallowed_features), 41 disallowed_features_(disallowed_features),
41 allowed_extensions_(allowed_extensions), 42 allowed_extensions_(allowed_extensions),
42 requested_attribs_(attribs), 43 requested_attribs_(attribs),
44 gpu_preference_(gpu_preference),
43 route_id_(route_id), 45 route_id_(route_id),
44 software_(software), 46 software_(software),
45 last_flush_count_(0), 47 last_flush_count_(0),
46 renderer_id_(renderer_id), 48 renderer_id_(renderer_id),
47 render_view_id_(render_view_id), 49 render_view_id_(render_view_id),
48 parent_stub_for_initialization_(), 50 parent_stub_for_initialization_(),
49 parent_texture_for_initialization_(0), 51 parent_texture_for_initialization_(0),
50 watchdog_(watchdog), 52 watchdog_(watchdog),
51 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) { 53 task_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
52 if (share_group) { 54 if (share_group) {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(software_, 198 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(software_,
197 gfx::Size(1, 1)); 199 gfx::Size(1, 1));
198 } 200 }
199 201
200 if (!surface_.get()) { 202 if (!surface_.get()) {
201 LOG(ERROR) << "Failed to create surface.\n"; 203 LOG(ERROR) << "Failed to create surface.\n";
202 OnInitializeFailed(reply_message); 204 OnInitializeFailed(reply_message);
203 return; 205 return;
204 } 206 }
205 207
206 context_ = gfx::GLContext::CreateGLContext(channel_->share_group(), 208 gfx::GpuPreference gpu_preference =
207 surface_.get()); 209 channel_->ShouldPreferDiscreteGpu() ?
210 gfx::PreferDiscreteGpu : gpu_preference_;
211
212 context_ = gfx::GLContext::CreateGLContext(
213 channel_->share_group(),
214 surface_.get(),
215 gpu_preference);
208 if (!context_.get()) { 216 if (!context_.get()) {
209 LOG(ERROR) << "Failed to create context.\n"; 217 LOG(ERROR) << "Failed to create context.\n";
210 OnInitializeFailed(reply_message); 218 OnInitializeFailed(reply_message);
211 return; 219 return;
212 } 220 }
213 221
214 // Initialize the decoder with either the view or pbuffer GLContext. 222 // Initialize the decoder with either the view or pbuffer GLContext.
215 if (!decoder_->Initialize(surface_.get(), 223 if (!decoder_->Initialize(surface_.get(),
216 context_.get(), 224 context_.get(),
217 initial_size_, 225 initial_size_,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
493 channel_->AddRoute(decoder_route_id, decoder); 501 channel_->AddRoute(decoder_route_id, decoder);
494 decoder->Initialize(profile, reply_message); 502 decoder->Initialize(profile, reply_message);
495 } 503 }
496 504
497 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { 505 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) {
498 channel_->RemoveRoute(decoder_route_id); 506 channel_->RemoveRoute(decoder_route_id);
499 video_decoders_.Remove(decoder_route_id); 507 video_decoders_.Remove(decoder_route_id);
500 } 508 }
501 509
502 #endif // defined(ENABLE_GPU) 510 #endif // defined(ENABLE_GPU)
OLDNEW
« no previous file with comments | « content/common/gpu/gpu_command_buffer_stub.h ('k') | content/common/gpu/gpu_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698