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/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); | 157 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, false); |
158 Send(reply_message); | 158 Send(reply_message); |
159 } | 159 } |
160 | 160 |
161 void GpuCommandBufferStub::OnInitialize( | 161 void GpuCommandBufferStub::OnInitialize( |
162 base::SharedMemoryHandle ring_buffer, | 162 base::SharedMemoryHandle ring_buffer, |
163 int32 size, | 163 int32 size, |
164 IPC::Message* reply_message) { | 164 IPC::Message* reply_message) { |
165 DCHECK(!command_buffer_.get()); | 165 DCHECK(!command_buffer_.get()); |
166 | 166 |
| 167 UNSHIPPED_TRACE_EVENT_INSTANT0("test_gpu", "TryCreateGLContext"); |
| 168 |
167 command_buffer_.reset(new gpu::CommandBufferService); | 169 command_buffer_.reset(new gpu::CommandBufferService); |
168 | 170 |
169 #if defined(OS_WIN) | 171 #if defined(OS_WIN) |
170 // Windows dups the shared memory handle it receives into the current process | 172 // Windows dups the shared memory handle it receives into the current process |
171 // and closes it when this variable goes out of scope. | 173 // and closes it when this variable goes out of scope. |
172 base::SharedMemory shared_memory(ring_buffer, | 174 base::SharedMemory shared_memory(ring_buffer, |
173 false, | 175 false, |
174 channel_->renderer_process()); | 176 channel_->renderer_process()); |
175 #else | 177 #else |
176 // POSIX receives a dup of the shared memory handle and closes the dup when | 178 // POSIX receives a dup of the shared memory handle and closes the dup when |
177 // this variable goes out of scope. | 179 // this variable goes out of scope. |
178 base::SharedMemory shared_memory(ring_buffer, false); | 180 base::SharedMemory shared_memory(ring_buffer, false); |
179 #endif | 181 #endif |
180 | 182 |
181 if (!command_buffer_->Initialize(&shared_memory, size)) { | 183 if (!command_buffer_->Initialize(&shared_memory, size)) { |
| 184 DLOG(ERROR) << "CommandBufferService failed to initialize.\n"; |
182 OnInitializeFailed(reply_message); | 185 OnInitializeFailed(reply_message); |
183 return; | 186 return; |
184 } | 187 } |
185 | 188 |
186 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); | 189 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); |
187 | 190 |
188 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), | 191 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), |
189 decoder_.get(), | 192 decoder_.get(), |
190 NULL)); | 193 NULL)); |
191 | 194 |
192 decoder_->set_engine(scheduler_.get()); | 195 decoder_->set_engine(scheduler_.get()); |
193 | 196 |
194 if (handle_) { | 197 if (handle_) { |
195 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 198 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
196 if (software_) { | 199 if (software_) { |
| 200 DLOG(ERROR) << "No software support.\n"; |
197 OnInitializeFailed(reply_message); | 201 OnInitializeFailed(reply_message); |
198 return; | 202 return; |
199 } | 203 } |
200 #endif | 204 #endif |
201 | 205 |
202 surface_ = ImageTransportSurface::CreateSurface( | 206 surface_ = ImageTransportSurface::CreateSurface( |
203 channel_->gpu_channel_manager(), | 207 channel_->gpu_channel_manager(), |
204 render_view_id_, | 208 render_view_id_, |
205 renderer_id_, | 209 renderer_id_, |
206 route_id_, | 210 route_id_, |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 | 275 |
272 if (parent_stub_for_initialization_) { | 276 if (parent_stub_for_initialization_) { |
273 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), | 277 decoder_->SetParent(parent_stub_for_initialization_->decoder_.get(), |
274 parent_texture_for_initialization_); | 278 parent_texture_for_initialization_); |
275 parent_stub_for_initialization_.reset(); | 279 parent_stub_for_initialization_.reset(); |
276 parent_texture_for_initialization_ = 0; | 280 parent_texture_for_initialization_ = 0; |
277 } | 281 } |
278 | 282 |
279 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); | 283 GpuCommandBufferMsg_Initialize::WriteReplyParams(reply_message, true); |
280 Send(reply_message); | 284 Send(reply_message); |
| 285 |
| 286 UNSHIPPED_TRACE_EVENT_INSTANT1("test_gpu", "CreateGLContextSuccess", |
| 287 "offscreen", surface_->IsOffscreen()); |
281 } | 288 } |
282 | 289 |
283 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, | 290 void GpuCommandBufferStub::OnSetParent(int32 parent_route_id, |
284 uint32 parent_texture_id, | 291 uint32 parent_texture_id, |
285 IPC::Message* reply_message) { | 292 IPC::Message* reply_message) { |
286 | 293 |
287 GpuCommandBufferStub* parent_stub = NULL; | 294 GpuCommandBufferStub* parent_stub = NULL; |
288 if (parent_route_id != MSG_ROUTING_NONE) { | 295 if (parent_route_id != MSG_ROUTING_NONE) { |
289 parent_stub = channel_->LookupCommandBuffer(parent_route_id); | 296 parent_stub = channel_->LookupCommandBuffer(parent_route_id); |
290 } | 297 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
458 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { | 465 void GpuCommandBufferStub::OnDestroyVideoDecoder(int decoder_route_id) { |
459 channel_->RemoveRoute(decoder_route_id); | 466 channel_->RemoveRoute(decoder_route_id); |
460 video_decoders_.Remove(decoder_route_id); | 467 video_decoders_.Remove(decoder_route_id); |
461 } | 468 } |
462 | 469 |
463 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { | 470 void GpuCommandBufferStub::OnSetSurfaceVisible(bool visible) { |
464 surface_->SetVisible(visible); | 471 surface_->SetVisible(visible); |
465 } | 472 } |
466 | 473 |
467 #endif // defined(ENABLE_GPU) | 474 #endif // defined(ENABLE_GPU) |
OLD | NEW |