OLD | NEW |
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 Loading... |
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 Loading... |
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 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 channel_->AddRoute(decoder_route_id, decoder); | 499 channel_->AddRoute(decoder_route_id, decoder); |
492 decoder->Initialize(profile, reply_message); | 500 decoder->Initialize(profile, reply_message); |
493 } | 501 } |
494 | 502 |
495 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { | 503 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { |
496 channel_->RemoveRoute(decoder_route_id); | 504 channel_->RemoveRoute(decoder_route_id); |
497 video_decoders_.Remove(decoder_route_id); | 505 video_decoders_.Remove(decoder_route_id); |
498 } | 506 } |
499 | 507 |
500 #endif // defined(ENABLE_GPU) | 508 #endif // defined(ENABLE_GPU) |
OLD | NEW |