OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "base/bind_helpers.h" | 6 #include "base/bind_helpers.h" |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/hash.h" | 8 #include "base/hash.h" |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 while (!sync_points_.empty()) | 478 while (!sync_points_.empty()) |
479 OnRetireSyncPoint(sync_points_.front()); | 479 OnRetireSyncPoint(sync_points_.front()); |
480 | 480 |
481 if (decoder_) | 481 if (decoder_) |
482 decoder_->set_engine(NULL); | 482 decoder_->set_engine(NULL); |
483 | 483 |
484 // The scheduler has raw references to the decoder and the command buffer so | 484 // The scheduler has raw references to the decoder and the command buffer so |
485 // destroy it before those. | 485 // destroy it before those. |
486 scheduler_.reset(); | 486 scheduler_.reset(); |
487 | 487 |
| 488 sync_point_client_.reset(); |
| 489 |
488 bool have_context = false; | 490 bool have_context = false; |
489 if (decoder_ && decoder_->GetGLContext()) { | 491 if (decoder_ && decoder_->GetGLContext()) { |
490 // Try to make the context current regardless of whether it was lost, so we | 492 // Try to make the context current regardless of whether it was lost, so we |
491 // don't leak resources. | 493 // don't leak resources. |
492 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); | 494 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); |
493 } | 495 } |
494 FOR_EACH_OBSERVER(DestructionObserver, | 496 FOR_EACH_OBSERVER(DestructionObserver, |
495 destruction_observers_, | 497 destruction_observers_, |
496 OnWillDestroyStub()); | 498 OnWillDestroyStub()); |
497 | 499 |
(...skipping 23 matching lines...) Expand all Loading... |
521 | 523 |
522 scoped_ptr<base::SharedMemory> shared_state_shm( | 524 scoped_ptr<base::SharedMemory> shared_state_shm( |
523 new base::SharedMemory(shared_state_handle, false)); | 525 new base::SharedMemory(shared_state_handle, false)); |
524 | 526 |
525 command_buffer_.reset(new gpu::CommandBufferService( | 527 command_buffer_.reset(new gpu::CommandBufferService( |
526 context_group_->transfer_buffer_manager())); | 528 context_group_->transfer_buffer_manager())); |
527 | 529 |
528 bool result = command_buffer_->Initialize(); | 530 bool result = command_buffer_->Initialize(); |
529 DCHECK(result); | 531 DCHECK(result); |
530 | 532 |
| 533 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
| 534 DCHECK(manager); |
| 535 |
| 536 gpu::SyncPointManager* sync_point_manager = manager->sync_point_manager(); |
| 537 DCHECK(sync_point_manager); |
| 538 |
531 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); | 539 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); |
532 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), | 540 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), |
533 decoder_.get(), | 541 decoder_.get(), |
534 decoder_.get())); | 542 decoder_.get())); |
| 543 sync_point_client_ = |
| 544 sync_point_manager->CreateSyncPointClient( |
| 545 channel_->GetSyncPointClientState(), |
| 546 gpu::CommandBufferNamespace::GPU_IO, |
| 547 command_buffer_id_); |
| 548 |
535 if (preemption_flag_.get()) | 549 if (preemption_flag_.get()) |
536 scheduler_->SetPreemptByFlag(preemption_flag_); | 550 scheduler_->SetPreemptByFlag(preemption_flag_); |
537 | 551 |
538 decoder_->set_engine(scheduler_.get()); | 552 decoder_->set_engine(scheduler_.get()); |
539 | 553 |
540 if (!handle_.is_null()) { | 554 if (!handle_.is_null()) { |
541 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 555 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
542 if (software_) { | 556 if (software_) { |
543 LOG(ERROR) << "No software support."; | 557 LOG(ERROR) << "No software support."; |
544 OnInitializeFailed(reply_message); | 558 OnInitializeFailed(reply_message); |
545 return; | 559 return; |
546 } | 560 } |
547 #endif | 561 #endif |
548 | 562 |
549 surface_ = ImageTransportSurface::CreateSurface( | 563 surface_ = ImageTransportSurface::CreateSurface( |
550 channel_->gpu_channel_manager(), | 564 channel_->gpu_channel_manager(), |
551 this, | 565 this, |
552 handle_); | 566 handle_); |
553 } else { | 567 } else { |
554 GpuChannelManager* manager = channel_->gpu_channel_manager(); | |
555 surface_ = manager->GetDefaultOffscreenSurface(); | 568 surface_ = manager->GetDefaultOffscreenSurface(); |
556 } | 569 } |
557 | 570 |
558 if (!surface_.get()) { | 571 if (!surface_.get()) { |
559 DLOG(ERROR) << "Failed to create surface."; | 572 DLOG(ERROR) << "Failed to create surface."; |
560 OnInitializeFailed(reply_message); | 573 OnInitializeFailed(reply_message); |
561 return; | 574 return; |
562 } | 575 } |
563 | 576 |
564 scoped_refptr<gfx::GLContext> context; | 577 scoped_refptr<gfx::GLContext> context; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
675 shared_state_shm.Pass(), kSharedStateSize)); | 688 shared_state_shm.Pass(), kSharedStateSize)); |
676 | 689 |
677 gpu::Capabilities capabilities = decoder_->GetCapabilities(); | 690 gpu::Capabilities capabilities = decoder_->GetCapabilities(); |
678 capabilities.future_sync_points = channel_->allow_future_sync_points(); | 691 capabilities.future_sync_points = channel_->allow_future_sync_points(); |
679 | 692 |
680 GpuCommandBufferMsg_Initialize::WriteReplyParams( | 693 GpuCommandBufferMsg_Initialize::WriteReplyParams( |
681 reply_message, true, capabilities); | 694 reply_message, true, capabilities); |
682 Send(reply_message); | 695 Send(reply_message); |
683 | 696 |
684 if (handle_.is_null() && !active_url_.is_empty()) { | 697 if (handle_.is_null() && !active_url_.is_empty()) { |
685 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 698 manager->Send(new GpuHostMsg_DidCreateOffscreenContext( |
686 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | |
687 active_url_)); | 699 active_url_)); |
688 } | 700 } |
689 | 701 |
690 initialized_ = true; | 702 initialized_ = true; |
691 } | 703 } |
692 | 704 |
693 void GpuCommandBufferStub::OnCreateStreamTexture( | 705 void GpuCommandBufferStub::OnCreateStreamTexture( |
694 uint32 texture_id, int32 stream_id, bool* succeeded) { | 706 uint32 texture_id, int32 stream_id, bool* succeeded) { |
695 #if defined(OS_ANDROID) | 707 #if defined(OS_ANDROID) |
696 *succeeded = StreamTexture::Create(this, texture_id, stream_id); | 708 *succeeded = StreamTexture::Create(this, texture_id, stream_id); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1216 result)); | 1228 result)); |
1217 } | 1229 } |
1218 | 1230 |
1219 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1231 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1220 base::TimeDelta interval) { | 1232 base::TimeDelta interval) { |
1221 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1233 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1222 interval)); | 1234 interval)); |
1223 } | 1235 } |
1224 | 1236 |
1225 } // namespace content | 1237 } // namespace content |
OLD | NEW |