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 460 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 while (!sync_points_.empty()) | 471 while (!sync_points_.empty()) |
472 OnRetireSyncPoint(sync_points_.front()); | 472 OnRetireSyncPoint(sync_points_.front()); |
473 | 473 |
474 if (decoder_) | 474 if (decoder_) |
475 decoder_->set_engine(NULL); | 475 decoder_->set_engine(NULL); |
476 | 476 |
477 // The scheduler has raw references to the decoder and the command buffer so | 477 // The scheduler has raw references to the decoder and the command buffer so |
478 // destroy it before those. | 478 // destroy it before those. |
479 scheduler_.reset(); | 479 scheduler_.reset(); |
480 | 480 |
| 481 sync_point_client_.reset(); |
| 482 |
481 bool have_context = false; | 483 bool have_context = false; |
482 if (decoder_ && decoder_->GetGLContext()) { | 484 if (decoder_ && decoder_->GetGLContext()) { |
483 // Try to make the context current regardless of whether it was lost, so we | 485 // Try to make the context current regardless of whether it was lost, so we |
484 // don't leak resources. | 486 // don't leak resources. |
485 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); | 487 have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); |
486 } | 488 } |
487 FOR_EACH_OBSERVER(DestructionObserver, | 489 FOR_EACH_OBSERVER(DestructionObserver, |
488 destruction_observers_, | 490 destruction_observers_, |
489 OnWillDestroyStub()); | 491 OnWillDestroyStub()); |
490 | 492 |
(...skipping 23 matching lines...) Expand all Loading... |
514 | 516 |
515 scoped_ptr<base::SharedMemory> shared_state_shm( | 517 scoped_ptr<base::SharedMemory> shared_state_shm( |
516 new base::SharedMemory(shared_state_handle, false)); | 518 new base::SharedMemory(shared_state_handle, false)); |
517 | 519 |
518 command_buffer_.reset(new gpu::CommandBufferService( | 520 command_buffer_.reset(new gpu::CommandBufferService( |
519 context_group_->transfer_buffer_manager())); | 521 context_group_->transfer_buffer_manager())); |
520 | 522 |
521 bool result = command_buffer_->Initialize(); | 523 bool result = command_buffer_->Initialize(); |
522 DCHECK(result); | 524 DCHECK(result); |
523 | 525 |
| 526 GpuChannelManager* manager = channel_->gpu_channel_manager(); |
| 527 DCHECK(manager); |
| 528 |
| 529 gpu::SyncPointManager* sync_point_manager = manager->sync_point_manager(); |
| 530 DCHECK(sync_point_manager); |
| 531 |
524 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); | 532 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group_.get())); |
525 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), | 533 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), |
526 decoder_.get(), | 534 decoder_.get(), |
527 decoder_.get())); | 535 decoder_.get())); |
| 536 sync_point_client_ = |
| 537 sync_point_manager->CreateSyncPointClient( |
| 538 channel_->GetSyncPointClientState(), |
| 539 gpu::CommandBufferNamespace::GPU_IO, |
| 540 command_buffer_id_); |
| 541 |
528 if (preemption_flag_.get()) | 542 if (preemption_flag_.get()) |
529 scheduler_->SetPreemptByFlag(preemption_flag_); | 543 scheduler_->SetPreemptByFlag(preemption_flag_); |
530 | 544 |
531 decoder_->set_engine(scheduler_.get()); | 545 decoder_->set_engine(scheduler_.get()); |
532 | 546 |
533 if (!handle_.is_null()) { | 547 if (!handle_.is_null()) { |
534 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) | 548 #if defined(OS_MACOSX) || defined(UI_COMPOSITOR_IMAGE_TRANSPORT) |
535 if (software_) { | 549 if (software_) { |
536 LOG(ERROR) << "No software support."; | 550 LOG(ERROR) << "No software support."; |
537 OnInitializeFailed(reply_message); | 551 OnInitializeFailed(reply_message); |
538 return; | 552 return; |
539 } | 553 } |
540 #endif | 554 #endif |
541 | 555 |
542 surface_ = ImageTransportSurface::CreateSurface( | 556 surface_ = ImageTransportSurface::CreateSurface( |
543 channel_->gpu_channel_manager(), | 557 channel_->gpu_channel_manager(), |
544 this, | 558 this, |
545 handle_); | 559 handle_); |
546 } else { | 560 } else { |
547 GpuChannelManager* manager = channel_->gpu_channel_manager(); | |
548 surface_ = manager->GetDefaultOffscreenSurface(); | 561 surface_ = manager->GetDefaultOffscreenSurface(); |
549 } | 562 } |
550 | 563 |
551 if (!surface_.get()) { | 564 if (!surface_.get()) { |
552 DLOG(ERROR) << "Failed to create surface."; | 565 DLOG(ERROR) << "Failed to create surface."; |
553 OnInitializeFailed(reply_message); | 566 OnInitializeFailed(reply_message); |
554 return; | 567 return; |
555 } | 568 } |
556 | 569 |
557 scoped_refptr<gfx::GLContext> context; | 570 scoped_refptr<gfx::GLContext> context; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 shared_state_shm.Pass(), kSharedStateSize)); | 681 shared_state_shm.Pass(), kSharedStateSize)); |
669 | 682 |
670 gpu::Capabilities capabilities = decoder_->GetCapabilities(); | 683 gpu::Capabilities capabilities = decoder_->GetCapabilities(); |
671 capabilities.future_sync_points = channel_->allow_future_sync_points(); | 684 capabilities.future_sync_points = channel_->allow_future_sync_points(); |
672 | 685 |
673 GpuCommandBufferMsg_Initialize::WriteReplyParams( | 686 GpuCommandBufferMsg_Initialize::WriteReplyParams( |
674 reply_message, true, capabilities); | 687 reply_message, true, capabilities); |
675 Send(reply_message); | 688 Send(reply_message); |
676 | 689 |
677 if (handle_.is_null() && !active_url_.is_empty()) { | 690 if (handle_.is_null() && !active_url_.is_empty()) { |
678 GpuChannelManager* gpu_channel_manager = channel_->gpu_channel_manager(); | 691 manager->Send(new GpuHostMsg_DidCreateOffscreenContext( |
679 gpu_channel_manager->Send(new GpuHostMsg_DidCreateOffscreenContext( | |
680 active_url_)); | 692 active_url_)); |
681 } | 693 } |
682 | 694 |
683 initialized_ = true; | 695 initialized_ = true; |
684 } | 696 } |
685 | 697 |
686 void GpuCommandBufferStub::OnCreateStreamTexture( | 698 void GpuCommandBufferStub::OnCreateStreamTexture( |
687 uint32 texture_id, int32 stream_id, bool* succeeded) { | 699 uint32 texture_id, int32 stream_id, bool* succeeded) { |
688 #if defined(OS_ANDROID) | 700 #if defined(OS_ANDROID) |
689 *succeeded = StreamTexture::Create(this, texture_id, stream_id); | 701 *succeeded = StreamTexture::Create(this, texture_id, stream_id); |
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1209 result)); | 1221 result)); |
1210 } | 1222 } |
1211 | 1223 |
1212 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, | 1224 void GpuCommandBufferStub::SendUpdateVSyncParameters(base::TimeTicks timebase, |
1213 base::TimeDelta interval) { | 1225 base::TimeDelta interval) { |
1214 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, | 1226 Send(new GpuCommandBufferMsg_UpdateVSyncParameters(route_id_, timebase, |
1215 interval)); | 1227 interval)); |
1216 } | 1228 } |
1217 | 1229 |
1218 } // namespace content | 1230 } // namespace content |
OLD | NEW |