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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer( | 67 gpu_channel_manager->Send(new GpuHostMsg_DestroyCommandBuffer( |
68 handle_, renderer_id_, render_view_id_)); | 68 handle_, renderer_id_, render_view_id_)); |
69 } | 69 } |
70 | 70 |
71 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { | 71 bool GpuCommandBufferStub::OnMessageReceived(const IPC::Message& message) { |
72 // Ensure the appropriate GL context is current before handling any IPC | 72 // Ensure the appropriate GL context is current before handling any IPC |
73 // messages directed at the command buffer. This ensures that the message | 73 // messages directed at the command buffer. This ensures that the message |
74 // handler can assume that the context is current. | 74 // handler can assume that the context is current. |
75 if (decoder_.get()) { | 75 if (decoder_.get()) { |
76 if (!decoder_->MakeCurrent()) { | 76 if (!decoder_->MakeCurrent()) { |
77 LOG(ERROR) << "Context lost because MakeCurrent failed."; | 77 DLOG(ERROR) << "Context lost because MakeCurrent failed."; |
78 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); | 78 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); |
79 command_buffer_->SetParseError(gpu::error::kLostContext); | 79 command_buffer_->SetParseError(gpu::error::kLostContext); |
80 if (gfx::GLContext::LosesAllContextsOnContextLost()) | 80 if (gfx::GLContext::LosesAllContextsOnContextLost()) |
81 channel_->LoseAllContexts(); | 81 channel_->LoseAllContexts(); |
82 return false; | 82 return false; |
83 } | 83 } |
84 } | 84 } |
85 | 85 |
86 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers | 86 // Always use IPC_MESSAGE_HANDLER_DELAY_REPLY for synchronous message handlers |
87 // here. This is so the reply can be delayed if the scheduler is unscheduled. | 87 // here. This is so the reply can be delayed if the scheduler is unscheduled. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 #endif | 198 #endif |
199 } else { | 199 } else { |
200 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(software_, | 200 surface_ = gfx::GLSurface::CreateOffscreenGLSurface(software_, |
201 gfx::Size(1, 1)); | 201 gfx::Size(1, 1)); |
202 } | 202 } |
203 | 203 |
204 if (!surface_.get()) { | 204 if (!surface_.get()) { |
205 // Ensure the decoder is not destroyed if it is not initialized. | 205 // Ensure the decoder is not destroyed if it is not initialized. |
206 decoder_.reset(); | 206 decoder_.reset(); |
207 | 207 |
208 LOG(ERROR) << "Failed to create surface.\n"; | 208 DLOG(ERROR) << "Failed to create surface.\n"; |
209 OnInitializeFailed(reply_message); | 209 OnInitializeFailed(reply_message); |
210 return; | 210 return; |
211 } | 211 } |
212 | 212 |
213 gfx::GpuPreference gpu_preference = | 213 gfx::GpuPreference gpu_preference = |
214 channel_->ShouldPreferDiscreteGpu() ? | 214 channel_->ShouldPreferDiscreteGpu() ? |
215 gfx::PreferDiscreteGpu : gpu_preference_; | 215 gfx::PreferDiscreteGpu : gpu_preference_; |
216 | 216 |
217 context_ = gfx::GLContext::CreateGLContext( | 217 context_ = gfx::GLContext::CreateGLContext( |
218 channel_->share_group(), | 218 channel_->share_group(), |
219 surface_.get(), | 219 surface_.get(), |
220 gpu_preference); | 220 gpu_preference); |
221 if (!context_.get()) { | 221 if (!context_.get()) { |
222 // Ensure the decoder is not destroyed if it is not initialized. | 222 // Ensure the decoder is not destroyed if it is not initialized. |
223 decoder_.reset(); | 223 decoder_.reset(); |
224 | 224 |
225 LOG(ERROR) << "Failed to create context.\n"; | 225 DLOG(ERROR) << "Failed to create context.\n"; |
226 OnInitializeFailed(reply_message); | 226 OnInitializeFailed(reply_message); |
227 return; | 227 return; |
228 } | 228 } |
229 | 229 |
230 // Initialize the decoder with either the view or pbuffer GLContext. | 230 // Initialize the decoder with either the view or pbuffer GLContext. |
231 if (!decoder_->Initialize(surface_.get(), | 231 if (!decoder_->Initialize(surface_.get(), |
232 context_.get(), | 232 context_.get(), |
233 initial_size_, | 233 initial_size_, |
234 disallowed_features_, | 234 disallowed_features_, |
235 allowed_extensions_.c_str(), | 235 allowed_extensions_.c_str(), |
236 requested_attribs_)) { | 236 requested_attribs_)) { |
237 LOG(ERROR) << "Failed to initialize decoder."; | 237 DLOG(ERROR) << "Failed to initialize decoder."; |
238 OnInitializeFailed(reply_message); | 238 OnInitializeFailed(reply_message); |
239 return; | 239 return; |
240 } | 240 } |
241 | 241 |
242 if (CommandLine::ForCurrentProcess()->HasSwitch( | 242 if (CommandLine::ForCurrentProcess()->HasSwitch( |
243 switches::kEnableGPUServiceLogging)) { | 243 switches::kEnableGPUServiceLogging)) { |
244 decoder_->set_debug(true); | 244 decoder_->set_debug(true); |
245 } | 245 } |
246 | 246 |
247 SetSwapInterval(); | 247 SetSwapInterval(); |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { | 513 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { |
514 channel_->RemoveRoute(decoder_route_id); | 514 channel_->RemoveRoute(decoder_route_id); |
515 video_decoders_.Remove(decoder_route_id); | 515 video_decoders_.Remove(decoder_route_id); |
516 } | 516 } |
517 | 517 |
518 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { | 518 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { |
519 surface_->SetVisible(visible); | 519 surface_->SetVisible(visible); |
520 } | 520 } |
521 | 521 |
522 #endif // defined(ENABLE_GPU) | 522 #endif // defined(ENABLE_GPU) |
OLD | NEW |